//HACK: once we port tests to the new data directory, remove this
GeoServerLoader.setLegacy( useLegacyDataDirectory() );
// if we have data, create a mock servlet context and start up the spring configuration
if (testData.isTestDataAvailable()) {
MockServletContext servletContext = new MockServletContext();
servletContext.setInitParameter("GEOSERVER_DATA_DIR", testData.getDataDirectoryRoot()
.getPath());
servletContext.setInitParameter("serviceStrategy", "PARTIAL-BUFFER2");
//set up a fake WEB-INF directory
if (testData.getDataDirectoryRoot().canWrite()) {
File webinf = new File(testData.getDataDirectoryRoot(), "WEB-INF");
webinf.mkdir();
servletContext.setRealPath("WEB-INF", webinf.getAbsolutePath());
}
applicationContext = new GeoServerTestApplicationContext(getSpringContextLocations(),
servletContext);
applicationContext.setUseLegacyGeoServerLoader(useLegacyDataDirectory());
applicationContext.refresh();
// set the parameter after a refresh because it appears a refresh
// wipes
// out all parameters
servletContext.setAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
applicationContext);
}
}