-
Notifications
You must be signed in to change notification settings - Fork 4
GSIP 12 Mock Test Support
Provide base classes which make it trivial to develop unit tests based on a “mock” GeoServer setup.
Justin Deoliveira
Core Change
tbd.
Obsolete
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:
-
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 ... }
}
-
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.
Justin Deoliveira