Skip to content

Devs: running integration tests

Emanuele Tajariol edited this page Feb 10, 2021 · 9 revisions

PostGIS tests

(Since 3.4.8).

In order to run persistence tests against PostGIS, run the mvn install command with the postgis profile, e.g.:

mvn clean install -Ppostgis

With this profile, the module persistence-pg-test will be included; it runs the very same set of tests implemented in the persistence module, but against a pg database.

You will need:

  • an existing local Postgres DB named geofence_test
  • the owner of the db is called geofence_test with password geofence_test.

If you need to change the test db access info, you have to edit the core/persistence-pg-test/src/test/resources/geofence-datasource-ovr.properties file.

REST integration tests

The tests in src/services/modules/rest/client will be skipped if a test server instance is not found.

In order to run the test server instance:

  • go to src/services/modules/rest/test

  • run

       mvn jetty:run
    

Then rebuild (or run the test goal) in the rest client module:

  • go to src/services/modules/rest/client

  • run

       mvn clean install
    

    and make sure the ConnectException stack traces are not dumped.

REST tests with postgis

If you want to run the tests against a PostGIS DB, run the test server instance with:

mvn jetty:run -Dgeofence-datasource-file=src/main/resources/geofence-datasource-ovr-pg.properties -Ppostgis

As in the previous test, you will need:

  • a local Postgres DB named geofence_test
  • the owner of the db is called geofence_test with password geofence_test

GeoServer integration (GeoFence standalone)

The tests in the GeoServer community module src/community/geofence will be skipped if no test server instance is found; this message will be printed for each skipped test:

    Skipping test in AccessManagerTest as GeoFence service is down: in order to run this test you need the services to be running on port 9191

In order to run the test server instance:

  • go to the GeoFence module src/services/core/webtest

  • run

       mvn jetty:run
    

Then rebuild (or run the test goal) in the geofence community module:

  • go to src/community/geofence

  • run

       mvn clean install
    

GeoServer tests with postgis

If you want to run the tests against a PostGIS DB, run the test server instance with:

mvn jetty:run -Dgeofence-datasource-file=src/main/resources/geofence-datasource-ovr-pg.properties -Ppostgis

As in the previous test, you will need:

  • a local Postgres DB named geofence_test
  • the owner of the db is called geofence_test with password geofence_test

GeoServer integration (GeoFence embedded)

Build GeoServer and the GeoFence plugins:

cd <GEOSERVER_SOURCE_ROOT>/src
mvn clean install -Pgeofence -Pgeofence-server -T4

The previous build will also create a .war. file with both geofence plugins dependencies, which are in conflict. Let's build a vanilla geoserver.war with sample data:

cd web/app
mvn clean install -Prelease

Build the plugin ZIPs:

cd <GEOSERVER_SOURCE_ROOT>/src/release
mvn clean install 
cd ../..
mvn -f src/pom.xml assembly:single -N

Create a new war with the geofence-server plugin:

cd <GEOSERVER_SOURCE_ROOT>
mkdir -p distribution/geoserver
unzip src/web/app/target/geoserver.war -d distribution/geoserver/
unzip src/target/release/geoserver-2.17-SNAPSHOT-geofence-server-plugin.zip -d distribution/geoserver/WEB-INF/lib/
cd distribution/geoserver/
zip -r ../geoserver.war *
cd ..