<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>com.atlassian.crowd</groupId>
        <artifactId>atlassian-crowd</artifactId>
        <version>2.8.2</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <artifactId>crowd-dao-database-test</artifactId>
    <name>Atlassian Crowd - DAO database tests</name>

    <description>An acceptance test to run Crowd's Hibernate DAO tests against
         real databases. Uses HSQLDB by default.</description>

    <dependencies>
        <!-- Test fundamentals -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-test-utils</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-acceptance-test</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-jdbc-test-properties</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <copy file="src/test/resources/${test-database}-jdbc.test.properties" tofile="${project.build.testOutputDirectory}/jdbc.test.properties" />
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                            <argLine>-Xmx128m</argLine>
                            <includes>
                                <!-- these tests are DB-independent and can be run always -->
                                <include>**/HibernateDaoSuite.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>hsql</id>

            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <properties>
                <test-database>hsql</test-database>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>org.hsqldb</groupId>
                    <artifactId>hsqldb</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <skip>false</skip>
                                    <argLine>-Xmx128m</argLine>
                                    <includes>
                                        <!-- run all tests, even the HSQLDB-specific ones -->
                                        <include>**/*Suite.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

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

        <profile>
            <id>mysql</id>

            <properties>
                <test-database>mysql</test-database>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>postgres</id>

            <properties>
                <test-database>postgres</test-database>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>oracle</id>

            <properties>
                <test-database>oracle</test-database>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc6</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <!--
            Microsoft SQL Server: Want to use this profile (i.e. run MS SQL Server DAO tests)?
            1) Modify sqlserver-jdbc.test.properties to point to your MS SQL Server install
            2) run the sql script at src/test/bin/setup-crowd-db-in-sqlserver-for-dao-tests.sql against your MS SQL
               Server install
            3) mvn -o -am -Psqlserver -pl crowd-test-runner/crowd-dao-database-test clean install
            -->
            <id>sqlserver</id>

            <properties>
                <test-database>sqlserver</test-database>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>net.sourceforge.jtds</groupId>
                    <artifactId>jtds</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

</project>
