Skip to content

Commit

Permalink
Avoid full context reload in GWC integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Dec 28, 2018
1 parent 51f39ba commit 5450860
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.geoserver.catalog.PublishedInfo; import org.geoserver.catalog.PublishedInfo;
import org.geoserver.config.GeoServer; import org.geoserver.config.GeoServer;
import org.geoserver.config.GeoServerInitializer; import org.geoserver.config.GeoServerInitializer;
import org.geoserver.config.GeoServerReinitializer;
import org.geoserver.gwc.ConfigurableBlobStore; import org.geoserver.gwc.ConfigurableBlobStore;
import org.geoserver.gwc.layer.CatalogConfiguration; import org.geoserver.gwc.layer.CatalogConfiguration;
import org.geoserver.gwc.layer.GeoServerTileLayerInfo; import org.geoserver.gwc.layer.GeoServerTileLayerInfo;
Expand Down Expand Up @@ -62,7 +63,7 @@
* @author groldan * @author groldan
* @see GeoServerInitializer * @see GeoServerInitializer
*/ */
public class GWCInitializer implements GeoServerInitializer { public class GWCInitializer implements GeoServerReinitializer {


private static final Logger LOGGER = Logging.getLogger(GWCInitializer.class); private static final Logger LOGGER = Logging.getLogger(GWCInitializer.class);


Expand Down
23 changes: 16 additions & 7 deletions src/gwc/src/test/java/org/geoserver/gwc/GWCIntegrationTest.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
import org.geoserver.platform.GeoServerExtensions; import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.platform.GeoServerResourceLoader; import org.geoserver.platform.GeoServerResourceLoader;
import org.geoserver.test.GeoServerSystemTestSupport; import org.geoserver.test.GeoServerSystemTestSupport;
import org.geoserver.test.TestSetup;
import org.geoserver.test.TestSetupFrequency;
import org.geotools.feature.NameImpl; import org.geotools.feature.NameImpl;
import org.geowebcache.GeoWebCacheDispatcher; import org.geowebcache.GeoWebCacheDispatcher;
import org.geowebcache.GeoWebCacheException; import org.geowebcache.GeoWebCacheException;
Expand All @@ -96,13 +94,13 @@
import org.geowebcache.layer.TileLayerDispatcher; import org.geowebcache.layer.TileLayerDispatcher;
import org.geowebcache.service.wmts.WMTSService; import org.geowebcache.service.wmts.WMTSService;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import org.w3c.dom.Document; import org.w3c.dom.Document;


@TestSetup(run = TestSetupFrequency.REPEAT)
public class GWCIntegrationTest extends GeoServerSystemTestSupport { public class GWCIntegrationTest extends GeoServerSystemTestSupport {


// WMTS 1.0 namespaces // WMTS 1.0 namespaces
Expand Down Expand Up @@ -149,10 +147,7 @@ protected void setUpSpring(List<String> springContextLocations) {
springContextLocations.add("gwc-integration-test.xml"); springContextLocations.add("gwc-integration-test.xml");
} }


@Override private void prepareDataDirectory(SystemTestData testData) throws Exception {
protected void onSetUp(SystemTestData testData) throws Exception {
super.onSetUp(testData);

Catalog catalog = getCatalog(); Catalog catalog = getCatalog();
testData.addWorkspace(TEST_WORKSPACE_NAME, TEST_WORKSPACE_URI, catalog); testData.addWorkspace(TEST_WORKSPACE_NAME, TEST_WORKSPACE_URI, catalog);
WorkspaceInfo wi = catalog.getWorkspaceByName(TEST_WORKSPACE_NAME); WorkspaceInfo wi = catalog.getWorkspaceByName(TEST_WORKSPACE_NAME);
Expand Down Expand Up @@ -192,6 +187,20 @@ protected void onSetUp(SystemTestData testData) throws Exception {
HttpRequestRecorderCallback.reset(); HttpRequestRecorderCallback.reset();
} }


@Before
public void cleanup() throws Exception {
SystemTestData testData = getTestData();
for (File f : testData.getDataDirectoryRoot().listFiles()) {
FileUtils.deleteQuietly(f);
}
testData.setUp();
testData.setUpDefault();
getGeoServer().reload();
// GeoServerLoader loader = GeoServerExtensions.bean(DefaultGeoServerLoader.class);
// loader.initializeStyles(getCatalog());
prepareDataDirectory(testData);
}

protected GridSet namedGridsetCopy(final String newName, final GridSet oldGridset) { protected GridSet namedGridsetCopy(final String newName, final GridSet oldGridset) {
final GridSet newGridset; final GridSet newGridset;
{ {
Expand Down

0 comments on commit 5450860

Please sign in to comment.