<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">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>itests</artifactId>
  <packaging>jar</packaging>
  <name>Forge &amp; Illusion - itests</name>
  <description>Forge &amp; Illusion - Integration tests</description>
  <parent>
    <groupId>fi.foyt.fni</groupId>
    <artifactId>parent</artifactId>
    <version>3.2.23</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  
  <properties>
    <!-- Selenium -->

    <selenium-java.version>2.43.0</selenium-java.version>
    
    <!-- GreenMail -->
    
    <greenmail.version>1.3.1b</greenmail.version>
    
    <!-- REST Assured -->
    
    <restassured.version>2.4.0</restassured.version>  
    
    <!-- WireMock -->
    
    <wiremock.version>1.55</wiremock.version>
    
  </properties>

  <dependencies>
    <!-- WebApp -->
    
    <dependency>
      <groupId>fi.foyt.fni</groupId>
      <artifactId>webapp</artifactId>
      <type>war</type>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>fi.foyt.fni</groupId>
      <artifactId>rest-model</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>fi.foyt.fni</groupId>
      <artifactId>larp-kalenteri-rest-model</artifactId>
      <scope>test</scope>
    </dependency>
    
    <!-- Mail -->
    
    <dependency>
      <groupId>com.sun.mail</groupId>
      <artifactId>javax.mail</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Jackson -->

    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-joda</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Apache Oltu -->
    
    <dependency>
      <groupId>org.apache.oltu.oauth2</groupId>
      <artifactId>org.apache.oltu.oauth2.client</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.oltu.oauth2</groupId>
      <artifactId>org.apache.oltu.oauth2.authzserver</artifactId>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>org.apache.oltu.oauth2</groupId>
      <artifactId>org.apache.oltu.oauth2.resourceserver</artifactId>
      <scope>test</scope>
    </dependency>
        
    <!-- Test -->
    
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <scope>test</scope>
      <version>${selenium-java.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>httpclient</artifactId>
          <groupId>org.apache.httpcomponents</groupId>
        </exclusion>
        <exclusion>
          <artifactId>httpmime</artifactId>
          <groupId>org.apache.httpcomponents</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>com.saucelabs</groupId>
      <artifactId>sauce_junit</artifactId>
      <version>2.1.18</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>httpclient</artifactId>
          <groupId>org.apache.httpcomponents</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>com.icegreen</groupId>
      <artifactId>greenmail</artifactId>
      <scope>test</scope>
      <version>${greenmail.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>javax.mail</groupId>
          <artifactId>mail</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
     
    <dependency>
      <groupId>com.jayway.restassured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
      <version>${restassured.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>httpclient</artifactId>
          <groupId>org.apache.httpcomponents</groupId>
        </exclusion>
        <exclusion>
          <artifactId>httpmime</artifactId>
          <groupId>org.apache.httpcomponents</groupId>
        </exclusion>
      </exclusions>
    </dependency>    

    <dependency>
      <groupId>com.github.tomakehurst</groupId>
      <artifactId>wiremock</artifactId>
      <version>${wiremock.version}</version>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <artifactId>httpclient</artifactId>
      <groupId>org.apache.httpcomponents</groupId>
      <version>4.3.1</version>
    </dependency>
    
    <dependency>
      <artifactId>httpmime</artifactId>
      <groupId>org.apache.httpcomponents</groupId>
      <version>4.3.1</version>
    </dependency>
    
    <dependency>
      <artifactId>httpcore</artifactId>
      <groupId>org.apache.httpcomponents</groupId>
      <version>4.3.1</version>
    </dependency>
    
  </dependencies>
  
  <profiles>
    <profile>
      <id>rest</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      
      <properties>
        <wildfly.home>${project.basedir}/.cargo/extracts/wildfly-8.1.0.Final/wildfly-8.1.0.Final</wildfly.home>
        <wildfly.version>8.1.0.Final</wildfly.version>
        <h2.version>1.4.177</h2.version>
        <it.port.http>8080</it.port.http>
        <it.port.https>8443</it.port.https>
        <it.smtp.port>3025</it.smtp.port>
        <it.host>test.forgeandillusion.net</it.host>
        <it.ctx>fnici</it.ctx>
        <it.jdbc.driver>org.h2.Driver</it.jdbc.driver>
        <it.jdbc.url>jdbc:h2:file:${project.build.directory}/h2;AUTO_SERVER=TRUE</it.jdbc.url>
        <it.jdbc.jndi>java:/jboss/datasources/fni</it.jdbc.jndi>
        <it.jdbc.username>sa</it.jdbc.username>
        <it.jdbc.password>sa</it.jdbc.password>
        <it.hibernate.dialect>org.hibernate.dialect.H2Dialect</it.hibernate.dialect>
        <it.keystore>${project.build.directory}/fnici.keystore</it.keystore>
        <it.truststore>${project.build.directory}/fnici.truststore</it.truststore>
        <it.keystorepass>keystorepass</it.keystorepass>
        <it.truststorepass>truststorepass</it.truststorepass>
      </properties>
      
      <dependencies>
        <dependency>
          <groupId>com.h2database</groupId>
          <artifactId>h2</artifactId>
          <version>${h2.version}</version>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>fi.foyt.fni</groupId>
          <artifactId>persistence</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
      
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
              <systemPropertyVariables>
                <jboss.home>${wildfly.home}</jboss.home>
                <module.path>${wildfly.home}/modules</module.path>
              </systemPropertyVariables>
            </configuration>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <executions>
              <execution>
                <phase>initialize</phase>
                <goals>
                  <goal>read-project-properties</goal>
                </goals>
                <configuration>
                  <files>
                    <file>src/test/resources/it.properties</file>
                  </files>
                </configuration>
              </execution>
            </executions>
          </plugin>
    
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.16</version>
            <configuration>
              <includes>
                <include>fi/foyt/fni/test/rest/**/*IT.java</include>
              </includes>
              <systemPropertyVariables>
                <javax.net.ssl.keyStore>${it.keystore}</javax.net.ssl.keyStore>
                <javax.net.ssl.keyStorePassword>${it.keystorepass}</javax.net.ssl.keyStorePassword>
                <javax.net.ssl.trustStore>${it.truststore}</javax.net.ssl.trustStore>
                <javax.net.ssl.trustStorePassword>${it.truststorepass}</javax.net.ssl.trustStorePassword>
                <jboss.home>${wildfly.home}</jboss.home>
                <module.path>${wildfly.home}/modules</module.path>
                <it.project.version>${project.version}</it.project.version>
                <it.host>${it.host}</it.host>
                <it.port.http>${it.port.http}</it.port.http>
                <it.port.https>${it.port.https}</it.port.https>
                <it.smtp.port>${it.smtp.port}</it.smtp.port>
                <it.ctx>${it.ctx}</it.ctx>
                <it.jdbc.driver>${it.jdbc.driver}</it.jdbc.driver>
                <it.jdbc.url>${it.jdbc.url}</it.jdbc.url>
                <it.jdbc.jndi>${it.jdbc.jndi}</it.jdbc.jndi>
                <it.jdbc.username>${it.jdbc.username}</it.jdbc.username>
                <it.jdbc.password>${it.jdbc.password}</it.jdbc.password>
                <it.google.apiKey>${it.google.apiKey}</it.google.apiKey>
                <it.google.apiSecret>${it.google.apiSecret}</it.google.apiSecret>
                <it.google.username>${it.google.username}</it.google.username>
                <it.google.password>${it.google.password}</it.google.password>
                <it.facebook.apiKey>${it.facebook.apiKey}</it.facebook.apiKey>
                <it.facebook.apiSecret>${it.facebook.apiSecret}</it.facebook.apiSecret>
                <it.facebook.username>${it.facebook.username}</it.facebook.username>
                <it.facebook.password>${it.facebook.password}</it.facebook.password>
                <it.dropbox.apiKey>${it.dropbox.apiKey}</it.dropbox.apiKey>
                <it.dropbox.apiSecret>${it.dropbox.apiSecret}</it.dropbox.apiSecret>
                <it.dropbox.username>${it.dropbox.username}</it.dropbox.username>
                <it.dropbox.password>${it.dropbox.password}</it.dropbox.password>
              </systemPropertyVariables>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
              <execution>
                <id>verify</id>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>de.juplo</groupId>
            <artifactId>hibernate4-maven-plugin</artifactId>
            <version>1.0.5</version>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
              </dependency>
            </dependencies>
            <configuration>
              <driverClassName>${it.jdbc.driver}</driverClassName>
              <hibernateDialect>${it.hibernate.dialect}</hibernateDialect> 
              <url><![CDATA[${it.jdbc.url}]]></url>
              <username>${it.jdbc.username}</username>
              <password>${it.jdbc.password}</password>
            </configuration>
            <executions>
              <execution> 
                <id>create-schema</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>export</goal>
                </goals>
                <configuration>
                  <type>CREATE</type>
                </configuration>
              </execution>
              
              <execution> 
                <id>drop-db-after-test</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>export</goal>
                </goals>
                <configuration>
                  <type>DROP</type>
                  <force>true</force>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sql-maven-plugin</artifactId>
            <version>1.5</version>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
              </dependency>
            </dependencies>
    
            <configuration>      
              <driver>${it.jdbc.driver}</driver>
              <url>${it.jdbc.url}</url>
              <username>${it.jdbc.username}</username>
              <password>${it.jdbc.password}</password>
            </configuration>
            <executions>
              <execution>
                <id>basic-sql-setup</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <autocommit>true</autocommit>
                  <srcFiles>
                    <srcFile>src/test/resources/basic-setup.sql</srcFile>
                  </srcFiles>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>keytool-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
              <execution>
                <phase>generate-resources</phase>
                <id>keystoreclean</id>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>truststoreclean</id>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <keystore>${it.truststore}</keystore>
                </configuration>
              </execution>
              <execution> 
                <phase>generate-resources</phase>
                <id>genkey</id>
                <goals>
                  <goal>generateKeyPair</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <dname>cn=${it.host}, ou=None, L=Test, ST=Test, o=Test, c=TE</dname>
                  <storepass>${it.keystorepass}</storepass>
                  <alias>${it.host}</alias>
                  <keyalg>RSA</keyalg>
                  <keysize>2048</keysize>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>exportkey</id>
                <goals>
                  <goal>exportCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <alias>${it.host}</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.keystorepass}</storepass>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-keystore</id>
                <goals>
                  <goal>importCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <alias>root</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.keystorepass}</storepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-truststore</id>
                <goals>
                  <goal>importCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.truststore}</keystore>
                  <alias>${it.host}</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.truststorepass}</storepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-jre-truststore</id>
                <goals>
                  <goal>importKeystore</goal>
                </goals>
                <configuration>
                  <srckeystore>${java.home}/lib/security/cacerts</srckeystore>
                  <srcstorepass>changeit</srcstorepass>
                  <destkeystore>${it.truststore}</destkeystore>
                  <deststorepass>${it.truststorepass}</deststorepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.4.8</version>
            <configuration>
              <container>
                <containerId>wildfly8x</containerId>
                <log>${project.basedir}/target/cargo.log</log>
                <output>${project.basedir}/target/wildfly.log</output>
                <zipUrlInstaller>
                  <url>http://download.jboss.org/wildfly/8.1.0.Final/wildfly-8.1.0.Final.zip</url>
                  <downloadDir>${project.basedir}/.cargo/downloads</downloadDir>
                  <extractDir>${project.basedir}/.cargo/extracts</extractDir>
                </zipUrlInstaller>
                <dependencies>
                  <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                  </dependency>
                </dependencies>
                <systemProperties>
                  <javax.net.ssl.keyStore>${it.keystore}</javax.net.ssl.keyStore>
                  <javax.net.ssl.keyStorePassword>${it.keystorepass}</javax.net.ssl.keyStorePassword>
                  <javax.net.ssl.trustStore>${it.truststore}</javax.net.ssl.trustStore>
                  <javax.net.ssl.trustStorePassword>${it.truststorepass}</javax.net.ssl.trustStorePassword>
                </systemProperties>                
              </container>
              <configuration>
                <properties>
                  <cargo.servlet.port>${it.port.http}</cargo.servlet.port>
                  <cargo.jboss.configuration>standalone</cargo.jboss.configuration>
                  <cargo.jvmargs>-Xms64m -Xmx1152m -XX:MaxPermSize=512m</cargo.jvmargs>
                  <cargo.datasource.datasource.fnici>
                    cargo.datasource.driver=${it.jdbc.driver}|
                    cargo.datasource.url=${it.jdbc.url}|
                    cargo.datasource.jndi=${it.jdbc.jndi}|
                    cargo.datasource.username=${it.jdbc.username}|
                    cargo.datasource.password=${it.jdbc.password}|
                    cargo.datasource.transactionsupport=LOCAL_TRANSACTION
                  </cargo.datasource.datasource.fnici>
                </properties>    
              </configuration>

              <deployables>
                <deployable>
                  <groupId>fi.foyt.fni</groupId>
                  <artifactId>webapp</artifactId>
                  <type>war</type>
                  <properties>
                    <context>${it.ctx}</context>
                  </properties>
                </deployable>
              </deployables>

            </configuration>
            <executions>
              <execution>
                <id>start-cargo</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
              </execution>
              <execution>
                <id>stop-cargo</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.1.Final</version>
            <executions>
              <execution>
                <id>configure-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute-commands</goal>
                </goals>
                <configuration>
                  <execute-commands>
                    <batch>true</batch>
                    <commands>
                      <command>/system-property=fni-google-drive.keyFile:add(value="${it.googleDrive.keyFile}")</command>
                      <command>/system-property=fni-google-drive.accountId:add(value="${it.googleDrive.accountId}")</command>
                      <command>/system-property=fni-google-drive.accountUser:add(value="${it.googleDrive.accountUser}")</command>
                      <command>/system-property=fni-host:add(value="${it.host}")</command>
                      <command>/system-property=fni-http-port:add(value="${it.port.http}")</command>
                      <command>/system-property=fni-https-port:add(value="${it.port.https}")</command>
                      <command>/core-service=management/security-realm=ssl-realm:add()</command>
                      <command>/core-service=management/security-realm=ssl-realm/server-identity=ssl:add(keystore-path="${it.keystore}",keystore-password="${it.keystorepass}",alias="${it.host}")</command>
                      <command>/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding="https",security-realm="ssl-realm")</command>
                      <command>/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp/:write-attribute(name=port,value=${it.smtp.port})</command>
                    </commands>
                  </execute-commands>
                </configuration>
              </execution>
              
              <execution>
                <id>reload-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute-commands</goal>
                </goals>
                <configuration>
                  <execute-commands>
                    <commands>
                      <command>:reload</command>
                    </commands>
                  </execute-commands>
                </configuration>
              </execution>
            </executions>
          </plugin>
                    
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>wait-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
              <execution>
                <id>wait</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>wait</goal>
                </goals>      
                <configuration>
                  <protocol>http</protocol>
                  <host>${it.host}</host>
                  <port>${it.port.http}</port>
                  <file>/${it.ctx}/rest/system/ping</file>
                  <maxcount>20</maxcount>
                  <timeout>10000</timeout>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    
    <profile>
      <id>ui</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      
      <properties>
        <wildfly.home>${project.basedir}/.cargo/extracts/wildfly-8.1.0.Final/wildfly-8.1.0.Final</wildfly.home>
        <wildfly.version>8.1.0.Final</wildfly.version>
        <h2.version>1.4.177</h2.version>
        <it.port.http>8080</it.port.http>
        <it.port.https>8443</it.port.https>
        <it.smtp.port>3025</it.smtp.port>
        <it.host>test.forgeandillusion.net</it.host>
        <it.ctx>fnici</it.ctx>
        <it.jdbc.driver>org.h2.Driver</it.jdbc.driver>
        <it.jdbc.url>jdbc:h2:file:${project.build.directory}/h2;AUTO_SERVER=TRUE</it.jdbc.url>
        <it.jdbc.jndi>java:/jboss/datasources/fni</it.jdbc.jndi>
        <it.jdbc.username>sa</it.jdbc.username>
        <it.jdbc.password>sa</it.jdbc.password>
        <it.hibernate.dialect>org.hibernate.dialect.H2Dialect</it.hibernate.dialect>
        <it.keystore>${project.build.directory}/fnici.keystore</it.keystore>
        <it.truststore>${project.build.directory}/fnici.truststore</it.truststore>
        <it.keystorepass>keystorepass</it.keystorepass>
        <it.truststorepass>truststorepass</it.truststorepass>
      </properties>
      
      <dependencies>
        <dependency>
          <groupId>com.h2database</groupId>
          <artifactId>h2</artifactId>
          <version>${h2.version}</version>
          <scope>test</scope>
        </dependency>   

        <dependency>
          <groupId>fi.foyt.fni</groupId>
          <artifactId>persistence</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
      
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
              <systemPropertyVariables>
                <jboss.home>${wildfly.home}</jboss.home>
                <module.path>${wildfly.home}/modules</module.path>
              </systemPropertyVariables>
            </configuration>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <executions>
              <execution>
                <phase>initialize</phase>
                <goals>
                  <goal>read-project-properties</goal>
                </goals>
                <configuration>
                  <files>
                    <file>src/test/resources/it.properties</file>
                  </files>
                </configuration>
              </execution>
            </executions>
          </plugin>
    
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.16</version>
            <configuration>
              <includes>
                <include>fi/foyt/fni/test/ui/chrome/**/*IT.java</include>
              </includes>
              <systemPropertyVariables>
                <jboss.home>${wildfly.home}</jboss.home>
                <module.path>${wildfly.home}/modules</module.path>
                <it.project.version>${project.version}</it.project.version>
                <it.host>${it.host}</it.host>
                <it.port.http>${it.port.http}</it.port.http>
                <it.port.https>${it.port.https}</it.port.https>
                <it.smtp.port>${it.smtp.port}</it.smtp.port>
                <it.ctx>${it.ctx}</it.ctx>
                <it.jdbc.driver>${it.jdbc.driver}</it.jdbc.driver>
                <it.jdbc.url>${it.jdbc.url}</it.jdbc.url>
                <it.jdbc.jndi>${it.jdbc.jndi}</it.jdbc.jndi>
                <it.jdbc.username>${it.jdbc.username}</it.jdbc.username>
                <it.jdbc.password>${it.jdbc.password}</it.jdbc.password>
                <it.google.apiKey>${it.google.apiKey}</it.google.apiKey>
                <it.google.apiSecret>${it.google.apiSecret}</it.google.apiSecret>
                <it.google.username>${it.google.username}</it.google.username>
                <it.google.password>${it.google.password}</it.google.password>
                <it.facebook.apiKey>${it.facebook.apiKey}</it.facebook.apiKey>
                <it.facebook.apiSecret>${it.facebook.apiSecret}</it.facebook.apiSecret>
                <it.facebook.username>${it.facebook.username}</it.facebook.username>
                <it.facebook.password>${it.facebook.password}</it.facebook.password>
                <it.dropbox.apiKey>${it.dropbox.apiKey}</it.dropbox.apiKey>
                <it.dropbox.apiSecret>${it.dropbox.apiSecret}</it.dropbox.apiSecret>
                <it.dropbox.username>${it.dropbox.username}</it.dropbox.username>
                <it.dropbox.password>${it.dropbox.password}</it.dropbox.password>
              </systemPropertyVariables>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
              <execution>
                <id>verify</id>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>de.juplo</groupId>
            <artifactId>hibernate4-maven-plugin</artifactId>
            <version>1.0.5</version>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
              </dependency>
            </dependencies>
            <configuration>
              <driverClassName>${it.jdbc.driver}</driverClassName>
              <hibernateDialect>${it.hibernate.dialect}</hibernateDialect> 
              <url><![CDATA[${it.jdbc.url}]]></url>
              <username>${it.jdbc.username}</username>
              <password>${it.jdbc.password}</password>
            </configuration>
            <executions>
              <execution> 
                <id>create-schema</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>export</goal>
                </goals>
                <configuration>
                  <type>CREATE</type>
                </configuration>
              </execution>
              
              <execution> 
                <id>drop-db-after-test</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>export</goal>
                </goals>
                <configuration>
                  <type>DROP</type>
                  <force>true</force>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sql-maven-plugin</artifactId>
            <version>1.5</version>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
              </dependency>
            </dependencies>
    
            <configuration>      
              <driver>${it.jdbc.driver}</driver>
              <url>${it.jdbc.url}</url>
              <username>${it.jdbc.username}</username>
              <password>${it.jdbc.password}</password>
            </configuration>
            <executions>
              <execution>
                <id>basic-sql-setup</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <autocommit>true</autocommit>
                  <srcFiles>
                    <srcFile>src/test/resources/basic-setup.sql</srcFile>
                  </srcFiles>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>keytool-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
              <execution>
                <phase>generate-resources</phase>
                <id>keystoreclean</id>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>truststoreclean</id>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <keystore>${it.truststore}</keystore>
                </configuration>
              </execution>
              <execution> 
                <phase>generate-resources</phase>
                <id>genkey</id>
                <goals>
                  <goal>generateKeyPair</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <dname>cn=${it.host}, ou=None, L=Test, ST=Test, o=Test, c=TE</dname>
                  <storepass>${it.keystorepass}</storepass>
                  <alias>${it.host}</alias>
                  <keyalg>RSA</keyalg>
                  <keysize>2048</keysize>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>exportkey</id>
                <goals>
                  <goal>exportCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <alias>${it.host}</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.keystorepass}</storepass>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-keystore</id>
                <goals>
                  <goal>importCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <alias>root</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.keystorepass}</storepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-truststore</id>
                <goals>
                  <goal>importCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.truststore}</keystore>
                  <alias>${it.host}</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.truststorepass}</storepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-jre-truststore</id>
                <goals>
                  <goal>importKeystore</goal>
                </goals>
                <configuration>
                  <srckeystore>${java.home}/lib/security/cacerts</srckeystore>
                  <srcstorepass>changeit</srcstorepass>
                  <destkeystore>${it.truststore}</destkeystore>
                  <deststorepass>${it.truststorepass}</deststorepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.4.8</version>
            <configuration>
              <container>
                <containerId>wildfly8x</containerId>
                <log>${project.basedir}/target/cargo.log</log>
                <output>${project.basedir}/target/wildfly.log</output>
                <zipUrlInstaller>
                  <url>http://download.jboss.org/wildfly/8.1.0.Final/wildfly-8.1.0.Final.zip</url>
                  <downloadDir>${project.basedir}/.cargo/downloads</downloadDir>
                  <extractDir>${project.basedir}/.cargo/extracts</extractDir>
                </zipUrlInstaller>
                <dependencies>
                  <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                  </dependency>
                </dependencies>
                <systemProperties>
                  <javax.net.ssl.keyStore>${it.keystore}</javax.net.ssl.keyStore>
                  <javax.net.ssl.keyStorePassword>${it.keystorepass}</javax.net.ssl.keyStorePassword>
                  <javax.net.ssl.trustStore>${it.truststore}</javax.net.ssl.trustStore>
                  <javax.net.ssl.trustStorePassword>${it.truststorepass}</javax.net.ssl.trustStorePassword>
                </systemProperties>                
              </container>
              <configuration>
                <properties>
                  <cargo.servlet.port>${it.port.http}</cargo.servlet.port>
                  <cargo.jboss.configuration>standalone</cargo.jboss.configuration>
                  <cargo.jvmargs>-Xms64m -Xmx1152m -XX:MaxPermSize=512m</cargo.jvmargs>
                  <cargo.datasource.datasource.fnici>
                    cargo.datasource.driver=${it.jdbc.driver}|
                    cargo.datasource.url=${it.jdbc.url}|
                    cargo.datasource.jndi=${it.jdbc.jndi}|
                    cargo.datasource.username=${it.jdbc.username}|
                    cargo.datasource.password=${it.jdbc.password}|
                    cargo.datasource.transactionsupport=LOCAL_TRANSACTION
                  </cargo.datasource.datasource.fnici>
                </properties>    
              </configuration>

              <deployables>
                <deployable>
                  <groupId>fi.foyt.fni</groupId>
                  <artifactId>webapp</artifactId>
                  <type>war</type>
                  <properties>
                    <context>${it.ctx}</context>
                  </properties>
                </deployable>
              </deployables>

            </configuration>
            <executions>
              <execution>
                <id>start-cargo</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
              </execution>
              <execution>
                <id>stop-cargo</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.1.Final</version>
            <executions>
              <execution>
                <id>configure-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute-commands</goal>
                </goals>
                <configuration>
                  <execute-commands>
                    <batch>true</batch>
                    <commands>
                      <command>/system-property=fni-google-drive.keyFile:add(value="${it.googleDrive.keyFile}")</command>
                      <command>/system-property=fni-google-drive.accountId:add(value="${it.googleDrive.accountId}")</command>
                      <command>/system-property=fni-google-drive.accountUser:add(value="${it.googleDrive.accountUser}")</command>
                      <command>/system-property=fni-host:add(value="${it.host}")</command>
                      <command>/system-property=fni-http-port:add(value="${it.port.http}")</command>
                      <command>/system-property=fni-https-port:add(value="${it.port.https}")</command>
                      <command>/core-service=management/security-realm=ssl-realm:add()</command>
                      <command>/core-service=management/security-realm=ssl-realm/server-identity=ssl:add(keystore-path="${it.keystore}",keystore-password="${it.keystorepass}",alias="${it.host}")</command>
                      <command>/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding="https",security-realm="ssl-realm")</command>
                      <command>/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp/:write-attribute(name=port,value=${it.smtp.port})</command>
                    </commands>
                  </execute-commands>
                </configuration>
              </execution>
              
              <execution>
                <id>reload-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute-commands</goal>
                </goals>
                <configuration>
                  <execute-commands>
                    <commands>
                      <command>:reload</command>
                    </commands>
                  </execute-commands>
                </configuration>
              </execution>
            </executions>
          </plugin>
                    
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>wait-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
              <execution>
                <id>wait</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>wait</goal>
                </goals>      
                <configuration>
                  <protocol>http</protocol>
                  <host>${it.host}</host>
                  <port>${it.port.http}</port>
                  <file>/${it.ctx}</file>
                  <maxcount>20</maxcount>
                  <timeout>10000</timeout>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>sauce</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      
      <properties>
        <wildfly.home>${project.basedir}/.cargo/extracts/wildfly-8.1.0.Final/wildfly-8.1.0.Final</wildfly.home>
        <wildfly.version>8.1.0.Final</wildfly.version>
        <h2.version>1.4.177</h2.version>
        <it.port.http>8080</it.port.http>
        <it.port.https>8443</it.port.https>
        <it.host>test.forgeandillusion.net</it.host>
        <it.ctx>fnici</it.ctx>
        <it.smtp.port>3025</it.smtp.port>
        <it.jdbc.driver>org.h2.Driver</it.jdbc.driver>
        <it.jdbc.url>jdbc:h2:file:${project.build.directory}/h2;AUTO_SERVER=TRUE</it.jdbc.url>
        <it.jdbc.jndi>java:/jboss/datasources/fni</it.jdbc.jndi>
        <it.jdbc.username>sa</it.jdbc.username>
        <it.jdbc.password>sa</it.jdbc.password>
        <it.hibernate.dialect>org.hibernate.dialect.H2Dialect</it.hibernate.dialect>
        <it.keystore>${project.build.directory}/fnici.keystore</it.keystore>
        <it.truststore>${project.build.directory}/fnici.truststore</it.truststore>
        <it.keystorepass>keystorepass</it.keystorepass>
        <it.truststorepass>truststorepass</it.truststorepass>
      </properties>
      
      <dependencies>
        <dependency>
          <groupId>com.h2database</groupId>
          <artifactId>h2</artifactId>
          <version>${h2.version}</version>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>fi.foyt.fni</groupId>
          <artifactId>persistence</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
              <systemPropertyVariables>
                <jboss.home>${wildfly.home}</jboss.home>
                <module.path>${wildfly.home}/modules</module.path>
              </systemPropertyVariables>
            </configuration>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <executions>
              <execution>
                <phase>initialize</phase>
                <goals>
                  <goal>read-project-properties</goal>
                </goals>
                <configuration>
                  
                  <files>
                    <file>src/test/resources/it.properties</file>
                  </files>
                </configuration>
              </execution>
            </executions>
          </plugin>
    
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.16</version>
            <configuration>
              <includes>
                <include>fi/foyt/fni/test/ui/sauce/**/*IT.java</include>
              </includes>
              <systemPropertyVariables>
                <jboss.home>${wildfly.home}</jboss.home>
                <module.path>${wildfly.home}/modules</module.path>
                <it.project.version>${project.version}</it.project.version>
                <it.host>${it.host}</it.host>
                <it.port.http>${it.port.http}</it.port.http>
                <it.port.https>${it.port.https}</it.port.https>
                <it.ctx>${it.ctx}</it.ctx>
                <it.smtp.port>${it.smtp.port}</it.smtp.port>
                <it.jdbc.driver>${it.jdbc.driver}</it.jdbc.driver>
                <it.jdbc.url>${it.jdbc.url}</it.jdbc.url>
                <it.jdbc.jndi>${it.jdbc.jndi}</it.jdbc.jndi>
                <it.jdbc.username>${it.jdbc.username}</it.jdbc.username>
                <it.jdbc.password>${it.jdbc.password}</it.jdbc.password>
                <it.google.apiKey>${it.google.apiKey}</it.google.apiKey>
                <it.google.apiSecret>${it.google.apiSecret}</it.google.apiSecret>
                <it.google.username>${it.google.username}</it.google.username>
                <it.google.password>${it.google.password}</it.google.password>
                <it.facebook.apiKey>${it.facebook.apiKey}</it.facebook.apiKey>
                <it.facebook.apiSecret>${it.facebook.apiSecret}</it.facebook.apiSecret>
                <it.facebook.username>${it.facebook.username}</it.facebook.username>
                <it.facebook.password>${it.facebook.password}</it.facebook.password>
                <it.dropbox.apiKey>${it.dropbox.apiKey}</it.dropbox.apiKey>
                <it.dropbox.apiSecret>${it.dropbox.apiSecret}</it.dropbox.apiSecret>
                <it.dropbox.username>${it.dropbox.username}</it.dropbox.username>
                <it.dropbox.password>${it.dropbox.password}</it.dropbox.password>
                <it.sauce.username>${it.sauce.username}</it.sauce.username>
                <it.sauce.accessKey>${it.sauce.accessKey}</it.sauce.accessKey>
                <it.sauce.host>${it.sauce.host}</it.sauce.host>
                <it.sauce.port>${it.sauce.port}</it.sauce.port>
              </systemPropertyVariables>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
              <execution>
                <id>verify</id>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>de.juplo</groupId>
            <artifactId>hibernate4-maven-plugin</artifactId>
            <version>1.0.5</version>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
              </dependency>
            </dependencies>
            <configuration>
              <driverClassName>${it.jdbc.driver}</driverClassName>
              <hibernateDialect>${it.hibernate.dialect}</hibernateDialect> 
              <url><![CDATA[${it.jdbc.url}]]></url>
              <username>${it.jdbc.username}</username>
              <password>${it.jdbc.password}</password>
            </configuration>
            <executions>
              <execution> 
                <id>create-schema</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>export</goal>
                </goals>
                <configuration>
                  <type>CREATE</type>
                </configuration>
              </execution>
              
              <execution> 
                <id>drop-db-after-test</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>export</goal>
                </goals>
                <configuration>
                  <type>DROP</type>
                  <force>true</force>
                </configuration>
              </execution>
            </executions>
          </plugin>
    
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sql-maven-plugin</artifactId>
            <version>1.5</version>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
              </dependency>
            </dependencies>
    
            <configuration>      
              <driver>${it.jdbc.driver}</driver>
              <url>${it.jdbc.url}</url>
              <username>${it.jdbc.username}</username>
              <password>${it.jdbc.password}</password>
            </configuration>
            <executions>
              <execution>
                <id>basic-sql-setup</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <autocommit>true</autocommit>
                  <srcFiles>
                    <srcFile>src/test/resources/basic-setup.sql</srcFile>
                  </srcFiles>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>keytool-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
              <execution>
                <phase>generate-resources</phase>
                <id>keystoreclean</id>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>truststoreclean</id>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <keystore>${it.truststore}</keystore>
                </configuration>
              </execution>
              <execution> 
                <phase>generate-resources</phase>
                <id>genkey</id>
                <goals>
                  <goal>generateKeyPair</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <dname>cn=${it.host}, ou=None, L=Test, ST=Test, o=Test, c=TE</dname>
                  <storepass>${it.keystorepass}</storepass>
                  <alias>${it.host}</alias>
                  <keyalg>RSA</keyalg>
                  <keysize>2048</keysize>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>exportkey</id>
                <goals>
                  <goal>exportCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <alias>${it.host}</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.keystorepass}</storepass>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-keystore</id>
                <goals>
                  <goal>importCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <alias>root</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.keystorepass}</storepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-truststore</id>
                <goals>
                  <goal>importCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.truststore}</keystore>
                  <alias>${it.host}</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.truststorepass}</storepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-jre-truststore</id>
                <goals>
                  <goal>importKeystore</goal>
                </goals>
                <configuration>
                  <srckeystore>${java.home}/lib/security/cacerts</srckeystore>
                  <srcstorepass>changeit</srcstorepass>
                  <destkeystore>${it.truststore}</destkeystore>
                  <deststorepass>${it.truststorepass}</deststorepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.4.8</version>
            <configuration>
              <container>
                <containerId>wildfly8x</containerId>
                <log>${project.basedir}/target/cargo.log</log>
                <output>${project.basedir}/target/wildfly.log</output>
                <zipUrlInstaller>
                  <url>http://download.jboss.org/wildfly/8.1.0.Final/wildfly-8.1.0.Final.zip</url>
                  <downloadDir>${project.basedir}/.cargo/downloads</downloadDir>
                  <extractDir>${project.basedir}/.cargo/extracts</extractDir>
                </zipUrlInstaller>
                <dependencies>
                  <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                  </dependency>
                </dependencies>
                <systemProperties>
                  <javax.net.ssl.keyStore>${it.keystore}</javax.net.ssl.keyStore>
                  <javax.net.ssl.keyStorePassword>${it.keystorepass}</javax.net.ssl.keyStorePassword>
                  <javax.net.ssl.trustStore>${it.truststore}</javax.net.ssl.trustStore>
                  <javax.net.ssl.trustStorePassword>${it.truststorepass}</javax.net.ssl.trustStorePassword>
                </systemProperties>                
              </container>
              <configuration>
                <properties>
                  <cargo.servlet.port>${it.port.http}</cargo.servlet.port>
                  <cargo.jboss.configuration>standalone</cargo.jboss.configuration>
                  <cargo.jvmargs>-Xms64m -Xmx1152m -XX:MaxPermSize=512m</cargo.jvmargs>
                  <cargo.datasource.datasource.fnici>
                    cargo.datasource.driver=${it.jdbc.driver}|
                    cargo.datasource.url=${it.jdbc.url}|
                    cargo.datasource.jndi=${it.jdbc.jndi}|
                    cargo.datasource.username=${it.jdbc.username}|
                    cargo.datasource.password=${it.jdbc.password}|
                    cargo.datasource.transactionsupport=LOCAL_TRANSACTION
                  </cargo.datasource.datasource.fnici>
                </properties>    
              </configuration>

              <deployables>
                <deployable>
                  <groupId>fi.foyt.fni</groupId>
                  <artifactId>webapp</artifactId>
                  <type>war</type>
                  <properties>
                    <context>${it.ctx}</context>
                  </properties>
                </deployable>
              </deployables>

            </configuration>
            <executions>
              <execution>
                <id>start-cargo</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
              </execution>
              <execution>
                <id>stop-cargo</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.1.Final</version>
            <executions>
              <execution>
                <id>configure-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute-commands</goal>
                </goals>
                <configuration>
                  <execute-commands>
                    <batch>true</batch>
                    <commands>
                      <command>/system-property=fni-google-drive.keyFile:add(value="${it.googleDrive.keyFile}")</command>
                      <command>/system-property=fni-google-drive.accountId:add(value="${it.googleDrive.accountId}")</command>
                      <command>/system-property=fni-google-drive.accountUser:add(value="${it.googleDrive.accountUser}")</command>
                      <command>/system-property=fni-host:add(value="${it.host}")</command>
                      <command>/system-property=fni-http-port:add(value="${it.port.http}")</command>
                      <command>/system-property=fni-https-port:add(value="${it.port.https}")</command>
                      <command>/core-service=management/security-realm=ssl-realm:add()</command>
                      <command>/core-service=management/security-realm=ssl-realm/server-identity=ssl:add(keystore-path="${it.keystore}",keystore-password="${it.keystorepass}",alias="${it.host}")</command>
                      <command>/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding="https",security-realm="ssl-realm")</command>
                      <command>/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp/:write-attribute(name=port,value=${it.smtp.port})</command>
                    </commands>
                  </execute-commands>
                </configuration>
              </execution>
              
              <execution>
                <id>reload-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute-commands</goal>
                </goals>
                <configuration>
                  <execute-commands>
                    <commands>
                      <command>:reload</command>
                    </commands>
                  </execute-commands>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>com.saucelabs.maven.plugin</groupId>
            <artifactId>sauce-connect-plugin</artifactId>
            <version>2.1.13</version>
            <configuration>
              <sauceUsername>${it.sauce.username}</sauceUsername>
              <sauceAccessKey>${it.sauce.accessKey}</sauceAccessKey>
              <quietMode>true</quietMode>
            </configuration>
            <executions>
              <execution>
                <id>start-sauceconnct</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start-sauceconnect</goal>
                </goals>
              </execution>
              <execution>
                <id>stop-sauceconnect</id>
                  <phase>post-integration-test</phase>
                  <goals>
                    <goal>stop-sauceconnect</goal>
                  </goals>
              </execution>
            </executions>
          </plugin>
                    
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>wait-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
              <execution>
                <id>wait</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>wait</goal>
                </goals>      
                <configuration>
                  <protocol>http</protocol>
                  <host>${it.host}</host>
                  <port>${it.port.http}</port>
                  <file>/${it.ctx}</file>
                  <maxcount>20</maxcount>
                  <timeout>10000</timeout>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>travis</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      
      <properties>
        <wildfly.home>${project.basedir}/.cargo/extracts/wildfly-8.1.0.Final/wildfly-8.1.0.Final</wildfly.home>
        <wildfly.version>8.1.0.Final</wildfly.version>
        <h2.version>1.4.177</h2.version>
        <it.port.http>8080</it.port.http>
        <it.port.https>8443</it.port.https>
        <it.host>test.forgeandillusion.net</it.host>
        <it.ctx>fnici</it.ctx>
        <it.smtp.port>3025</it.smtp.port>
        <it.jdbc.driver>org.h2.Driver</it.jdbc.driver>
        <it.jdbc.url>jdbc:h2:file:${project.build.directory}/h2;AUTO_SERVER=TRUE</it.jdbc.url>
        <it.jdbc.jndi>java:/jboss/datasources/fni</it.jdbc.jndi>
        <it.jdbc.username>sa</it.jdbc.username>
        <it.jdbc.password>sa</it.jdbc.password>
        <it.hibernate.dialect>org.hibernate.dialect.H2Dialect</it.hibernate.dialect>
        <it.keystore>${project.build.directory}/fnici.keystore</it.keystore>
        <it.truststore>${project.build.directory}/fnici.truststore</it.truststore>
        <it.keystorepass>keystorepass</it.keystorepass>
        <it.truststorepass>truststorepass</it.truststorepass>
      </properties>
      
      <dependencies>
        <dependency>
          <groupId>com.h2database</groupId>
          <artifactId>h2</artifactId>
          <version>${h2.version}</version>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>fi.foyt.fni</groupId>
          <artifactId>persistence</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
              <systemPropertyVariables>
                <jboss.home>${wildfly.home}</jboss.home>
                <module.path>${wildfly.home}/modules</module.path>
              </systemPropertyVariables>
            </configuration>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <executions>
              <execution>
                <phase>initialize</phase>
                <goals>
                  <goal>read-project-properties</goal>
                </goals>
                <configuration>
                  <files>
                    <file>src/test/resources/it.properties</file>
                  </files>
                </configuration>
              </execution>
            </executions>
          </plugin>
    
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.16</version>
            <configuration>
              <includes>
                <include>fi/foyt/fni/test/rest/**/*IT.java</include>
                <include>fi/foyt/fni/test/ui/sauce/**/*IT.java</include>
              </includes>
              <systemPropertyVariables>
                <jboss.home>${wildfly.home}</jboss.home>
                <module.path>${wildfly.home}/modules</module.path>
                <it.project.version>${project.version}</it.project.version>
                <it.host>${it.host}</it.host>
                <it.port.http>${it.port.http}</it.port.http>
                <it.port.https>${it.port.https}</it.port.https>
                <it.ctx>${it.ctx}</it.ctx>
                <it.smtp.port>${it.smtp.port}</it.smtp.port>
                <it.jdbc.driver>${it.jdbc.driver}</it.jdbc.driver>
                <it.jdbc.url>${it.jdbc.url}</it.jdbc.url>
                <it.jdbc.jndi>${it.jdbc.jndi}</it.jdbc.jndi>
                <it.jdbc.username>${it.jdbc.username}</it.jdbc.username>
                <it.jdbc.password>${it.jdbc.password}</it.jdbc.password>
                <it.google.apiKey>${it.google.apiKey}</it.google.apiKey>
                <it.google.apiSecret>${it.google.apiSecret}</it.google.apiSecret>
                <it.google.username>${it.google.username}</it.google.username>
                <it.google.password>${it.google.password}</it.google.password>
                <it.facebook.apiKey>${it.facebook.apiKey}</it.facebook.apiKey>
                <it.facebook.apiSecret>${it.facebook.apiSecret}</it.facebook.apiSecret>
                <it.facebook.username>${it.facebook.username}</it.facebook.username>
                <it.facebook.password>${it.facebook.password}</it.facebook.password>
                <it.dropbox.apiKey>${it.dropbox.apiKey}</it.dropbox.apiKey>
                <it.dropbox.apiSecret>${it.dropbox.apiSecret}</it.dropbox.apiSecret>
                <it.dropbox.username>${it.dropbox.username}</it.dropbox.username>
                <it.dropbox.password>${it.dropbox.password}</it.dropbox.password>
                <it.sauce.username>${env.SAUCE_USERNAME}</it.sauce.username>
                <it.sauce.accessKey>${env.SAUCE_ACCESS_KEY}</it.sauce.accessKey>
                <it.sauce.tunnelId>${env.TRAVIS_JOB_NUMBER}</it.sauce.tunnelId>
                <javax.net.ssl.trustStore>${it.truststore}</javax.net.ssl.trustStore>
                <javax.net.ssl.trustStorePassword>${it.truststorepass}</javax.net.ssl.trustStorePassword>
              </systemPropertyVariables>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
              <execution>
                <id>verify</id>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>de.juplo</groupId>
            <artifactId>hibernate4-maven-plugin</artifactId>
            <version>1.0.5</version>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
              </dependency>
            </dependencies>
            <configuration>
              <driverClassName>${it.jdbc.driver}</driverClassName>
              <hibernateDialect>${it.hibernate.dialect}</hibernateDialect> 
              <url><![CDATA[${it.jdbc.url}]]></url>
              <username>${it.jdbc.username}</username>
              <password>${it.jdbc.password}</password>
            </configuration>
            <executions>
              <execution> 
                <id>create-schema</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>export</goal>
                </goals>
                <configuration>
                  <type>CREATE</type>
                </configuration>
              </execution>
              
              <execution> 
                <id>drop-db-after-test</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>export</goal>
                </goals>
                <configuration>
                  <type>DROP</type>
                  <force>true</force>
                </configuration>
              </execution>
            </executions>
          </plugin>
    
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sql-maven-plugin</artifactId>
            <version>1.5</version>
            <dependencies>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
              </dependency>
            </dependencies>
    
            <configuration>      
              <driver>${it.jdbc.driver}</driver>
              <url>${it.jdbc.url}</url>
              <username>${it.jdbc.username}</username>
              <password>${it.jdbc.password}</password>
            </configuration>
            <executions>
              <execution>
                <id>basic-sql-setup</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <autocommit>true</autocommit>
                  <srcFiles>
                    <srcFile>src/test/resources/basic-setup.sql</srcFile>
                  </srcFiles>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>keytool-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
              <execution>
                <phase>generate-resources</phase>
                <id>keystoreclean</id>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>truststoreclean</id>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <keystore>${it.truststore}</keystore>
                </configuration>
              </execution>
              <execution> 
                <phase>generate-resources</phase>
                <id>genkey</id>
                <goals>
                  <goal>generateKeyPair</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <dname>cn=${it.host}, ou=None, L=Test, ST=Test, o=Test, c=TE</dname>
                  <storepass>${it.keystorepass}</storepass>
                  <alias>${it.host}</alias>
                  <keyalg>RSA</keyalg>
                  <keysize>2048</keysize>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>exportkey</id>
                <goals>
                  <goal>exportCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <alias>${it.host}</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.keystorepass}</storepass>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-keystore</id>
                <goals>
                  <goal>importCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.keystore}</keystore>
                  <alias>root</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.keystorepass}</storepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-truststore</id>
                <goals>
                  <goal>importCertificate</goal>
                </goals>
                <configuration>
                  <keystore>${it.truststore}</keystore>
                  <alias>${it.host}</alias>
                  <file>${project.build.directory}/fnici.crt</file>
                  <storepass>${it.truststorepass}</storepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
              <execution>
                <phase>generate-resources</phase>
                <id>importkey-jre-truststore</id>
                <goals>
                  <goal>importKeystore</goal>
                </goals>
                <configuration>
                  <srckeystore>${java.home}/lib/security/cacerts</srckeystore>
                  <srcstorepass>changeit</srcstorepass>
                  <destkeystore>${it.truststore}</destkeystore>
                  <deststorepass>${it.truststorepass}</deststorepass>
                  <noprompt>true</noprompt>
                  <trustcacerts>true</trustcacerts>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.4.8</version>
            <configuration>
              <container>
                <containerId>wildfly8x</containerId>
                <log>${project.basedir}/target/cargo.log</log>
                <output>${project.basedir}/target/wildfly.log</output>
                <zipUrlInstaller>
                  <url>http://download.jboss.org/wildfly/8.1.0.Final/wildfly-8.1.0.Final.zip</url>
                  <downloadDir>${project.basedir}/.cargo/downloads</downloadDir>
                  <extractDir>${project.basedir}/.cargo/extracts</extractDir>
                </zipUrlInstaller>
                <dependencies>
                  <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                  </dependency>
                </dependencies>
                <systemProperties>
                  <javax.net.ssl.keyStore>${it.keystore}</javax.net.ssl.keyStore>
                  <javax.net.ssl.keyStorePassword>${it.keystorepass}</javax.net.ssl.keyStorePassword>
                  <javax.net.ssl.trustStore>${it.truststore}</javax.net.ssl.trustStore>
                  <javax.net.ssl.trustStorePassword>${it.truststorepass}</javax.net.ssl.trustStorePassword>
                </systemProperties>                
              </container>
              <configuration>
                <properties>
                  <cargo.servlet.port>${it.port.http}</cargo.servlet.port>
                  <cargo.jboss.configuration>standalone</cargo.jboss.configuration>
                  <cargo.jvmargs>-Xms64m -Xmx1152m -XX:MaxPermSize=512m</cargo.jvmargs>
                  <cargo.datasource.datasource.fnici>
                    cargo.datasource.driver=${it.jdbc.driver}|
                    cargo.datasource.url=${it.jdbc.url}|
                    cargo.datasource.jndi=${it.jdbc.jndi}|
                    cargo.datasource.username=${it.jdbc.username}|
                    cargo.datasource.password=${it.jdbc.password}|
                    cargo.datasource.transactionsupport=LOCAL_TRANSACTION
                  </cargo.datasource.datasource.fnici>
                </properties>    
              </configuration>

              <deployables>
                <deployable>
                  <groupId>fi.foyt.fni</groupId>
                  <artifactId>webapp</artifactId>
                  <type>war</type>
                  <properties>
                    <context>${it.ctx}</context>
                  </properties>
                </deployable>
              </deployables>

            </configuration>
            <executions>
              <execution>
                <id>start-cargo</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
              </execution>
              <execution>
                <id>stop-cargo</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.1.Final</version>
            <executions>
              <execution>
                <id>configure-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute-commands</goal>
                </goals>
                <configuration>
                  <execute-commands>
                    <batch>true</batch>
                    <commands>
                      <command>/system-property=fni-google-drive.keyFile:add(value="${it.googleDrive.keyFile}")</command>
                      <command>/system-property=fni-google-drive.accountId:add(value="${it.googleDrive.accountId}")</command>
                      <command>/system-property=fni-google-drive.accountUser:add(value="${it.googleDrive.accountUser}")</command>
                      <command>/system-property=fni-host:add(value="${it.host}")</command>
                      <command>/system-property=fni-http-port:add(value="${it.port.http}")</command>
                      <command>/system-property=fni-https-port:add(value="${it.port.https}")</command>
                      <command>/core-service=management/security-realm=ssl-realm:add()</command>
                      <command>/core-service=management/security-realm=ssl-realm/server-identity=ssl:add(keystore-path="${it.keystore}",keystore-password="${it.keystorepass}",alias="${it.host}")</command>
                      <command>/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding="https",security-realm="ssl-realm")</command>
                      <command>/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp/:write-attribute(name=port,value=${it.smtp.port})</command>
                    </commands>
                  </execute-commands>
                </configuration>
              </execution>
              
              <execution>
                <id>reload-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>execute-commands</goal>
                </goals>
                <configuration>
                  <execute-commands>
                    <commands>
                      <command>:reload</command>
                    </commands>
                  </execute-commands>
                </configuration>
              </execution>
            </executions>
          </plugin>
                    
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>wait-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
              <execution>
                <id>wait</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>wait</goal>
                </goals>      
                <configuration>
                  <protocol>http</protocol>
                  <host>${it.host}</host>
                  <port>${it.port.http}</port>
                  <file>/${it.ctx}</file>
                  <maxcount>20</maxcount>
                  <timeout>10000</timeout>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
