<?xml version="1.0" encoding="UTF-8"?>
<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>

    <parent>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-testsuite-integration-agg</artifactId>
        <version>7.1.0.CR1</version>
    </parent>

    <!-- ********************************************************************************** -->
    <!-- ******************************** Basic Integration ******************************* -->
    <!-- ********************************************************************************** -->
    <groupId>org.jboss.as</groupId>
    <artifactId>jboss-as-testsuite-integration-basic</artifactId>
    <version>7.1.0.CR1</version>

    <name>JBoss AS Test Suite: Integration - Basic</name>

    <properties>
        <jbossas.ts.integ.dir>${basedir}/..</jbossas.ts.integ.dir>
        <jbossas.ts.dir>${jbossas.ts.integ.dir}/..</jbossas.ts.dir>
        <jbossas.project.dir>${jbossas.ts.dir}/..</jbossas.project.dir>
    </properties>

    <!--  TODO move this to parent? -->
    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
    </build>

    <profiles>

                                
        <profile>
            <id>basic.integration.tests.profile</id>
            <activation>
                <property>
                    <name>!no.basic.integration.tests</name>
                </property>
            </activation>

            <!--
                Server configuration executions.
            -->
            <build>
                <plugins>

                    <!-- Build the target/jbossas server configuration. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions combine.children="append">
                            <!-- Copy in some jars. -->
                            <execution>
                                <id>prepare-jars-basic-integration.server</id>
                                <phase>process-test-resources</phase>
                                <goals><goal>run</goal></goals>
                                <configuration>
                                    <target>
                                        <property name="tests.resources.dir" value="${basedir}/../src/test/resources"/>
                                        <property name="tests.output.dir" value="${project.build.directory}"/>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions combine.children="append">

                            <!-- Disable default-test execution. -->
                            <execution><id>default-test</id><goals><goal>test</goal></goals><phase>none</phase></execution>


                            <execution>
                                <id>basic-integration-default-full.surefire</id>
                                <phase>test</phase>
                                <goals><goal>test</goal></goals>
                                <configuration>
                                    <!-- Tests to execute. Overriden in webProfileExclusion.profile . -->
                                    <includes>
                                        <include>org/jboss/as/test/integration/ejb/iiop/**/*TestCase*.java</include>
                                        <include>org/jboss/as/test/integration/*/security/**/*TestCase.java</include>
                                        <include>org/jboss/as/test/integration/ejb/mdb/**/*TestCase*.java</include>
                                        <include>org/jboss/as/test/integration/ejb/pool/**/*TestCase*.java</include>
                                        <include>org/jboss/as/test/integration/ejb/entity/cmp/**/*TestCase*.java</include>
                                        <include>org/jboss/as/test/integration/ejb/remote/entity/cmp/**/*TestCase*.java</include>
                                        <include>org/jboss/as/test/integration/ejb/management/deployments/EjbJarInEarRuntimeResourcesTestCase.java</include>
                                        <include>org/jboss/as/test/integration/ejb/management/deployments/EjbJarRuntimeResourcesTestCase.java</include>
                                        <include>org/jboss/as/test/integration/messaging/**/*TestCase*.java</include>
                                        <include>org/jboss/as/test/integration/management/cli/HelpTestCase.java</include>
                                        <include>org/jboss/as/test/integration/management/cli/JmsTestCase.java</include>
                                        <include>org/jboss/as/test/integration/ee/injection/resource/resourceref/*TestCase.java</include>
                                        <include>org/jboss/as/test/integration/ee/injection/resource/enventry/EnvEntryTestCase.java</include>
					<include>org/jboss/as/test/integration/ee/injection/resource/basic/*TestCase.java</include>
                                    </includes>

                                    <!-- Parameters to test cases. -->
                                    <systemPropertyVariables>
                                        <jboss.server.config.file.name>standalone-full.xml</jboss.server.config.file.name>
                                        <jboss.inst>${basedir}/target/jbossas</jboss.inst>
                                        <!-- Needed for the IIOP tests-->
                                        <com.sun.CORBA.ORBUseDynamicStub>true</com.sun.CORBA.ORBUseDynamicStub>
                                    </systemPropertyVariables>

                                    <additionalClasspathElements>
                                        <additionalClasspathElement>${project.basedir}/../src/test/resources</additionalClasspathElement>
                                    </additionalClasspathElements>

                                    <!--<reportNameSuffix>tests-basic-integration-default</reportNameSuffix>-->
                                </configuration>
                            </execution>
                            
                            <execution>
                                <id>basic-integration-default-web.surefire</id>
                                <phase>test</phase>
                                <goals><goal>test</goal></goals>
                                <configuration>
                                    <!-- Tests to execute. Overriden in webProfileExclusion.profile . -->
                                    <excludes>
                                        <!-- 2nd run tests are run in other execution. -->
                                        <exclude>org/jboss/as/test/integration/**/*SecondTestCase.java</exclude>
                                        <!-- Tests which need FULL config. -->
                                        <exclude>org/jboss/as/test/integration/ejb/iiop/**/*TestCase*.java</exclude>
                                        <exclude>org/jboss/as/test/integration/ejb/mdb/**/*TestCase*.java</exclude>
                                        <exclude>org/jboss/as/test/integration/ejb/pool/**/*TestCase*.java</exclude>
                                        <exclude>org/jboss/as/test/integration/ejb/entity/cmp/**/*TestCase*.java</exclude>
                                        <exclude>org/jboss/as/test/integration/ejb/remote/entity/cmp/**/*TestCase*.java</exclude>
                                        <exclude>org/jboss/as/test/integration/ejb/management/deployments/EjbJarInEarRuntimeResourcesTestCase.java</exclude>
                                        <exclude>org/jboss/as/test/integration/ejb/management/deployments/EjbJarRuntimeResourcesTestCase.java</exclude>
                                        <exclude>org/jboss/as/test/integration/messaging/**/*TestCase*.java</exclude>
                                        <exclude>org/jboss/as/test/integration/management/cli/HelpTestCase.java</exclude>
                                        <exclude>org/jboss/as/test/integration/management/cli/JmsTestCase.java</exclude>
                                        <exclude>org/jboss/as/test/integration/ee/injection/resource/resourceref/*TestCase.java</exclude>
                                        <exclude>org/jboss/as/test/integration/ee/injection/resource/enventry/EnvEntryTestCase.java</exclude>
					<exclude>org/jboss/as/test/integration/ee/injection/resource/basic/*TestCase.java</exclude>
                                    </excludes>

                                    <!-- Parameters to test cases. -->
                                    <systemPropertyVariables>
                                        <jboss.server.config.file.name>standalone.xml</jboss.server.config.file.name>
                                        <jboss.inst>${basedir}/target/jbossas</jboss.inst>
                                    </systemPropertyVariables>

                                    <additionalClasspathElements>
                                        <additionalClasspathElement>${project.basedir}/../src/test/resources</additionalClasspathElement>
                                    </additionalClasspathElements>

                                    <!--<reportNameSuffix>tests-basic-integration-default</reportNameSuffix>-->
                                </configuration>
                            </execution>
                            
                            
                            <!-- The second run tests rely on restoring timer services setup in the first run of tests. -->
                            <execution>
                                <id>basic-integration-2nd.surefire</id>
                                <phase>test</phase>
                                <goals><goal>test</goal></goals>
                                <configuration>
                                    <skipTests>${ts.skipTests}</skipTests>
                                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                                    <enableAssertions>true</enableAssertions>
                                    <includes>
                                        <include>org/jboss/as/test/integration/**/*SecondTestCase.java</include>
                                    </includes>
                                    <excludes>
                                        <exclude>none</exclude>
                                    </excludes>
                                </configuration>
                            </execution>

                        </executions>

                    </plugin>

                </plugins>
            </build>
        </profile>
        
        <!-- With -DnoWebProfile, the all tests will run with standalone-full.xml. -->
        <!-- This changes the FULL exec so that it includes all tests. -->
        <profile>
            <id>webProfileExclusion.profile</id>
            <activation><property><name>noWebProfile</name></property></activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <!-- Disable execution with WEB config. -->
                            <execution>
                                <id>basic-integration-default-web.surefire</id>
                                <phase>none</phase>
                                <goals><goal>test</goal></goals>
                            </execution>
                            <!-- Run the ALL tests with FULL config. -->
                            <execution>
                                <id>basic-integration-default-full.surefire</id>
                                <phase>test</phase>
                                <goals><goal>test</goal></goals>
                                <configuration>
                                    <systemPropertyVariables>
                                        <jboss.server.config.file.name>standalone-full.xml</jboss.server.config.file.name>
                                    </systemPropertyVariables>
                                    <includes>
                                        <include>**/*TestCase.java</include>
                                    </includes>
                                    <excludes>
                                        <exclude>org/jboss/as/test/integration/**/*SecondTestCase.java</exclude>
                                    </excludes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>



        <!-- When -Dtest=... is set, only the default surefire execution with standalone-full.xml will run. -->
        <profile>
            <id>onlyOneSurefireExecution.basic.profile</id>
            <activation><property><name>test</name></property></activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <execution><id>basic-integration-default-full.surefire</id><phase>test</phase></execution>
                            <execution><id>basic-integration-default-web.surefire</id><phase>none</phase></execution>
                            <execution><id>basic-integration-2nd.surefire</id><phase>none</phase></execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>
</project>
