@Before public void setUp() throws Exception { sb = mock(StorageBroker.class); tld = mock(TileLayerDispatcher.class); gridsetBroker = new GridSetBroker(true, true); }
@Before public void setupBroker() { if (broker == null) { broker = new GridSetBroker(false, false); } }
@Before public void setupBroker() { if (broker == null) { broker = new GridSetBroker(false, false); } }
@Before public void setUp() throws Exception { sb = mock(StorageBroker.class); tld = mock(TileLayerDispatcher.class); gridsetBroker = new GridSetBroker(true, true); }
public void setUp() { RasterMaskTestUtils.debugToDisk = debugToDisk; layer = TestUtils.createWMSLayer( "image/png", new GridSetBroker(false, false), 3, 3, new BoundingBox(-180, -90, 180, 90)); gridsetId = layer.getGridSubsets().iterator().next(); }
@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(); }
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()); } }
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(); } }
public void setUp() { RasterMaskTestUtils.debugToDisk = debugToDisk; layer = TestUtils.createWMSLayer( "image/png", new GridSetBroker(false, false), 3, 3, new BoundingBox(-180, -90, 180, 90)); gridsetId = layer.getGridSubsets().iterator().next(); fullCoverage = layer.getGridSubset(gridsetId).getCoverages(); }
public void testLayerGroupInfoLayersChanged() throws Exception { CatalogModifyEvent modifyEvent = mock(CatalogModifyEvent.class); when(modifyEvent.getSource()).thenReturn(mockLayerGroupInfo); when(modifyEvent.getPropertyNames()).thenReturn(Arrays.asList("layers")); List<LayerInfo> oldLayers = Collections.emptyList(); List<LayerInfo> newLayers = Collections.singletonList(mockLayerInfo); when(modifyEvent.getOldValues()).thenReturn(Collections.singletonList((Object) oldLayers)); when(modifyEvent.getNewValues()).thenReturn(Collections.singletonList((Object) newLayers)); // the tile layer must exist otherwise the event will be ignored GeoServerTileLayerInfo tileLayerInfo = TileLayerInfoUtil.loadOrCreate(mockLayerGroupInfo, mockMediator.getConfig()); GridSetBroker gridsets = new GridSetBroker(true, true); GeoServerTileLayer tileLayer = new GeoServerTileLayer(mockLayerGroupInfo, gridsets, tileLayerInfo); when(mockMediator.hasTileLayer(same(mockLayerGroupInfo))).thenReturn(true); when(mockMediator.getTileLayer(same(mockLayerGroupInfo))).thenReturn(tileLayer); listener.handleModifyEvent(modifyEvent); CatalogPostModifyEvent postModifyEvent = mock(CatalogPostModifyEvent.class); when(postModifyEvent.getSource()).thenReturn(mockLayerGroupInfo); listener.handlePostModifyEvent(postModifyEvent); verify(mockMediator).truncate(eq(LAYER_GROUP_NAME)); }
@Before public void setUp() throws Exception { configDir = temp.newFolder("config"); cacheDir = temp.newFolder("cache"); provider = createMock(ApplicationContextProvider.class); appContext = createMock(WebApplicationContext.class); svltContext = createMock(ServletContext.class); storageFinder = createMock(DefaultStorageFinder.class); broker = new GridSetBroker(false, false); expect(provider.getApplicationContext()).andStubReturn(appContext); expect(appContext.getServletContext()).andStubReturn(svltContext); expect(svltContext.getInitParameter((String) anyObject())).andStubReturn(null); expect(storageFinder.getDefaultPath()).andStubReturn(cacheDir.getCanonicalPath()); expect(appContext.getBeansOfType(org.geowebcache.config.XMLConfigurationProvider.class)) .andReturn(Collections.emptyMap()); expect(svltContext.getRealPath("")).andStubReturn(temp.getRoot().getCanonicalPath()); replay(provider, appContext, svltContext, storageFinder); }
@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(); }
@Override protected void setUp() throws Exception { catalog = mock(Catalog.class); layer = mockLayer("testLayer", new String[]{"style1", "style2"}, LayerInfo.Type.RASTER); layerGroup = mockGroup("testGroup", layer); mockCatalog(); defaults = GWCConfig.getOldDefaults(); gwcConfigPersister = mock(GWCConfigPersister.class); when(gwcConfigPersister.getConfig()).thenReturn(defaults); storageBroker = mock(StorageBroker.class); gridSetBroker = new GridSetBroker(true, true); tileLayerInfo = TileLayerInfoUtil.loadOrCreate(layer, defaults); tileLayerGroupInfo = TileLayerInfoUtil.loadOrCreate(layerGroup, defaults); tileLayer = new GeoServerTileLayer(layer, gridSetBroker, tileLayerInfo); tileLayerGroup = new GeoServerTileLayer(layerGroup, gridSetBroker, tileLayerGroupInfo); tld = mock(TileLayerDispatcher.class); mockTileLayerDispatcher(); config = mock(Configuration.class); tileBreeder = mock(TileBreeder.class); quotaStore = mock(QuotaStore.class); diskQuotaMonitor = mock(DiskQuotaMonitor.class); owsDispatcher = mock(Dispatcher.class); mediator = new GWC(gwcConfigPersister, storageBroker, tld, gridSetBroker, tileBreeder, quotaStore, diskQuotaMonitor, owsDispatcher, catalog); GWC.set(mediator); }
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; } }
/** * 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); }
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; }
@Before public void setUp() throws Exception { server = createNiceMock(WebMapServer.class); cap = createNiceMock(WMSCapabilities.class); req = createNiceMock(WMSRequest.class); gcOpType = createNiceMock(OperationType.class); globalConfig = createNiceMock(DefaultingConfiguration.class); layerCapture = new Capture<TileLayer>(); broker = new GridSetBroker(false, false); expect(server.getCapabilities()).andStubReturn(cap); expect(cap.getRequest()).andStubReturn(req); expect(req.getGetCapabilities()).andStubReturn(gcOpType); expect(gcOpType.getGet()) .andStubReturn( new URL( "http://test/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities")); expect(cap.getVersion()).andStubReturn("1.1.1"); }
@Before public void setup() throws GeoWebCacheException { GridSetBroker gridSetBroker = new GridSetBroker(false, false); XMLConfiguration xmlConfig = loadXMLConfig(); xmlConfig.setGridSetBroker(gridSetBroker); xmlConfig.afterPropertiesSet(); mtc = new MassTruncateController(null); this.mockMvc = MockMvcBuilders.standaloneSetup(mtc).build(); }
@Before public void setup() throws GeoWebCacheException { GridSetBroker gridSetBroker = new GridSetBroker(false, false); XMLConfiguration xmlConfig = loadXMLConfig(); xmlConfig.setGridSetBroker(gridSetBroker); xmlConfig.afterPropertiesSet(); mcc = new MemoryCacheController(null); this.mockMvc = MockMvcBuilders.standaloneSetup(mcc).build(); }
@Test public void testDefaultMercatorGridSet() throws Exception { // setup GridSet defaults that use legacy names (i.e. use EPSG:######) final DefaultGridsets defaultGridSets = new DefaultGridsets(false, true); // create a GirdSetBroker with the defaults final GridSetBroker broker = new GridSetBroker(Arrays.asList(defaultGridSets)); // make sure EPSG:3857 is available and is the mercator default GridSet epsg3857GridSet = broker.get("EPSG:3857"); assertNotNull("GridSetBroker missing EPSG:3857 GridSet", epsg3857GridSet); // make sure GoogleMapsCompatible is NOT in the defaults GridSet googleMapsCompatible = broker.get("GoogleMapsCompatible"); assertNull("Unexpected GoogleMapsCompatible GridSet found", googleMapsCompatible); // make sure EPSG:900913 is NOT in the defaults GridSet epsg900913GridSet = broker.get("EPSG:900913"); assertNull("Unexpected EPSG:900913 GridSet found", epsg900913GridSet); // get the default mercator gridset and make sure it matches the EPSG:3857 gridset GridSet defaultMercatorGridSet = broker.getWorldEpsg3857(); assertNotNull("GridSetBroker missing default mercator GridSet", defaultMercatorGridSet); assertEquals( "Unexpected default mercator GridSet", epsg3857GridSet, defaultMercatorGridSet); }