<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at
  
  http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!--
  @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
-->
<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.apache.directory.studio</groupId>
    <artifactId>parent-tests</artifactId>
    <version>2.0.0-SNAPSHOT</version>
  </parent>
  
  <artifactId>test.integration.ui</artifactId>
  <name>Apache Directory Studio UI Integration Tests</name>
  <packaging>jar</packaging>

  <description></description>
  
  <profiles>
  
    <!--linux-x86  -->
    <profile>
      <id>linux-x86</id>
      <activation>
        <os>
          <arch>i386</arch>
          <family>unix</family>
          <name>linux</name>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^/]*)/(.*)$$</integration-regexp>
        <integration-cmdline-params>-os linux -ws gtk -arch x86</integration-cmdline-params>
        <integration-plugins-folder>plugins</integration-plugins-folder>
      </properties>
    </profile>
    
    <!-- linux-x86_64 -->
    <profile>
      <id>linux-x86_64</id>
      <activation>
        <os>
          <arch>amd64</arch>
          <family>unix</family>
          <name>linux</name>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^/]*)/(.*)$$</integration-regexp>
        <integration-cmdline-params>-os linux -ws gtk -arch x86_64</integration-cmdline-params>
        <integration-plugins-folder>plugins</integration-plugins-folder>
      </properties>
    </profile>  
    
    <!-- linux-ppc -->
    <profile>
      <id>linux-ppc</id>
      <activation>
        <os>
          <arch>ppc</arch>
          <family>unix</family>
          <name>linux</name>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^/]*)/(.*)$$</integration-regexp>
        <integration-cmdline-params>-os linux -ws gtk -arch ppc</integration-cmdline-params>
        <integration-plugins-folder>plugins</integration-plugins-folder>
      </properties>
    </profile>  
    
    <!--win32  -->
    <profile>
       <id>win32</id>
      <activation>
        <os>
          <arch>x86</arch>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^\\]*)\\(.*)$$</integration-regexp>
        <integration-cmdline-params>-os win32 -ws win32 -arch x86</integration-cmdline-params>
        <integration-plugins-folder>plugins</integration-plugins-folder>
      </properties>
    </profile>  
    
    <!-- macosx -->
    <profile>
      <id>macosx</id>
      <activation>
        <os>
          <family>unix</family>
          <name>mac os x</name>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^/]*)/(.*)$$</integration-regexp>
        <integration-cmdline-params>-os macosx -ws carbon -arch x86</integration-cmdline-params>
        <integration-plugins-folder>Apache Directory Studio.app/Contents/Resources/Java/plugins</integration-plugins-folder>
      </properties>
    </profile>  
    
    <!-- launch UI tests using eclipse test framework -->
    <profile>
      <id>integration-ui</id>
      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>integration-ui</id>
                <phase>test</phase>
                <configuration>
                  <tasks>
                    
                    <!-- cleanup and recreate test-sandbox -->
                    <delete dir="target/test-sandbox"/>
                    <mkdir dir="target/test-sandbox"/>
                    <mkdir dir="target/test-sandbox/workspace"/>
                    
                    <!-- copy complete eclipse distribution to test-sandbox -->
                    <copy todir="target/test-sandbox">
                      <fileset dir="${eclipse-home}">
                        <exclude name="plugins/org.junit4*/**"/>
                      </fileset>
                    </copy>
                    
                    <!-- copy apache directory studio plugins to test-sandbox -->
                    <copy todir="target/test-sandbox">
                      <fileset dir="../target/distributions">
                        <include name="ApacheDirectoryStudio-*/**/plugins/org.apache.directory*"/>
                      </fileset>
                      <regexpmapper from="${integration-regexp}" to="\2"/>
                    </copy>
                    
                    <!-- copy SWTbot and eclipse testing plugins to test-sandbox -->
                    <copy todir="target/test-sandbox/${integration-plugins-folder}">
                      <fileset dir="resources/test-plugins">
                        <include name="**/*" />
                      </fileset>
                    </copy>
                    
                    <!-- copy test-integration-ui plugin to test-sandbox -->
                    <copy todir="target/test-sandbox/${integration-plugins-folder}">
                      <fileset dir="target">
                        <include name="test.integration.ui-*.jar" />
                      </fileset>
                    </copy>
                    
                    <!-- launch the tests -->
                    <java fork="true" failonerror="true" classname="org.eclipse.core.launcher.Main">
                      <jvmarg line="-Xmx1024m -XX:MaxPermSize=512m"/>
                      <arg line="${integration-cmdline-params} -nl en -debug debugoptions -application org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplication -data target/test-sandbox/workspace formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,target/test-sandbox/workspace/test-result.xml -testPluginName org.apache.directory.studio.test.integration.ui -className org.apache.directory.studio.test.integration.ui.AutomatedSuite"/>
                      <classpath>
                        <fileset dir="target/test-sandbox">
                          <include name="**/org.eclipse.equinox.launcher_*.jar"/>
                        </fileset>
                      </classpath>
                    </java>
                    
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

        </plugins>
      </build>
    </profile>
  </profiles>
  
  <build>
    <resources>
      <resource>
        <directory>.</directory>
        <includes>
          <include>plugin.xml</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <skip>false</skip>
          <pde>true</pde>
          <additionalProjectnatures>
            <projectnature>org.eclipse.pde.PluginNature</projectnature>
            <projectnature>org.eclipse.jdt.core.javanature</projectnature>
          </additionalProjectnatures>
          <classpathContainers>
            <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
            <classpathContainer>org.eclipse.pde.core.requiredPlugins</classpathContainer>
          </classpathContainers>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.directory.studio</groupId>
        <artifactId>studio-maven-plugin</artifactId>
        <configuration>
          <skip>false</skip>
          <createManifest>true</createManifest>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>prepare-jar-package</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
            <addMavenDescriptor>false</addMavenDescriptor>
          </archive>
        </configuration>
      </plugin>
      <!-- MANIFEST.MF Generation -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <manifestLocation>META-INF</manifestLocation>
          <instructions>            
            <Bundle-SymbolicName>${groupId}.${artifactId};singleton:=true</Bundle-SymbolicName>
            <Bundle-Localization>plugin</Bundle-Localization>
            <Require-Bundle>org.eclipse.core.runtime,
 org.eclipse.ui,
 org.apache.directory.studio.connection.core,
 org.apache.directory.studio.connection.ui,
 org.apache.directory.studio.ldapbrowser.common,
 org.apache.directory.studio.ldapbrowser.core,
 org.apache.directory.studio.ldapbrowser.ui,
 org.apache.directory.studio.apacheds,
 org.junit4,
 org.eclipse.swtbot.junit4_x,
 org.eclipse.swtbot.swt.finder,
 org.eclipse.swtbot.eclipse.finder,
 org.hamcrest
            </Require-Bundle>
            <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
            <Embed-Directory>lib</Embed-Directory>
            <Embed-StripGroup>true</Embed-StripGroup>
            <Embed-Transitive>true</Embed-Transitive>  
            <Export-Package>!*</Export-Package>
            <Import-Package>!</Import-Package>
            <Private-Package>!</Private-Package>
          </instructions>
        </configuration>
        <executions>
          <execution>
            <phase>process-classes</phase>
            <goals>    
              <goal>manifest</goal>
            </goals>   
          </execution>
        </executions>
      </plugin>
      <!-- No tests to run -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>false</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.apache.directory.server</groupId>
      <artifactId>apacheds-core-integ</artifactId>
      <version>1.5.5</version>
    </dependency> 
    <dependency>
      <groupId>org.apache.directory.server</groupId>
      <artifactId>apacheds-server-integ</artifactId>
      <version>1.5.5</version>
    </dependency> 
    <dependency>
      <groupId>org.apache.directory.shared</groupId>
      <artifactId>shared-ldap</artifactId>
      <version>0.9.17</version>
      <scope>provided</scope>
    </dependency> 
    <dependency>
      <groupId>org.apache.directory.shared</groupId>
      <artifactId>shared-asn1</artifactId>
      <version>0.9.17</version>
      <scope>provided</scope>
    </dependency> 
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
    </dependency>
    
    <dependency>
      <groupId>org.apache.directory.studio</groupId>
      <artifactId>connection.core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.directory.studio</groupId>
      <artifactId>connection.ui</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.directory.studio</groupId>
      <artifactId>ldapbrowser.core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.directory.studio</groupId>
      <artifactId>ldapbrowser.common</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.directory.studio</groupId>
      <artifactId>ldapbrowser.ui</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.directory.studio</groupId>
      <artifactId>apacheds</artifactId>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>org.eclipse.swtbot.swt</groupId>
      <artifactId>finder</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.swtbot.eclipse</groupId>
      <artifactId>finder</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-all</artifactId>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>org.eclipse</groupId>
      <artifactId>osgi</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.equinox</groupId>
      <artifactId>common</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.equinox</groupId>
      <artifactId>registry</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.core</groupId>
      <artifactId>runtime</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.core</groupId>
      <artifactId>jobs</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse</groupId>
      <artifactId>ui</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.ui</groupId>
      <artifactId>workbench</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse</groupId>
      <artifactId>jface</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.swt.gtk.linux</groupId>
      <artifactId>x86</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.equinox</groupId>
      <artifactId>preferences</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  
</project>
