public WPSStorageCleaner(GeoServerDataDirectory dataDirectory) throws IOException, ConfigurationException { // get the temporary storage for WPS storage = dataDirectory.findOrCreateDir("temp/wps"); }
public GeoServerSimpleCatalogStore(GeoServerDataDirectory dataDirectory) throws IOException { super(dataDirectory.findOrCreateDir("catalog")); }
File getTransformInfoFile(String name) throws IOException { File root = dataDir.findOrCreateDir("wfs", "transform"); File infoFile = new File(root, name + ".xml"); return infoFile; }
private File getTransformFile(TransformInfo info) throws IOException { String txName = info.getXslt(); File root = dataDir.findOrCreateDir("wfs", "transform"); File txFile = new File(root, txName); return txFile; }
/** * Returns all the transform (either global or feature type specific) * * @return */ public List<TransformInfo> getAllTransforms() throws IOException { File root = dataDir.findOrCreateDir("wfs", "transform"); List<TransformInfo> result = new ArrayList<TransformInfo>(); for (File f : root.listFiles(CONFIG_NAME_FILTER)) { try { TransformInfo tx = infoCache.getItem(f); result.add(tx); } catch (Exception e) { LOGGER.log(Level.FINE, "Failed to load configuration from file " + f.getAbsolutePath(), e); } } return result; }
@After public void cleanupRegionationDatabases() throws IOException { File dir = getDataDirectory().findOrCreateDir("geosearch"); FileUtils.deleteDirectory(dir); }
@Test public void testPostScriptDisableTraversal() throws Exception { // prepare the scripts folder, but leave it empty File scripts = getDataDirectory().findOrCreateDir("importer", "scripts"); FileUtils.deleteQuietly(scripts); assertTrue(scripts.mkdirs()); try { new PostScriptTransform("../wfs.xml", Collections.emptyList()); fail("Should have thrown an exception"); } catch (Exception e) { assertThat(e.getMessage(), containsString("invalid ..")); } }
@Test public void testRunNonExistingScript() throws Exception { // prepare the scripts folder, but leave it empty File scripts = getDataDirectory().findOrCreateDir("importer", "scripts"); FileUtils.deleteQuietly(scripts); assertTrue(scripts.mkdirs()); try { new PostScriptTransform("i_am_not_there.sh", Collections.emptyList()); fail("Should have thrown an exception"); } catch (Exception e) { assertThat(e.getMessage(), containsString("i_am_not_there.sh")); } }
@Test public void testRelativePath() throws Exception { WatermarkDecoration d = new WatermarkDecoration(); Map<String, String> options = new HashMap<String, String>(); File file = new File("src/test/resources/org/geoserver/wms/world.png"); File styles = getDataDirectory().findOrCreateDir("styles"); File logoFile = new File(styles, "world.png").getAbsoluteFile(); FileUtils.copyFile(file, logoFile); options.put("url", "file:styles/world.png"); d.loadOptions(options); BufferedImage logo = d.getLogo(); assertNotNull(logo); assertEquals(180, logo.getWidth()); assertEquals(90, logo.getHeight()); }
@Test public void testRelativeUnqualifiedPath() throws Exception { WatermarkDecoration d = new WatermarkDecoration(); Map<String, String> options = new HashMap<>(); File file = new File("src/test/resources/org/geoserver/wms/world.png"); File styles = getDataDirectory().findOrCreateDir("styles"); File logoFile = new File(styles, "world.png").getAbsoluteFile(); FileUtils.copyFile(file, logoFile); options.put("url", "styles/world.png"); d.loadOptions(options); BufferedImage logo = d.getLogo(); assertNotNull(logo); assertEquals(180, logo.getWidth()); assertEquals(90, logo.getHeight()); } }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); ImporterTestUtils.setComparisonTolerance(); // init xmlunit Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); namespaces.put("wms", "http://www.opengis.net/wms"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); // add test importer properties file to the temporary data dir. For testing purposes only dd = new GeoServerDataDirectory(testData.getDataDirectoryRoot()); GeoServerExtensionsHelper.singleton("dataDirectory", dd, GeoServerDataDirectory.class); // write out a simple shell script in the data dir and make it executable File importerConfigLocation = dd.findOrCreateDir("importer"); File importerConfigProps = new File(importerConfigLocation, "importer.properties"); IOUtils.copy( ImporterTestSupport.class .getClassLoader() .getResourceAsStream("importer.properties"), importerConfigProps); }
@Test public void testLayoutTranslucent() throws Exception { // add the layout to the data dir File layouts = getDataDirectory().findOrCreateDir("layouts"); URL layout = GetMapIntegrationTest.class.getResource("test-layout.xml"); FileUtils.copyURLToFile(layout, new File(layouts, "test-layout.xml")); // get a map with the layout after using a translucent style BufferedImage image = getAsImage( "wms?bbox=" + bbox + "&styles=translucent&layers=" + layers + "&Format=image/png" + "&request=GetMap" + "&width=550" + "&height=250" + "&srs=EPSG:4326" + "&format_options=layout:test-layout&transparent=true", "image/png"); // RenderedImageBrowser.showChain(image); // check the pixels that should be in the scale bar assertPixel(image, 56, 211, Color.WHITE); // see GEOS-6482 assertTrue( getPixelColor(image, 52, 221).equals(Color.BLACK) || getPixelColor(image, 52, 222).equals(Color.BLACK)); }
@Test public void testLayoutLegendNPE() throws Exception { // set the title to null FeatureTypeInfo states = getCatalog().getFeatureTypeByName("states"); states.setTitle(null); getCatalog().save(states); // add the layout to the data dir File layouts = getDataDirectory().findOrCreateDir("layouts"); URL layout = GetMapIntegrationTest.class.getResource("test-layout.xml"); FileUtils.copyURLToFile(layout, new File(layouts, "test-layout.xml")); // get a map with the layout, it used to NPE BufferedImage image = getAsImage( "wms?bbox=" + bbox + "&styles=Population&layers=" + layers + "&Format=image/png" + "&request=GetMap" + "&width=550" + "&height=250" + "&srs=EPSG:4326&format_options=layout:test-layout", "image/png"); // RenderedImageBrowser.showChain(image); // check the pixels that should be in the legend assertPixel(image, 12, 16, Color.RED); assertPixel(image, 12, 32, Color.GREEN); assertPixel(image, 12, 52, Color.BLUE); }
@Test public void testLayoutLegendStyleTitle() throws Exception { // set the title to null FeatureTypeInfo states = getCatalog().getFeatureTypeByName("states"); states.setTitle(null); getCatalog().save(states); // add the layout to the data dir File layouts = getDataDirectory().findOrCreateDir("layouts"); URL layout = GetMapIntegrationTest.class.getResource("test-layout-sldtitle.xml"); FileUtils.copyURLToFile(layout, new File(layouts, "test-layout-sldtitle.xml")); // get a map with the layout, it used to NPE BufferedImage image = getAsImage( "wms?bbox=" + bbox + "&styles=Population&layers=" + layers + "&Format=image/png" + "&request=GetMap" + "&width=550" + "&height=250" + "&srs=EPSG:4326&format_options=layout:test-layout-sldtitle", "image/png"); // RenderedImageBrowser.showChain(image); // check the pixels that should be in the legend assertPixel(image, 12, 36, Color.RED); assertPixel(image, 12, 52, Color.GREEN); assertPixel(image, 12, 72, Color.BLUE); }
File layouts = getDataDirectory().findOrCreateDir("layouts"); URL layout = GetMapIntegrationTest.class.getResource("test-layout-sldtitle.xml"); FileUtils.copyURLToFile(layout, new File(layouts, "test-layout-sldtitle.xml"));
File scripts = getDataDirectory().findOrCreateDir("importer", "scripts"); File script = new File(scripts, "test.sh"); FileUtils.writeStringToFile(script, "touch test.properties\n");