<?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.    
-->
<project>
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.tuscany.sca</groupId>
        <artifactId>tuscany-sca</artifactId>
        <version>1.2-incubating-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>tuscany-itest</artifactId>
    <packaging>pom</packaging>
    <name>Apache Tuscany SCA Integration Tests</name>
    
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.2</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>2.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <was.ant.script>${basedir}/build-was-integration.xml</was.ant.script>
        <was.python.script>${basedir}/wasAdmin.py</was.python.script>
    </properties>


    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <modules>
                <module>callablereferences</module>
                <module>callablereferences-ws</module>
                <module>callback-api</module>
                <module>callback-basic</module>
                <module>callback-complex-type</module>
                <module>callback-id</module>
                <module>callback-multiple-wires</module>
                <module>callback-separatethread</module>
                <module>callback-set-callback</module>
                <module>callback-set-conversation</module>
                <module>contribution</module>
                <module>contribution-multiple</module>
                <module>contribution-import-export</module>
                <module>contribution-classloader</module>
                <module>conversations</module>
                <module>conversations-ws</module>
                <module>databindings</module>
                <module>domain</module>
                <module>exceptions</module>
                <module>exceptions-cross-binding</module>
                <module>exceptions-cross-binding-ws</module>
                <module>exceptions-simple-ws</module>
                <module>extended-api</module>
                <module>jms</module>
                <!--module>large-sdo-ws</module-->
                <module>oneway</module>
                <module>operation-overloading</module>
                <!--
                <module>osgi-implementation</module>
                <module>osgi-contribution</module>
                -->
                <module>properties</module>
                <module>recursive</module>
                <module>references</module>
                <module>services</module>
                <module>component-type</module>
                <module>interfaces</module>
                <module>wires</module>
                <!--
                <module>callback-separatethread</module>
                -->
                <module>scopes</module>
                <module>wsdl</module>
                <module>wsdlless</module>
                <module>wsdl2java</module>
                <module>wsdl-multiple</module>
                <module>ws-void-args-return</module>
                <module>transaction</module>
                <module>bpel</module>
                <module>spring</module>
		<module>policy</module>
           </modules>
        </profile>
        
        <!-- 
        This profile handles generation of jar/war artifacts to be used in executing tests in a web-container
        -->
        <profile>
            <id>webapp</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <!--
                <file>
                    <exists>src</exists>
                </file>
                -->
            </activation>
            
            <dependencies>
                <dependency>
	    	    <groupId>org.apache.tuscany.sca</groupId>
	    	    <artifactId>tuscany-host-webapp</artifactId>
	    	    <version>1.2-incubating-SNAPSHOT</version>
                    <scope>runtime</scope>
	    	</dependency>
                <dependency>
	    	    <groupId>org.apache.tuscany.sca</groupId>
	    	    <artifactId>tuscany-host-webapp-junit</artifactId>
	    	    <version>1.2-incubating-SNAPSHOT</version>
                    <scope>runtime</scope>
	    	</dependency>
                <dependency>
	    	    <groupId>javax.servlet</groupId>
	    	    <artifactId>servlet-api</artifactId>
	    	    <version>2.3</version>
                    <scope>provided</scope>
	    	</dependency>
	    </dependencies>    

            <modules>
                <module>callback-api</module>
                <module>callback-basic</module>
                <!--
                <module>callback-complex-type</module>
                -->
                <module>callback-id</module>
                <module>callback-multiple-wires</module>
                <module>callback-set-callback</module>
                <module>callback-set-conversation</module>
                <!--
                <module>contribution</module>
                <module>contribution-multiple</module>
                <module>contribution-import-export</module>
                <module>contribution-classloader</module>
                -->
                <module>conversations</module>
                <module>exceptions</module>
                <module>exceptions-cross-binding</module>
                <module>extended-api</module>
                <module>oneway</module>
                <module>operation-overloading</module>
                <!--
                <module>properties</module>
                <module>recursive</module>
                -->
                <module>references</module>
                <module>services</module>
                <module>component-type</module>
                <module>interfaces</module>
                <module>wires</module>
                <module>scopes</module>
                <module>large-sdo-ws</module>
            </modules>


            <build>
                <pluginManagement>
                    <plugins>
                        <!-- Skip local junit test cases -->
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>2.3.1</version>
                            <configuration>
                                <skip>true</skip>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>

                <plugins>

                    <!-- Create jar containing the jUnit tests -->
                    <!--
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>2.2</version>
                        <executions>
                            <execution>
                                <configuration>
                                    <finalName>junit</finalName>
                                </configuration>
                                <phase>test</phase>
                                <goals>
                                    <goal>test-jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    -->

                    <!-- Generate web-xml -->
                    <plugin>
                        <groupId>org.apache.tuscany.sca</groupId>
                        <artifactId>tuscany-maven-web-junit</artifactId>
                        <version>1.2-incubating-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <id>generate-web-xml</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Create war and include jUnit test classes -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.0.2</version>
                        <configuration>
                            <primaryArtifact>false</primaryArtifact>
                            <!-- Exclude a few jars to avoid conflicts -->
                            <warSourceExcludes>WEB-INF/lib/tuscany-host-tomcat-*.jar,WEB-INF/lib/tuscany-host-jetty-*.jar,servlet-api-*.jar, WEB-INF/lib/catalina*.jar,WEB-INF/classes/META-INF/sca-contribution*.xml</warSourceExcludes>
                            <webResources>
                                <!-- Add the tests jar into the WAR -->
                                <!--
                                <resource>
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>*-tests.jar</include>
                                    </includes>
                                    <targetPath>WEB-INF/lib</targetPath>
                                </resource>
                                -->

                                <resource>
                                    <directory>${project.build.directory}/test-classes</directory>
                                    <targetPath>WEB-INF/classes</targetPath>
                                </resource>

                                <resource>
                                    <directory>${project.build.directory}/classes/META-INF</directory>
                                    <includes>
                                        <include>sca-contribution*.xml</include>
                                    </includes>
                                    <targetPath>META-INF</targetPath>
                                </resource>

                                <!-- Add the junit -->
                                <resource>
                                    <directory>${settings.localRepository}/junit/junit/4.2</directory>
                                    <includes>
                                        <include>junit-4.2.jar</include>
                                    </includes>
                                    <targetPath>WEB-INF/lib</targetPath>
                                </resource>

                            </webResources>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>war</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>tomcat</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <!--
                <file>
                    <exists>src</exists>
                </file>
                -->
            </activation>
           <properties>
               <http.port>8085</http.port>
               <http.base>http://127.0.0.1:${http.port}</http.base>
               <tomcat.home>${env.CATALINA_HOME}</tomcat.home>
           </properties>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.tuscany.sca</groupId>
                        <artifactId>tuscany-maven-web-junit</artifactId>
                        <version>1.2-incubating-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <id>generate-web-xml</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>web-junit-test</id>
                                <configuration>
                                    <url>${http.base}/${project.build.finalName}/junit?op=runAll</url>
                                </configuration>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <container>
                                <containerId>tomcat5x</containerId>
                                <type>installed</type>
                                <home>${tomcat.home}</home>
                                <systemProperties>
                                    <org.apache.commons.logging.Log>
                                        org.apache.commons.logging.impl.SimpleLog
                                    </org.apache.commons.logging.Log>
                                </systemProperties>
                            </container>
                            <wait>false</wait>
                            <configuration>
                                <properties>
                                    <cargo.servlet.port>${http.port}</cargo.servlet.port>
                                </properties>
                                <deployables>
                                    <deployable>
                                        <location>${project.build.directory}/${project.build.finalName}.war</location>
                                        <pingURL>${http.base}/${project.build.finalName}/junit?op=list</pingURL>
                                        <type>war</type>
                                    </deployable>
                                </deployables>
                                <home>${project.build.directory}/cargo-tomcat</home>
                            </configuration>
                        </configuration>

                    </plugin>
                </plugins>
            </build>
        </profile>


        <profile>
            <id>jetty</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <!--
                <file>
                    <exists>src</exists>
                </file>
                -->
            </activation>
           <properties>
               <http.port>8085</http.port>
               <http.base>http://127.0.0.1:${http.port}</http.base>
               <jetty.home>${env.JETTY_HOME}</jetty.home>
           </properties>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.tuscany.sca</groupId>
                        <artifactId>tuscany-maven-web-junit</artifactId>
                        <version>1.2-incubating-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <id>generate-web-xml</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>web-junit-test</id>
                                <configuration>
                                    <url>${http.base}/${project.build.finalName}/junit?op=runAll</url>
                                </configuration>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <container>
                                <containerId>jetty6x</containerId>
                                <type>embedded</type>
                                <home>${jetty.home}</home>
                                <systemProperties>
                                    <org.apache.commons.logging.Log>
                                        org.apache.commons.logging.impl.SimpleLog
                                    </org.apache.commons.logging.Log>
                                </systemProperties>
                            </container>
                            <wait>false</wait>
                            <configuration>
                                <properties>
                                    <cargo.servlet.port>${http.port}</cargo.servlet.port>
                                </properties>
                                <deployables>
                                    <deployable>
                                        <location>${project.build.directory}/${project.build.finalName}.war</location>
                                        <pingURL>${http.base}/${project.build.finalName}/junit?op=list</pingURL>
                                        <type>war</type>
                                    </deployable>
                                </deployables>
                                <home>${project.build.directory}/cargo-jetty</home>
                            </configuration>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>geronimo</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <!--
                <file>
                    <exists>${geronimo.home}</exists>
                </file>
                -->
            </activation>
            <properties>
                <http.port>8080</http.port>
                <http.base>http://127.0.0.1:${http.port}</http.base>
                <geronimo.home>${env.GERONIMO_HOME}</geronimo.home>
            </properties>

            <build>
                <plugins>
                    <!-- Generate web-xml and geronimo deployment descriptor -->
                    <plugin>
                        <groupId>org.apache.tuscany.sca</groupId>
                        <artifactId>tuscany-maven-web-junit</artifactId>
                        <version>1.2-incubating-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <id>generate-web-xml</id>
                                <configuration>
                                    <geronimo>true</geronimo>
                                </configuration>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>web-junit-test</id>
                                <configuration>
                                    <url>${http.base}/${project.build.finalName}/junit?op=runAll</url>
                                </configuration>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.geronimo.plugins</groupId>
                        <artifactId>geronimo-maven-plugin</artifactId>
                        <version>2.0.2</version>
                        <configuration>
                            <geronimoHome>${geronimo.home}</geronimoHome>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <background>true</background>
                                </configuration>
                            </execution>
                            <execution>
                                <id>deploy-war</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>deploy</goal>
                                </goals>
                                <configuration>
                                    <moduleArchive>${project.build.directory}/${project.build.finalName}.war</moduleArchive>
                                </configuration>
                            </execution>
                            <execution>
                                <id>undeploy-war</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>undeploy</goal>
                                </goals>
                                <configuration>
                                    <moduleId>${groupId}/${artifactId}/${version}/war</moduleId>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                                <configuration>
                                    <username>system</username>
                                    <password>manager</password>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>websphere</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <http.port>8080</http.port>
                <http.base>http://127.0.0.1:${http.port}</http.base>
                <websphere.home>${env.WAS_HOME}</websphere.home>
            </properties>

            <build>
                <plugins>
                    <!-- Generate web-xml and geronimo deployment descriptor -->
                    <plugin>
                        <groupId>org.apache.tuscany.sca</groupId>
                        <artifactId>tuscany-maven-web-junit</artifactId>
                        <version>1.2-incubating-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <id>generate-web-xml</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>web-junit-test</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <url>${http.base}/${project.build.finalName}/junit?op=runAll</url>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

		    <!--WAS ant integration -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.1</version>
                        <executions>
                            <!-- start Websphere server -->
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
	                        <configuration>
	                            <tasks>
	                                <ant antfile="${was.ant.script}" target="startServer"/>
	                            </tasks>
	                        </configuration>
	                    </execution>
                            <!-- Deploy war application -->
                            <execution>
                                <id>deploy-war</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
	                        <configuration>
	                            <tasks>
	                                <ant antfile="${was.ant.script}" target="installApplication">
                                            <property name="was.python.script" value="${was.python.script}"/>
                                            <property name="application.war" value="${project.build.directory}/${project.build.finalName}.war"/>
                                            <property name="application.name" value="${project.build.finalName}.war"/>
                                            <property name="application.contextRoot" value="${project.build.finalName}"/>
                                            <property name="application.server" value="server1"/>
                                        </ant>
	                            </tasks>
	                        </configuration>
                            </execution>
                            <!-- unDeploy war application -->
                            <execution>
                                <id>undeploy-war</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
	                        <configuration>
	                            <tasks>
	                                <ant antfile="${was.ant.script}" target="uninstallApplication">
                                            <property name="was.python.script" value="${was.python.script}"/>
                                            <property name="application.name" value="${project.build.finalName}.war"/>
                                        </ant>
	                            </tasks>
	                        </configuration>
                            </execution>
                            <!-- Stop Websphere server -->
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
	                        <configuration>
	                            <tasks>
	                                <ant antfile="${was.ant.script}" target="stopServer"/>
	                            </tasks>
	                        </configuration>
                            </execution>

                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>


    </profiles>

</project>
