<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.jboss.test.richfaces-selenium</groupId>
		<artifactId>root</artifactId>
		<version>1.5.2.SP2</version>
	</parent>
	<artifactId>functional-test-template</artifactId>
	<packaging>pom</packaging>
	<name>RichFaces-Selenium: Functional Test Template</name>
	
	<properties>
		<method>*</method>
		<deployable.location />
		<deployable.type>war</deployable.type>
		<resources.dir>${project.build.directory}/test-classes</resources.dir>
		<context.host>localhost</context.host>
		<context.root>http://${context.host}:8080/</context.root>
		<context.path>/</context.path>
		<context.deploy.path>${context.path}</context.deploy.path>
		<selenium.host>localhost</selenium.host>
		<selenium.port>8444</selenium.port>
		<selenium.debug>false</selenium.debug>
		<selenium.maximize>false</selenium.maximize>
		<selenium.speed>0</selenium.speed>
		<selenium.network.traffic>false</selenium.network.traffic>
		<selenium.timeout.default>30000</selenium.timeout.default>
		<selenium.timeout.gui>5000</selenium.timeout.gui>
		<selenium.timeout.ajax>15000</selenium.timeout.ajax>
		<selenium.timeout.model>30000</selenium.timeout.model>
		<cargo.timeout.deploy>120000</cargo.timeout.deploy>
		<cargo.jvmargs.additional />
		<browserSessionReuse>true</browserSessionReuse>
	</properties>
	
	<modules>
		<module>jboss-ci</module>
	</modules>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.twdata.maven</groupId>
				<artifactId>maven-cli-plugin</artifactId>
				<version>1.0.4</version>
				<configuration>
					<userAliases>
						<selenium-only>verify -Dselenium.test.skip=true -Pwait-for-key</selenium-only>
						<tomcat6>verify -Dmaven.test.skip=true -DcontainerId=tomcat6x -Pdeploy-from-location -Pwait-for-key</tomcat6>
						<jboss5>verify -Dmaven.test.skip=true -DcontainerId=jboss5x -Pdeploy-from-location -Pwait-for-key</jboss5>
						<jboss6>verify -Dmaven.test.skip=true -DcontainerId=jboss6x -Pdeploy-from-location -Pwait-for-key</jboss6>
						<selenium-tomcat6>verify -Dselenium.test.skip=true -DcontainerId=tomcat6x -Pdeploy-from-location -Pwait-for-key</selenium-tomcat6>
						<selenium-jboss5>verify -Dselenium.test.skip=true -DcontainerId=jboss5x -Pdeploy-from-location -Pwait-for-key</selenium-jboss5>
						<selenium-jboss6>verify -Dselenium.test.skip=true -DcontainerId=jboss6x -Pdeploy-from-location -Pwait-for-key</selenium-jboss6>
						<browser>verify -Dselenium.server.skip=true</browser>
						<firefox>verify -Dbrowser=*firefox -Dselenium.server.skip=true</firefox>
						<iexplore>verify -Dbrowser=*piiexplore -Dselenium.server.skip=true</iexplore>
						<browser-debug>verify -Dselenium.server.skip=true -Pdebug-tests</browser-debug>
						<firefox-debug>verify -Dbrowser=*firefox -Dselenium.server.skip=true -Pdebug-tests</firefox-debug>
						<iexplore-debug>verify -Dbrowser=*piiexplore -Dselenium.server.skip=true -Pdebug-tests</iexplore-debug>
					</userAliases>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<!-- Functional Test -->
		<profile>
			<id>selenium-functional-test</id>
			<activation>
				<property>
					<name>!maven.test.skip</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-surefire-plugin</artifactId>
						<executions>
							<execution>
								<id>functional-test</id>
								<phase>integration-test</phase>
								<goals>
									<goal>test</goal>
								</goals>
								<configuration>
									<skip>${selenium.test.skip}</skip>
									<systemProperties>
										<property>
											<name>method</name>
											<value>${method}</value>
										</property>
										<property>
											<name>browser</name>
											<value>${browser}</value>
										</property>
										<property>
											<name>context.root</name>
											<value>${context.root}</value>
										</property>
										<property>
											<name>context.path</name>
											<value>${context.path}</value>
										</property>
										<property>
											<name>selenium.host</name>
											<value>${selenium.host}</value>
										</property>
										<property>
											<name>selenium.port</name>
											<value>${selenium.port}</value>
										</property>
										<property>
											<name>selenium.network.traffic</name>
											<value>${selenium.network.traffic}</value>
										</property>
										<property>
											<name>selenium.debug</name>
											<value>${selenium.debug}</value>
										</property>
										<property>
											<name>selenium.maximize</name>
											<value>${selenium.maximize}</value>
										</property>
										<property>
											<name>maven.resources.dir</name>
											<value>${resources.dir}</value>
										</property>
										<property>
											<name>maven.project.build.directory</name>
											<value>${project.build.directory}</value>
										</property>
										<property>
											<name>selenium.timeout.default</name>
											<value>${selenium.timeout.default}</value>
										</property>
										<property>
											<name>selenium.timeout.gui</name>
											<value>${selenium.timeout.gui}</value>
										</property>
										<property>
											<name>selenium.timeout.ajax</name>
											<value>${selenium.timeout.ajax}</value>
										</property>
										<property>
											<name>selenium.timeout.model</name>
											<value>${selenium.timeout.model}</value>
										</property>
									</systemProperties>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Selenium Session -->
		<profile>
			<id>selenium-session</id>
			<activation>
				<property>
					<name>!maven.test.skip</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>selenium-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>start-selenium-server</id>
								<phase>pre-integration-test</phase>
								<goals>
									<goal>start-server</goal>
								</goals>
								<configuration>
									<background>true</background>
									<port>${selenium.port}</port>
									<logOutput>true</logOutput>
									<logFile>${project.build.directory}/selenium/selenium-server.log</logFile>
									<browserSideLog>${selenium.debug}</browserSideLog>
									<debug>${selenium.debug}</debug>
									<skip>${selenium.server.skip}</skip>
								</configuration>
							</execution>
							<execution>
								<id>stop-selenium-server</id>
								<phase>post-integration-test</phase>
								<goals>
									<goal>stop-server</goal>
								</goals>
								<configuration>
									<background>true</background>
									<port>${selenium.port}</port>
									<skip>${selenium.server.skip}</skip>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!-- Installs Selenium Server Standalone locally to run it outside of Maven -->
		<profile>
			<id>provide-selenium-server-standalone</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-dependency-plugin</artifactId>
						<executions>
							<execution>
								<id>copy-selenium-server-standalone</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>copy</goal>
								</goals>
								<configuration>
									<artifactItems>
										<artifactItem>
											<groupId>org.seleniumhq.selenium.server</groupId>
											<artifactId>selenium-server</artifactId>
											<classifier>standalone</classifier>
											<type>jar</type>
										</artifactItem>
									</artifactItems>
									<stripVersion>true</stripVersion>
									<outputDirectory>target</outputDirectory>
									<overWriteReleases>true</overWriteReleases>
									<overWriteSnapshots>true</overWriteSnapshots>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Cargo - Generic Container Profile -->
		<profile>
			<id>container</id>
			<activation>
				<property>
					<name>containerId</name>
				</property>
			</activation>
			<properties>
				<container.dir><!-- change in custom container profiles --></container.dir>
				<container.dir.deflatted>${container.dir}</container.dir.deflatted>
				<container.dir.unflatted>${container.dir}</container.dir.unflatted>
				<container.home>${project.build.directory}/installs/${container.dir.deflatted}/${container.dir.unflatted}</container.home>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.cargo</groupId>
						<artifactId>cargo-maven2-plugin</artifactId>
						<executions>
							<execution>
								<id>install-container</id>
								<phase>generate-test-resources</phase>
								<goals>
									<goal>install</goal>
								</goals>
							</execution>
							<execution>
								<id>deploy-to-container</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>deploy</goal>
								</goals>
							</execution>
							<execution>
								<id>start-container</id>
								<phase>pre-integration-test</phase>
								<goals>
									<goal>start</goal>
								</goals>
							</execution>
							<execution>
								<id>stop-container</id>
								<phase>post-integration-test</phase>
								<goals>
									<goal>stop</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<wait>false</wait>
							<container>
								<containerId>${containerId}</containerId>
								<append>false</append>
								<timeout>${cargo.timeout.deploy}</timeout>
								<zipUrlInstaller>
									<url>${container.installer.url}</url>
									<installDir>${project.build.directory}/installs</installDir>
								</zipUrlInstaller>
							</container>
							<configuration>
								<properties>
									<cargo.hostname>${context.host}</cargo.hostname>
									<cargo.jvmargs>-Xms256m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 ${cargo.jvmargs.additional}</cargo.jvmargs>
								</properties>
							</configuration>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!-- Cargo: Deploy from Location -->
		<profile>
			<id>deploy-from-location</id>
			<activation>
				<file>
					<exists>${deployable.location}</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.cargo</groupId>
						<artifactId>cargo-maven2-plugin</artifactId>
						<configuration>
							<deployer>
								<type>installed</type>
								<deployables>
									<deployable>
										<type>${deployable.type}</type>
										<location>${deployable.location}</location>
										<properties>
											<context>${context.deploy.path}</context>
										</properties>
									</deployable>
								</deployables>
							</deployer>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!-- Container: JBoss AS 6.x -->
		<profile>
			<id>container-jboss6x</id>
			<activation>
				<property>
					<name>containerId</name>
					<value>jboss6x</value>
				</property>
			</activation>
			<properties>
				<container.short.version>6.0.0.CR1</container.short.version>
				<container.version>6.0.0.20101110-CR1</container.version>
				<container.dir.deflatted>jboss-as-distribution-${container.version}</container.dir.deflatted>
				<container.dir.unflatted>jboss-${container.version}</container.dir.unflatted>
				<container.installer.url>http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-${container.short.version}/jboss-as-distribution-${container.version}.zip</container.installer.url>
				<container.dir>jboss-${container.version}</container.dir>
				<container.configuration>default</container.configuration>
				<container.configuration.home>${container.home}/server/${container.configuration}</container.configuration.home>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.cargo</groupId>
						<artifactId>cargo-maven2-plugin</artifactId>
						<executions>
							<execution>
								<id>undeploy-container</id>
								<phase>post-integration-test</phase>
								<goals>
									<goal>undeploy</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<configuration>
								<home>${container.home}/server/${container.configuration}</home>
								<type>existing</type>
								<properties>
									<cargo.jboss.configuration>${container.configuration}</cargo.jboss.configuration>
									<cargo.rmi.port>1099</cargo.rmi.port>
								</properties>
							</configuration>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!-- Container: JBoss AS 5.x -->
		<profile>
			<id>container-jboss5x</id>
			<activation>
				<property>
					<name>containerId</name>
					<value>jboss5x</value>
				</property>
			</activation>
			<properties>
				<container.version>5.1.0.GA</container.version>
				<container.installer.url>http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-${container.version}/jboss-${container.version}.zip</container.installer.url>
				<container.dir>jboss-${container.version}</container.dir>
				<container.configuration>default</container.configuration>
				<container.configuration.home>${container.home}/server/${container.configuration}</container.configuration.home>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.cargo</groupId>
						<artifactId>cargo-maven2-plugin</artifactId>
						<executions>
							<execution>
								<id>undeploy-container</id>
								<phase>post-integration-test</phase>
								<goals>
									<goal>undeploy</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<configuration>
								<home>${container.home}/server/${container.configuration}</home>
								<type>existing</type>
								<properties>
									<cargo.jboss.configuration>${container.configuration}</cargo.jboss.configuration>
									<cargo.rmi.port>1099</cargo.rmi.port>
								</properties>
							</configuration>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!--  Container: Tomcat 6.X -->
		<profile>
			<id>container-tomcat6x</id>
			<activation>
				<property>
					<name>containerId</name>
					<value>tomcat6x</value>
				</property>
			</activation>
			<properties>
				<container.version>6.0.29</container.version>
				<container.installer.url>http://www.apache.org/dist/tomcat/tomcat-6/v${container.version}/bin/apache-tomcat-${container.version}.zip</container.installer.url>
				<container.dir>apache-tomcat-${container.version}</container.dir>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.cargo</groupId>
						<artifactId>cargo-maven2-plugin</artifactId>
						<configuration>
							<configuration>
								<home>${container.home}</home>
								<type>existing</type>
							</configuration>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<profile>
			<id>debug-tests</id>
			<activation>
				<property>
					<name>maven.test.debug</name>
					<value>true</value>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<debugForkedProcess>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE</debugForkedProcess>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!--  -->
		<profile>
			<id>wait-for-key</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>press-key-to-shutdown-server</id>
								<phase>integration-test</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<input>Press key for shutdown server...</input>
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
	
	<dependencies>
		<dependency>
			<groupId>org.testng</groupId>
			<artifactId>testng</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium.client-drivers</groupId>
			<artifactId>selenium-java-client-driver</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium.server</groupId>
			<artifactId>selenium-server-coreless</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>jetty</groupId>
					<artifactId>org.mortbay.jetty</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.jboss.test</groupId>
			<artifactId>richfaces-selenium</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
</project>
