<?xml version="1.0"?>

<project name="Test sampler deployment" basedir="." default="integration-test-all">
   
	<!-- Target deploying demo.war -->
	<fail unless="test.integration.server" message="test.integration.server must be set for integration tests to run"/>
	
	<fail unless="test.integration.user" message="test.integration.user must be set for integration tests to run"/>
	<fail unless="test.integration.antfile" message="test.integration.antfile must be set for integration tests to run"/>

	<!-- Test with these browsers -->
	<property name="test_browsers" value="winxp-firefox36" />

	<!-- Path to key file. Default value -->
	<property name="sshkey.file" value="id_dsa" />
	
	<!-- path and name for demo.war to be deployed -->
	<property name="demo.war" value="demo.war"/>
	
	<!-- Host running Testbench RC or Testbench Hub. Default value -->
	<property name="com.vaadin.testbench.tester.host" value="127.0.0.1" />

	<!-- Base url where the testable application is deployed -->
	<property name="deployment.url" value="http://${test.integration.server}:8080" />

	<!-- ssh host values -->
	<property name="ant.hub" value="${test.integration.antfile}" />
	<property name="user" value="${test.integration.user}" />
	<property name="passphrase" value="" />
	
	<!-- add ant contrib -->
	<taskdef resource="net/sf/antcontrib/antcontrib.properties">
		<classpath>
			<pathelement location="../build/lib/ant-contrib-1.0b3.jar"/>
		</classpath>
	</taskdef>
	
	<!-- Upload war to deploy to ssh host -->
	<target name="integration-test-upload-demo">
		<scp file="${demo.war}" todir="${user}@${test.integration.server}:integration-tests/servers/demo.war" keyfile="${sshkey.file}" passphrase="${passphrase}" />
	</target>
	
	<!-- Run sampler deployment test -->
	<target name="integration-test-sampler">
		<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-${server-name}-sampler.html" />
		<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
		
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
			<property name="server.start.succeeded" value="1" />
			<property name="browsers" value="${test_browsers}" />
			<property name="testfiles" value="${testfiles}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
			
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
	
	<!-- Start and stop methods for servers -->
	<target name="integration-test-start-tomcat-4">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-tomcat-4.1.40" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-tomcat-4.1.40-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-tomcat-4">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-tomcat-4.1.40" />
	</target>
	
	<target name="integration-test-start-tomcat-5">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-tomcat-5.5.28" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-tomcat-5.5.28-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-tomcat-5">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-tomcat-5.5.28" />
	</target>
	
	<target name="integration-test-start-tomcat-6">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-tomcat-6.0.20" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-tomcat-6.0.20-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-tomcat-6">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-tomcat-6.0.20" />
	</target>
	
	<target name="integration-test-start-jetty-5">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-jetty-5.1.15" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-jetty-5.1.15-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-jetty-5">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-jetty-5.1.15" />
	</target>

	<target name="integration-test-start-jetty-6">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-jetty-6.1.22" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-jetty-6.1.22-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-jetty-6">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-jetty-6.1.22" />
	</target>
	
	<target name="integration-test-start-jetty-7">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-jetty-7.0.0" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-jetty-7.0.0-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-jetty-7">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-jetty-7.0.0" />
	</target>
	
	<target name="integration-test-start-jboss-3">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-jboss-3.2.8" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-jboss-3.2.8-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-jboss-3">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-jboss-3.2.8" />
	</target>
	
	<target name="integration-test-start-jboss-4">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-jboss-4.2.3" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-jboss-4.2.3-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-jboss-4">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-jboss-4.2.3" />
	</target>
	
	<target name="integration-test-start-jboss-5">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-jboss-5.0.1" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-jboss-5.0.1-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-jboss-5">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-jboss-5.0.1" />
	</target>
	
	<target name="integration-test-start-glassfish2">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-glassfish-2.1.1" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-glassfish-2.1.1-sampler.html" overwrite="true" />
	</target>
	
	<target name="integration-test-stop-glassfish2">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-glassfish-2.1.1" />
	</target>
	
	<target name="integration-test-start-glassfish3">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-glassfish-3" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-glassfish-3-sampler.html" overwrite="true" />
	</target>
	
	<target name="integration-test-stop-glassfish3">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-glassfish-3" />
	</target>
			
	<!-- Test liferay sampler -->
	<target name="integration-test-test-liferay">
		<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-liferay-5.2.3-sampler.html" />
		<pathconvert pathsep=" " property="test-liferay" refid="html-test-files" />
		
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
			<property name="server.start.succeeded" value="1" />
			<property name="browsers" value="${test_browsers}" />
			<property name="testfiles" value="${test-liferay}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
			
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
	
	<!-- "deploy" sampler to liferay -->
	<target name="integration-test-init-liferay">
		<fileset dir="integration-testscripts" id="html-test-files" includes="Add_Sampler_to_Liferay.html" />
		<pathconvert pathsep=" " property="init-liferay" refid="html-test-files" />
		
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
			<property name="server.start.succeeded" value="1" />
			<property name="browsers" value="winxp-firefox36" />
			<property name="testfiles" value="${init-liferay}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
	
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
	
	<target name="integration-test-liferay-portlet2">
		<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-liferay-5.2.3-portlet2.html" />
		<pathconvert pathsep=" " property="init-liferay" refid="html-test-files" />
		
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
			<property name="server.start.succeeded" value="1" />
			<property name="browsers" value="winxp-firefox36" />
			<property name="testfiles" value="${init-liferay}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
	
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
		
	<target name="integration-test-liferay-6">
		<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-liferay-6.0.5.html" />
		<pathconvert pathsep=" " property="test-liferay" refid="html-test-files" />
		
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
			<property name="server.start.succeeded" value="1" />
			<property name="browsers" value="winxp-firefox36" />
			<property name="testfiles" value="${test-liferay}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
	
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
	
	<target name="test-theme-liferay-6">
		<fileset dir="integration-testscripts" id="html-test-files" includes="Liferay6-theme.html" />
		<pathconvert pathsep=" " property="test-liferay" refid="html-test-files" />
			
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
			<property name="server.start.succeeded" value="1" />
			<property name="testfiles" value="${test-liferay}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
		
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
	
	<target name="integration-test-liferay-6ee">
			<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-liferay-6ee.html" />
			<pathconvert pathsep=" " property="test-liferay" refid="html-test-files" />
			
			<subant target="run-tests" failonerror="false" antfile="test.xml">
				<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
				<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
				<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
				<property name="server.start.succeeded" value="1" />
				<property name="browsers" value="winxp-firefox36" />
				<property name="testfiles" value="${test-liferay}" />
				<property name="test-output-dir" value="../build/integration-test-output" />
		
				<fileset dir="." includes="test.xml" />
			</subant>
		</target>
	
	<target name="test-theme-liferay-6ee">
			<fileset dir="integration-testscripts" id="html-test-files" includes="Liferay6EE-theme.html" />
			<pathconvert pathsep=" " property="test-liferay" refid="html-test-files" />
				
			<subant target="run-tests" failonerror="false" antfile="test.xml">
				<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
				<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
				<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
				<property name="server.start.succeeded" value="1" />
				<property name="testfiles" value="${test-liferay}" />
				<property name="test-output-dir" value="../build/integration-test-output" />
			
				<fileset dir="." includes="test.xml" />
			</subant>
		</target>	
	
	<target name="integration-test-gatein-3">
		<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-GateIn-3.1.0-sampler.html" />
		<pathconvert pathsep=" " property="test-gatein" refid="html-test-files" />
		
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" />
			<property name="server.start.succeeded" value="1" />
			<property name="browsers" value="winxp-firefox36" />
			<property name="testfiles" value="${test-gatein}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
	
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
	
	<target name="integration-test-start-liferay">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-liferay-5.2.3" />
		<copy file="integration-testscripts/sampler_deployment_liferay.html" tofile="integration-testscripts/integration-test-liferay-5.2.3-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-liferay">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-liferay-5.2.3" />
	</target>
	
	<target name="integration-test-start-liferay-6">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-liferay-6.0.5" />
		<copy file="integration-testscripts/integration-test-liferay-6.0.5.html" tofile="integration-testscripts/integration-test-liferay-6.0.5-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-liferay-6">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-liferay-6.0.5" />
	</target>
	
	<target name="integration-test-start-liferay-6ee">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-liferay-6.0-ee" />
	</target>

	<target name="integration-test-stop-liferay-6ee">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-liferay-6.0-ee" />
	</target>
			
	<target name="integration-test-start-gatein-3">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-gatein-3.1.0" />
	</target>

	<target name="integration-test-stop-gatein-3">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-gatein-3.1.0" />
	</target>
	
	<!-- Run sampler deployment test for WebLogic server -->
	<target name="integration-test-test-weblogic">
		<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-${server-name}-sampler.html" />
		<pathconvert pathsep=" " property="test-weblogic" refid="html-test-files" />
		
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="http://${test.integration.server}:7001" />
			<property name="server.start.succeeded" value="1" />
			<property name="browsers" value="${test_browsers}" />
			<property name="testfiles" value="${test-weblogic}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
			
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
	
	<target name="integration-test-start-weblogic9">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-weblogic-9.2" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-weblogic-9.2-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-weblogic9">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-weblogic-9.2" />
	</target>
	
	<target name="integration-test-start-weblogic10">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} start-weblogic-10.3" />
		<copy file="integration-testscripts/sampler_deployment.tpl" tofile="integration-testscripts/integration-test-weblogic-10.3-sampler.html" overwrite="true" />
	</target>

	<target name="integration-test-stop-weblogic10">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} stop-weblogic-10.3" />
	</target>
	
	<!-- Run sampler deployment test on GAE -->
	<target name="integration-test-test-GAE">
		<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-GAE-sampler.html" />
		<pathconvert pathsep=" " property="test-GAE" refid="html-test-files" />
		
		<subant target="run-tests" failonerror="false" antfile="test.xml">
			<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
			<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
			<property name="com.vaadin.testbench.deployment.url" value="http://vaadin-integration-test.appspot.com/" />
			<property name="server.start.succeeded" value="1" />
			<property name="browsers" value="${test_browsers}" />
			<property name="testfiles" value="${test-GAE}" />
			<property name="test-output-dir" value="../build/integration-test-output" />
			
			<fileset dir="." includes="test.xml" />
		</subant>
	</target>
		
	<target name="integration-test-deploy-to-GAE">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} deploy-to-GAE" />
	</target>
			
	<!-- Server setup, test and teardown targets. -->
	<target name="integration-test-tomcat4">
		<antcall target="integration-test-start-tomcat-4"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="tomcat-4.1.40" />
		</antcall>
		<antcall target="integration-test-stop-tomcat-4"/>
	</target>
	
	<target name="integration-test-tomcat5">
		<antcall target="integration-test-start-tomcat-5"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="tomcat-5.5.28" />
		</antcall>
		<antcall target="integration-test-stop-tomcat-5"/>
	</target>	
	
	<target name="integration-test-tomcat6">
		<antcall target="integration-test-start-tomcat-6"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="tomcat-6.0.20" />
		</antcall>
		<antcall target="integration-test-stop-tomcat-6"/>
	</target>
	
	<target name="integration-test-jetty5">
		<antcall target="integration-test-start-jetty-5"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="jetty-5.1.15" />
		</antcall>
		<antcall target="integration-test-stop-jetty-5"/>
	</target>
	
	<target name="integration-test-jetty6">
		<antcall target="integration-test-start-jetty-6"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="jetty-6.1.22" />
		</antcall>
		<antcall target="integration-test-stop-jetty-6"/>
	</target>
	
	<target name="integration-test-jetty7">
		<antcall target="integration-test-start-jetty-7"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="jetty-7.0.0" />
		</antcall>
		<antcall target="integration-test-stop-jetty-7"/>
	</target>
	
	<target name="integration-test-jboss3">
		<antcall target="integration-test-start-jboss-3"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="jboss-3.2.8" />
		</antcall>
		<antcall target="integration-test-stop-jboss-3"/>
	</target>
	
	<target name="integration-test-jboss4">
		<antcall target="integration-test-start-jboss-4"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="jboss-4.2.3" />
		</antcall>
		<antcall target="integration-test-stop-jboss-4"/>
	</target>
	
	<target name="integration-test-jboss5">
		<antcall target="integration-test-start-jboss-5"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="jboss-5.0.1" />
		</antcall>
		<antcall target="integration-test-stop-jboss-5"/>
	</target>
		
	<target name="integration-test-glassfish2">
		<antcall target="integration-test-start-glassfish2"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="glassfish-2.1.1" />
		</antcall>
		<antcall target="integration-test-stop-glassfish2"/>
	</target>
	
	<target name="integration-test-glassfish3">
		<antcall target="integration-test-start-glassfish3"/>
		<antcall target="integration-test-sampler">
			<param name="server-name" value="glassfish-3" />
		</antcall>
		<antcall target="integration-test-stop-glassfish3"/>
	</target>
	
	<target name="integration-test-liferay">
		<antcall target="integration-test-start-liferay" />
		<trycatch property="tried">
			<try>
				<antcall target="integration-test-init-liferay" />
				<antcall target="integration-test-test-liferay" />
			</try>
			<catch>
				<echo message="Liferay sampler test failed. ${tried}" />
			</catch>
		</trycatch>
		<antcall target="integration-test-liferay-portlet2" />
		<antcall target="integration-test-stop-liferay" />
	</target>

	<target name="integration-test-liferay6">
		<antcall target="integration-test-start-liferay-6" />
		<antcall target="integration-test-liferay-6" />
		<antcall target="test-theme-liferay-6" />
		<antcall target="integration-test-stop-liferay-6" />
	</target>
	
	<target name="integration-test-liferay6ee">
		<antcall target="integration-test-start-liferay-6ee" />
		<antcall target="integration-test-liferay-6ee" />
		<antcall target="test-theme-liferay-6ee" />
		<antcall target="integration-test-stop-liferay-6ee" />
	</target>
	
	<target name="integration-test-gatein3">
		<antcall target="integration-test-start-gatein-3" />
		<antcall target="integration-test-gatein-3" />
		<antcall target="integration-test-stop-gatein-3" />
	</target>
	
	<target name="integration-test-weblogic9">
		<antcall target="integration-test-start-weblogic9"/>
		<antcall target="integration-test-test-weblogic">
			<param name="server-name" value="weblogic-9.2" />
		</antcall>
		<antcall target="integration-test-stop-weblogic9"/>
	</target>
	
	<target name="integration-test-weblogic10">
		<antcall target="integration-test-start-weblogic10"/>
		<antcall target="integration-test-test-weblogic">
			<param name="server-name" value="weblogic-10.3" />
		</antcall>
		<antcall target="integration-test-stop-weblogic10"/>
	</target>
	
	<target name="integration-test-GAE">
		<antcall target="integration-test-deploy-to-GAE"/>
		<antcall target="integration-test-test-GAE" />
	</target>
			
	<!-- Upload demo, clean error screenshots and test deployment on all servers -->
	<target name="integration-test-all">
		<echo message="Getting lock" />
		<antcall target="integration-test-get-lock" />
		<echo message="Got lock" />
		
		<trycatch property="tried">
			<try>
				<antcall target="integration-test-upload-demo" />
		
				<antcall target="run-integration-test">
					<param name="target-server" value="tomcat4"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="tomcat5"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="tomcat6"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="jetty5"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="jetty6"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="jetty7"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="jboss3"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="jboss4"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="jboss5"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="glassfish2"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="glassfish3"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="liferay"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="liferay6"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="liferay6ee"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="gatein3"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="weblogic9"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="weblogic10"/>
				</antcall>
				<antcall target="run-integration-test">
					<param name="target-server" value="GAE"/>
				</antcall>
			</try>
			<catch>
				<echo message="Uploading of demo.war failed. ${tried}" />
			</catch>
		</trycatch>
		
		<antcall target="integration-test-clean" />
		<echo message="Getting lock" />
		<antcall target="integration-test-release-lock" />
		<echo message="Lock released" />
	</target>
	
	<target name="run-integration-test">
		<echo message="##teamcity[testStarted name='${target-server}']" />
		<trycatch property="tried">
			<try>
				<antcall target="integration-test-${target-server}" />
			</try>
			<catch>
				<echo message="##teamcity[testFailed name='${target-server}' message='Integration test for ${target-server} failed.' details='${tried}']" />
			</catch>
		</trycatch>
		<echo message="##teamcity[testFinished name='${target-server}']" />
	</target>
	
	<target name="integration-test-get-lock">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} get-lock" />
	</target>
	
	<target name="integration-test-release-lock">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} release-lock" />
	</target>
		
	<!-- Remove demo.war -->
	<target name="integration-test-clean">
		<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} clean" />
	</target>
</project>