dk.kosmisk:postgresql-maven-plugin (maven 3.5+)

postgresql-maven-plugin integration testing with a real postgresql server instance - maven 3.5+ This plugin ensures a PostgreSQL server (binary) is downloaded and started up before integraion testing starts. Use the maven-failsafe-plugin to supply the port, the database is listening on, to the integraion tests.

License

License

Categories

Categories

Maven Build Tools PostgreSQL Data Databases
GroupId

GroupId

dk.kosmisk
ArtifactId

ArtifactId

postgresql-maven-plugin
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

dk.kosmisk:postgresql-maven-plugin (maven 3.5+)
postgresql-maven-plugin integration testing with a real postgresql server instance - maven 3.5+ This plugin ensures a PostgreSQL server (binary) is downloaded and started up before integraion testing starts. Use the maven-failsafe-plugin to supply the port, the database is listening on, to the integraion tests.
Project URL

Project URL

https://github.com/kosmisk-dk/postgresql-maven-plugin
Source Code Management

Source Code Management

https://github.com/kosmisk-dk/postgresql-maven-plugin/tree/master

Download postgresql-maven-plugin

How to add to project

<plugin>
    <groupId>dk.kosmisk</groupId>
    <artifactId>postgresql-maven-plugin</artifactId>
    <version>1.0.4</version>
</plugin>

Dependencies

compile (2)

Group / Artifact Type Version
commons-io : commons-io jar 2.6
org.apache.commons : commons-compress jar 1.19

provided (2)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.6.0
org.apache.maven : maven-core jar 3.6.2

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest jar 2.2
com.googlecode.java-diff-utils : diffutils jar 1.3.0

Project Modules

There are no modules declared in this project.

postgresql-maven-plugin

An integration test helper

This is a plugin for running a PostgreSQL server around integration testing.

It has 3 stages

  • setup This stage
    • Chooses a port if none has been defined in (by listening to a tcp port, and releasing it for reuse)
    • Exposes said port as a property specified in , this defaults to postgresql.${name}.port
    • Chooses a dump folder if none has been defined in , this defaults to ${folder}/dump/${name}
    • Exposes said folder as a property: postgresql.dump.folder
  • startup This stage
    • unpacks the postgresq-binary artifact.
    • Calls the prepare.sh/.bat script to set up ad database
    • Modifies the postgresql.conf file according to the tag
    • Calls the start.sh/.bat script to start up the database
  • shutdown This stage
    • Calls the stop.sh/.bat script to shut down the database

Example of usage:

    <plugin>
        <groupId>dk.kosmisk</groupId>
        <artifactId>postgresql-maven-plugin</artifactId>
        <version>LATEST</version>
        <configuration>
            <!-- <groupId>dk.kosmisk</groupId> -->
            <!-- <artifactId>postgresql-binary</artifactId> -->
            <!-- <version>LATEST</version> -->
            <!-- <folder>${project.build.directory}/postgresql</folder> -->
            <!-- <overwrite>true</overwrite> -->
        </configuration>
        <executions>
            <execution>
                <id>postgresql-test-database</id>
                <goals>
                    <goal>setup</goal>
                    <goal>startup</goal>
                    <goal>shutdown</goal>
                </goals>
                <configuration>
                    <name>testbase</name>
                    <!-- <dumpFolder>${folder}/dump/${name}</dumpFolder> -->
                    <!-- <portProperty>postgresql.testbase.port</portProperty> -->
                    <!-- <port>[random-port]</port> -->
                    <!-- <user>${user.name}</user> -->
                    <!-- <password>${user.name}</password> -->
                    <!-- <databaseFolder>${folder}/db/${name}</databaseFolder> -->
                    <!-- <logfile>${databaseFolder}.log</logfile> -->
                    <!-- <settings>
                        <archive_mode>on</archive_mode>
                    </settings> -->
                </configuration>
            </execution>
        </executions>
    </plugin>

....

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>LATEST</version>
        <configuration>
            <systemPropertyVariables>
                <postgresql.testbase.port>${postgresql.testbase.port}</postgresql.testbase.port>
                <postgresql.dump.folder>${postgresql.dump.folder}</postgresql.dump.folder>
            </systemPropertyVariables>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>integration-test</goal>
                    <goal>verify</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

Versions

Version
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0