<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/xsd/maven-4.0.0.xsd">
	<parent>
		<artifactId>org.cumulus4j.parent</artifactId>
		<groupId>org.cumulus4j</groupId>
		<version>1.2.1-SNAPSHOT</version>
		<relativePath>../org.cumulus4j.parent/pom.xml</relativePath>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<artifactId>org.cumulus4j.integrationtest.webapp</artifactId>
	<packaging>war</packaging>

	<name>org.cumulus4j.integrationtest.webapp</name>
	<description>Web-app providing a dummy-service that uses DataNucleus+Cumulus4j for persisting dummy-data. It integrates the keyserver-backend in order to test the whole system. The tests in this project use a client-sided embedded key manager and local key store (in the local file system).</description>

	<dependencies>
		<dependency>
			<groupId>javax.jdo</groupId>
			<artifactId>jdo-api</artifactId>
			<!-- We have this dependency declared as 'provided' in the parent (which is IMHO correct), but need to package it here. -->
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>com.sun.jersey</groupId>
			<artifactId>jersey-client</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.sun.jersey</groupId>
			<artifactId>jersey-server</artifactId>
		</dependency>
		<dependency>
			<groupId>org.datanucleus</groupId>
			<artifactId>datanucleus-rdbms</artifactId>
		</dependency>
		<dependency>
			<groupId>org.cumulus4j</groupId>
			<artifactId>org.cumulus4j.testutil</artifactId>
		</dependency>
		<dependency>
			<groupId>org.cumulus4j</groupId>
			<artifactId>org.cumulus4j.keymanager</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.cumulus4j</groupId>
			<artifactId>org.cumulus4j.keymanager.api</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.cumulus4j</groupId>
			<artifactId>org.cumulus4j.store</artifactId>
		</dependency>
		<dependency>
			<groupId>org.cumulus4j</groupId>
			<artifactId>org.cumulus4j.store.crypto.keymanager</artifactId>
		</dependency>
		<dependency>
			<groupId>org.cumulus4j</groupId>
			<artifactId>org.cumulus4j.store.test</artifactId>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.derby</groupId>
			<artifactId>derby</artifactId>
			<scope>compile</scope>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<!--
			We put the jetty-plugin into this separate profile in order to ensure that it is NOT started, when tests are skipped. Starting jetty is very slow
			and should only happen when it is really needed! Marco :-)
			-->
			<id>test</id>
			<activation>
				<property>
					<name>maven.test.skip</name>
					<value>!true</value>
				</property>
			</activation>
			
			<build>
				<plugins>
					<plugin>
						<groupId>org.mortbay.jetty</groupId>
						<artifactId>jetty-maven-plugin</artifactId>
						<configuration>
							<!-- <scanIntervalSeconds>10</scanIntervalSeconds> -->
							<stopKey>stop.${project.artifactId}</stopKey>
							<stopPort>9995</stopPort>
							<webAppConfig>
								<contextPath>/${project.artifactId}</contextPath>
								<!--
									The following extraClasspath configures log4j and binds slf4j 
									to log4j so that we have logging when running 'mvn jetty:run'. The WAR itself 
									does NOT contain this binding and will thus fall-back to NO-OP logging (i.e. 
									disable logging) with a warning. The log4j.properties is located in /src/test/java 
									in order to not be packaged into the WAR so that the logging can be configured 
									without any unexpected interference by the servlet container.
		
									Even though this is only a test project, we do not package these libs into the WAR, because 
									it may happen that someone copies this configuration for a productive project. 
									Additionally, this way, all our web-app-projects have (more or less) the 
									same configuration.
								-->
								<extraClasspath>${basedir}/src/test/java;${settings.localRepository}/org/slf4j/slf4j-log4j12/${slf4j.version}/slf4j-log4j12-${slf4j.version}.jar;${settings.localRepository}/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar</extraClasspath>
							</webAppConfig>
							<connectors>
								<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
									<port>8585</port>
									<maxIdleTime>60000</maxIdleTime>
								</connector>
							</connectors>
							<systemProperties>
								<systemProperty>
									<name>cumulus4j.MessageBrokerPMF.persistenceProperties.javax.jdo.option.ConnectionDriverName</name>
									<value>org.apache.derby.jdbc.EmbeddedDriver</value>
								</systemProperty>
								<systemProperty>
									<name>cumulus4j.MessageBrokerPMF.persistenceProperties.javax.jdo.option.ConnectionURL</name>
									<value>jdbc:derby:${basedir}/target/derby/messagebroker;create=true</value>
								</systemProperty>
							</systemProperties>
						</configuration>
						<executions>
							<execution>
								<id>start-jetty</id>
								<phase>pre-integration-test</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<scanIntervalSeconds>0</scanIntervalSeconds>
									<daemon>true</daemon>
								</configuration>
							</execution>
		<!--
			We do not stop jetty, because we want multiple servers to run at the same time.
			Unfortunately, it seems to be impossible to configure multiple instances of the
			jetty-maven-plugin in the same pom.xml. Thus, we now launch a jetty in multiple
			projects and therefore cannot stop them here. Due to the "daemon=true", it should
			be stopped when the build is done.
							<execution>
								<id>stop-jetty</id>
								<phase>post-integration-test</phase>
								<goals>
									<goal>stop</goal>
								</goals>
							</execution>
		-->
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

	<build>
		<plugins>
			<plugin>
				<!--
				We exclude all tests here, because all the tests in this module are INTEGRATION tests which should
				be executed only when running "mvn integration-test"
				-->
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/*</exclude>
                    </excludes>
                </configuration>
            </plugin>

			<plugin>
				<artifactId>maven-failsafe-plugin</artifactId>
				<configuration>
					<includes>
						<include>**/Test*.java</include>
						<include>**/*Test.java</include>
						<include>**/IT*.java</include>
						<include>**/*IT.java</include>
					</includes>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>integration-test</goal>
<!--
We comment this out, because we don't want to fail the build, if the integration test fails. We want it
in the reports just like every other test, too. Marco :-)
							<goal>verify</goal>
-->
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
