private XMLConfiguration loadXMLConfig() throws Exception { InputStream is = null; XMLConfiguration xmlConfig = null; xmlConfig = new XMLConfiguration( null, new MockConfigurationResourceProvider( () -> XMLConfiguration.class.getResourceAsStream( XMLConfigurationBackwardsCompatibilityTest .LATEST_FILENAME))); return xmlConfig; }
private XMLConfiguration loadXMLConfig() { XMLConfiguration xmlConfig = null; try { xmlConfig = new XMLConfiguration( null, new MockConfigurationResourceProvider( () -> XMLConfiguration.class.getResourceAsStream( XMLConfigurationBackwardsCompatibilityTest .GWC_125_CONFIG_FILE))); } catch (Exception e) { // Do nothing } return xmlConfig; } }
private XMLConfiguration loadXMLConfig() { XMLConfiguration xmlConfig = null; try { xmlConfig = new XMLConfiguration( null, new MockConfigurationResourceProvider( () -> XMLConfiguration.class.getResourceAsStream( XMLConfigurationBackwardsCompatibilityTest .GWC_125_CONFIG_FILE))); } catch (Exception e) { // Do nothing } return xmlConfig; }
private XMLConfiguration loadXMLConfig() { XMLConfiguration xmlConfig = null; try { xmlConfig = new XMLConfiguration( null, new MockConfigurationResourceProvider( () -> XMLConfiguration.class.getResourceAsStream( XMLConfigurationBackwardsCompatibilityTest .GWC_125_CONFIG_FILE))); } catch (Exception e) { // Do nothing } return xmlConfig; } }
private XMLConfiguration loadXMLConfig() { XMLConfiguration xmlConfig = null; try { xmlConfig = new XMLConfiguration( null, new MockConfigurationResourceProvider( () -> XMLConfiguration.class.getResourceAsStream( XMLConfigurationBackwardsCompatibilityTest .GWC_125_CONFIG_FILE))); } catch (Exception e) { // Do nothing } return xmlConfig; } }
private void loadSavedConfig() { try { XMLConfiguration configLoad = new XMLConfiguration(context, configDir.getAbsolutePath(), null); GridSetBroker gridSetBroker = new GridSetBroker(true, true); configLoad.setGridSetBroker(gridSetBroker); configLoad.afterPropertiesSet(); createFromSavedConfig(configLoad); } catch (StorageException | GeoWebCacheException e) { log.error(e.getMessage()); fail("Error loading from " + configFile + " " + e.getMessage()); } }
@Override public void resetConfiguration() throws Exception { if (configFile != null) { URL source = XMLConfiguration.class.getResource("geowebcache-empty.xml"); FileUtils.copyURLToFile(source, configFile); } config = new XMLConfiguration(null, configDir.getAbsolutePath()); broker = new GridSetBroker(getGridSetConfigurations()); config.setGridSetBroker(broker); config.deinitialize(); config.reinitialize(); }
@Test public void testPathAsArgumentCreate() throws Exception { ServerConfiguration config = new XMLConfiguration(provider, configDir.getCanonicalPath()); ((XMLConfiguration) config).setGridSetBroker(broker); config.afterPropertiesSet(); assertThat(configFile(cacheDir).exists(), is(false)); assertThat(configFile(configDir).exists(), is(true)); } }
private void setupXMLConfig() throws IOException, GeoWebCacheException { configDir = temp.getRoot(); configFile = temp.newFile("geowebcache.xml"); URL source = XMLConfiguration.class.getResource( XMLConfigurationBackwardsCompatibilityTest.LATEST_FILENAME); FileUtils.copyURLToFile(source, configFile); providers = new HashMap<String, XMLConfigurationProvider>(); Mockito.when(context.getApplicationContext()).thenReturn(webCtx, webCtx, webCtx, webCtx); Mockito.when(webCtx.getBeansOfType(XMLConfigurationProvider.class)) .thenReturn(providers, providers); S3BlobStoreConfigProvider provider = new S3BlobStoreConfigProvider(); Mockito.when(webCtx.getBean("S3BlobStore")).thenReturn(provider, provider); providers.put("S3BlobStore", provider); GridSetBroker gridSetBroker = new GridSetBroker(true, true); config = new XMLConfiguration(context, configDir.getAbsolutePath()); config.setGridSetBroker(gridSetBroker); config.afterPropertiesSet(); } }
@Test public void testOverrideWithPropertyCreate() throws Exception { gwcConfigDirProp.setValue(configDir.getCanonicalPath()); ServerConfiguration config = new XMLConfiguration(provider, storageFinder); ((XMLConfiguration) config).setGridSetBroker(broker); config.afterPropertiesSet(); assertThat(configFile(cacheDir).exists(), is(false)); assertThat(configFile(configDir).exists(), is(true)); }
private XMLConfiguration loadXMLConfig() { XMLConfiguration xmlConfig = null; try { xmlConfig = new XMLConfiguration( context.getContextProvider(), new MockConfigurationResourceProvider( () -> XMLConfiguration.class.getResourceAsStream( XMLConfigurationBackwardsCompatibilityTest .LATEST_FILENAME))); } catch (Exception e) { // Do nothing } return xmlConfig; }
@Test public void testDefaultToCacheDirCreate() throws Exception { ServerConfiguration config = new XMLConfiguration(provider, storageFinder); ((XMLConfiguration) config).setGridSetBroker(broker); config.afterPropertiesSet(); assertThat(configFile(cacheDir).exists(), is(true)); assertThat(configFile(configDir).exists(), is(false)); }
@Before public void setUp() throws Exception { configDir = temp.getRoot(); configFile = temp.newFile("geowebcache.xml"); URL source = XMLConfiguration.class.getResource( XMLConfigurationBackwardsCompatibilityTest.LATEST_FILENAME); FileUtils.copyURLToFile(source, configFile); gridSetBroker = new GridSetBroker(true, true); config = new XMLConfiguration(null, configDir.getAbsolutePath()); config.setGridSetBroker(gridSetBroker); config.afterPropertiesSet(); }
@Test public void testPathAsArgument() throws Exception { shouldLoadFrom(configDir); shouldNotLoadFrom(cacheDir); XMLConfiguration config = new XMLConfiguration(provider, configDir.getCanonicalPath()); config.setGridSetBroker(broker); config.afterPropertiesSet(); assertThat(config.getLayer(MARKED_LAYER), notNullValue()); }
/** * Tests {@link XMLConfiguration} persistence by initializing a configuration, constructing a * new configuration from the resulting geowebcache.xml, and validating some basic assumptions * about the new config. * * @throws Exception */ @Test public void testXMLConfiguration() throws Exception { GWCXMLConfigIntegrationTestSupport testSupport = new GWCXMLConfigIntegrationTestSupport(); GWCConfigIntegrationTestData.setUpTestData(testSupport); File configDirCopy = Files.createTempDirectory("gwc").toFile(); File configFileCopy = new File(configDirCopy, "geowebcache.xml"); configDirCopy.deleteOnExit(); FileUtils.copyFile(testSupport.configFile, configFileCopy); XMLConfiguration configCopy = new XMLConfiguration(null, configDirCopy.getAbsolutePath()); configCopy.setGridSetBroker(new GridSetBroker(true, true)); configCopy.afterPropertiesSet(); assertTileLayerConfiguration(configCopy); assertGridSetConfiguration(configCopy); assertBlobStoreConfiguration(configCopy); }
protected ServerConfiguration getConfig() throws Exception { if (configFile == null) { // create a temp XML config configDir = temp.getRoot(); configFile = temp.newFile(XMLConfiguration.DEFAULT_CONFIGURATION_FILE_NAME); // copy the example XML to the temp config file URL source = XMLConfiguration.class.getResource("geowebcache_190.xml"); FileUtils.copyURLToFile(source, configFile); } // initialize the config with an XMLFileResourceProvider that uses the temp config file gridSetBroker = new GridSetBroker(true, true); ConfigurationResourceProvider configProvider = new XMLFileResourceProvider( XMLConfiguration.DEFAULT_CONFIGURATION_FILE_NAME, (WebApplicationContext) null, configDir.getAbsolutePath(), null); config = new XMLConfiguration(null, configProvider); ((XMLConfiguration) config).setGridSetBroker(gridSetBroker); config.afterPropertiesSet(); return config; } }
private XMLConfiguration loadConfig(String fileName) throws Exception { try (InputStream is = XMLConfiguration.class.getResourceAsStream(fileName); ) { Node root = XMLConfiguration.loadDocument(is); print(root.getOwnerDocument()); } XMLConfiguration xmlConfig = new XMLConfiguration( null, new MockConfigurationResourceProvider( () -> XMLConfiguration.class.getResourceAsStream(fileName))); GridSetBroker gsb = new GridSetBroker(Arrays.asList(new DefaultGridsets(true, true), xmlConfig)); xmlConfig.setGridSetBroker(gsb); xmlConfig.afterPropertiesSet(); Iterator<TileLayer> iter = xmlConfig.getLayers().iterator(); while (iter.hasNext()) { TileLayer layer = iter.next(); layer.initialize(gsb); } return xmlConfig; }
@Test public void testDefaultToCacheDir() throws Exception { shouldLoadFrom(cacheDir); XMLConfiguration config = new XMLConfiguration(provider, storageFinder); config.setGridSetBroker(broker); config.afterPropertiesSet(); config.getLayerCount(); assertThat(config.getLayer(MARKED_LAYER), notNullValue()); }
@Test public void testOverrideWithProperty() throws Exception { shouldLoadFrom(configDir); shouldNotLoadFrom(cacheDir); gwcConfigDirProp.setValue(configDir.getCanonicalPath()); XMLConfiguration config = new XMLConfiguration(provider, storageFinder); config.setGridSetBroker(broker); config.afterPropertiesSet(); config.getLayerCount(); assertThat(config.getLayer(MARKED_LAYER), notNullValue()); }
@Test public void testOverrideWithPropertyRelative() throws Exception { shouldLoadFrom(configDir); shouldNotLoadFrom(cacheDir); gwcConfigDirProp.setValue(configDir.getName()); XMLConfiguration config = new XMLConfiguration(provider, storageFinder); config.setGridSetBroker(broker); config.afterPropertiesSet(); config.getLayerCount(); assertThat(config.getLayer(MARKED_LAYER), notNullValue()); }