<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM Corp.
- IBM UrbanCode Build
- IBM UrbanCode Deploy
- IBM UrbanCode Release
- IBM AnthillPro
- (c) Copyright IBM Corporation 2002, 2013. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-->
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier version="10" id="com.urbancode.air.plugin.DeployTools" name="Deploy Tools"/>
    <description>
         The Deploy Tools plugin provides automated post deployment verification.
      </description>
    <tag>Quality/Functional Testing/Simple Web Test</tag>
  </header>
  <!-- ==================================== -->
  <!--   Verify Deployment                  -->
  <!-- ==================================== -->
  <step-type name="Verify Deployment">
    <description>Verify the deployment of an application through http interface.</description>
    <properties>
      <property name="url" required="true">
        <property-ui type="textBox"
                     label="URL"
                     description="URL to use to verify deployment."/>
      </property>
      <property name="charset" required="false">
        <property-ui type="textBox"
                     label="Charset"
                     description="Optionally specify the charset for the file. The default is UTF-8" />
      </property>
      <property name="verifyString" required="true">
        <property-ui type="textBox"
                     label="Verification String"
                     description="String to search for in response to verify the correct deployment."/>
      </property>
      <property name="failIfFound">
        <property-ui type="checkBox"
                     label="Fail if match found"
                     description="Check here if you want to fail if a match is found rather than succeed."/>
      </property>
      <property name="user">
        <property-ui type="textBox"
                     label="User Name"
                     description="User name to use for authentication."/>
      </property>
      <property name="password">
        <property-ui type="secureBox"
                     label="Password"
                     description="Password to use for authentication."/>
      </property>
      <property name="timeout">
        <property-ui type="textBox"
                     label="Timeout"
                     description="The timeout in milliseconds if default is too long."/>
      </property>
      <property name="passScript">
        <property-ui type="textAreaBox"
                     label="Password Script"
                     description="A script that returns the password to use for authentication."/>
      </property>
    </properties>
    <post-processing>
      <![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]>
    </post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsUtil.jar:lib/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/log4j-api.jar:lib/log4j-1.2-api.jar:lib/log4j-core.jar:lib/commons-lang3.jar:lib/securedata.jar:lib/jettison.jar"/>
      <arg file="verify_deploy.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ==================================== -->
  <!--   Wait for web page                  -->
  <!-- ==================================== -->
  <step-type name="Wait for web page">
    <description>Wait for a web page to be accessible and have certain contents.</description>
    <properties>
      <property name="url" required="true">
        <property-ui type="textBox"
                     label="URL"
                     description="URL to use to verify deployment."/>
      </property>
      <property name="verifyString" required="true">
        <property-ui type="textBox"
                     label="Verification String"
                     description="String to search for in response to verify the correct deployment."/>
      </property>
      <property name="failIfFound">
        <property-ui type="checkBox"
                     label="Fail if match found"
                     description="Check here if you want to fail if a match is found rather than succeed."/>
      </property>
      <property name="user">
        <property-ui type="textBox"
                     label="User Name"
                     description="User name to use for authentication."/>
      </property>
      <property name="password">
        <property-ui type="secureBox"
                     label="Password"
                     description="Password to use for authentication."/>
      </property>
      <property name="timeout">
        <property-ui type="textBox"
                     label="Timeout"
                     description="The timeout in milliseconds if default is too long."/>
      </property>
      <property name="passScript">
        <property-ui type="textAreaBox"
                     label="Password Script"
                     description="A script that returns the password to use for authentication."/>
      </property>
      <property name="maxWaitTime" required="true">
        <property-ui type="textBox"
                     label="Maximum wait time (s)"
                     description="The maximum time in seconds to wait for the conditions to be met."/>
      </property>
      <property name="retryTimeout" required="true">
      <property-ui type="textBox"
                     label="Retry wait time (ms)"
                     default-value="5000"
                     description="The number of milliseconds to wait between retries."/>
      </property>
      <property name="proxyHost">
        <property-ui type="textBox"
                     label="Proxy Hostname"
                     description="Specify the hostname of the proxy server if connecting to website through a proxy. (e.g. 8.8.8.8)"
                     default-value="${p?:agent/deployTools.proxyHost}"/>
      </property>
      <property name="proxyPort">
        <property-ui type="textBox"
                     label="Proxy Port Number"
                     description="Specify the port number being used by the proxy server for client connections. (e.g. 80)"
                     default-value="${p?:agent/deployTools.proxyPort}"/>
      </property>
      <property name="proxyUser">
        <property-ui type="textBox"
                     label="Proxy Username"
                     description="Specify the username to authenticate with the proxy server if authentication is required."
                     default-value="${p?:agent/deployTools.proxyUser}"/>
      </property>
      <property name="proxyPass">
        <property-ui type="textBox"
                     label="Proxy Password"
                     description="Specify the password to authenticate with the proxy server if authentication is required."
                     default-value="${p?:agent/deployTools.proxyPass}"/>
      </property>
    </properties>
    <post-processing>
      <![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]>
    </post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsUtil.jar:lib/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/log4j-api.jar:lib/log4j-1.2-api.jar:lib/log4j-core.jar:lib/commons-lang3.jar:lib/securedata.jar:lib/jettison.jar"/>
      <arg file="wait_for_web_page.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ==================================== -->
  <!--   Check Total Process execution Time -->
  <!-- ==================================== -->
  <step-type name="Check Total Application Process Execution Time">
    <description>Check how long the application process has ran and fail if above a certain threshold.</description>
    <properties>
      <property name="timeout" required="true">
        <property-ui type="textBox"
                     label="Timeout"
                     description="The allowed time (in seconds) for the application process to run."/>
      </property>
      <property name="requestId" required="true">
        <property-ui type="textBox"
                     hidden="true"
                     label="Component Process Request ID"
                     default-value="${p:request.id}"/>
      </property>
    </properties>
    <post-processing>
      <![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]>
    </post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsUtil.jar:lib/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/commons-lang.jar:lib/commons-lang3.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/securedata.jar:lib/jettison.jar"/>
      <arg file="check_total_application_execution_time.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ==================================== -->
  <!--   Check Total Component execution Time -->
  <!-- ==================================== -->
  <step-type name="Check Total Component Process Execution Time">
    <description>Check how long the component process has ran and fail if above a certain threshold.</description>
    <properties>
      <property name="timeout" required="true">
        <property-ui type="textBox"
                     label="Timeout"
                     description="The allowed time (in seconds) for the application process to run."/>
      </property>
      <property name="requestId" required="true">
        <property-ui type="textBox"
                     hidden="true"
                     label="Component Process Request ID"
                     default-value="${p:request.id}"/>
      </property>
    </properties>
    <post-processing>
      <![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]>
    </post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsUtil.jar:lib/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/commons-lang.jar:lib/commons-lang3.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/securedata.jar:lib/jettison.jar"/>
      <arg file="check_total_component_execution_time.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
</plugin>
