This page last changed on Jul 17, 2008 by jdeolive.


Provide base classes which make it trivial to develop unit tests based on a "mock" GeoServer setup.

Proposed By

Justin Deoliveira

Proposal Type

Core Change

Assigned to release





JIRA task:


GSIP 8 - New Configuration System

Email discussion:

Other wiki discussions:


Current it is hard to develop unit tests for GeoServer is hard and a lot of work. For this reason our level of unit test coverage is unacceptably low.



Develop base classes which create a mock geoserver instance and make it available to test cases. Such base classes would provide the following:

  1. API which allows tests to simulate requests from a client. Example:
    public class GetFeatureMockTest extends GeoServerMockTest {
      public void testGet() {
        //execute a mock GetFeature "get" request
        String request = "request=GetFeature&typeName=topp:states&....";
        org.w3c.dom.Document response = getAsDOM( request );
        //make assertions
      public void testPost() {
         //execute a mock GetFeature "post" request
         String request = 
           "<wfs:GetFeature typeName="topp:states"/>";
         org.w3c.dom.Document response = postAsDOM( request );
         //make assertions
  2. Provide an instance of the spring context which is used in a live GeoServer instance, and access to the components inside of it. Example:
    public class DataTest extends GeoServerMockTest {
      public void testData() {
         //get the "data" component / bean
         Data data = (Data) context.getBean( "data" );
         //make assertions
      public void testGeoServer() {
         //get the "GeoServer" component / bean
         GeoServer geoServer = (GeoServer) context.getBean( "geoServer" );
         //make assertions


The base class which sets up the "mock" GeoServer instance will simulate the spring context which is created when a live GeoServer is started. To do so a full catalog and config must be created.

Backwards compatibility issues



Justin Deoliveira

Document generated by Confluence on May 14, 2014 23:00