Source:
public void testOverrideGridSetDefaults() throws Exception { URL source = XMLConfiguration.class.getResource("geowebcache_4326_override.xml"); FileUtils.copyURLToFile(source, configFile); XMLConfiguration config2 = new XMLConfiguration(null, configDir.getAbsolutePath()); final DefaultGridsets defaultGridSets = new DefaultGridsets(true, true); gridSetBroker = new GridSetBroker(Arrays.asList(defaultGridSets)); config2.setGridSetBroker(gridSetBroker); ApplicationContext appContext = createMock(ApplicationContext.class); final HashMap<String, GridSetConfiguration> beans = new HashMap<>(2); beans.put("defaultGridSets", defaultGridSets); beans.put("xmlConfig", config2); expect(appContext.getBeansOfType(GridSetConfiguration.class)).andReturn(beans); expect(appContext.getBean("defaultGridSets")).andReturn(defaultGridSets); expect(appContext.getBean("xmlConfig")).andReturn(config2); replay(appContext); GeoWebCacheExtensions gwcExtensions = new GeoWebCacheExtensions(); gwcExtensions.setApplicationContext(appContext); GridSet override4326 = gridSetBroker.get("EPSG:4326"); assertNotNull(override4326); GridSet worldEpsg4326 = defaultGridSets.worldEpsg4326(); assertEquals("Unexpected number of Default EPSG:4326 reslution levels", 22, worldEpsg4326.getNumLevels()); assertEquals("Unexpected number of Overriden EPSG:4326 reslution levels", 14, override4326.getNumLevels()); final Grid overrideLevel = override4326.getGrid(0); final Grid defaultLevel = worldEpsg4326.getGrid(0); assertEquals("Unexpected default resolution level 0", 0.703125, defaultLevel.getResolution(), 0d); assertEquals("Unexpected override resolution level 0", 1.40625, overrideLevel.getResolution(), 0d); final String overrideDescription = override4326.getDescription(); final String defaultDescription = worldEpsg4326.getDescription(); assertFalse("Default EPSG:4326 GridSet description should not contain 'OVERRIDE'", defaultDescription.contains( "OVERRIDE")); assertTrue("Overriden EPSG:4326 GridSet description should contain 'OVERRIDE'", overrideDescription.contains( "OVERRIDE")); }

Target:
public void testOverrideGridSetDefaults() throws Exception { URL source = XMLConfiguration.class.getResource("geowebcache_4326_override.xml"); FileUtils.copyURLToFile(source, configFile); XMLConfiguration config2 = new XMLConfiguration(null, configDir.getAbsolutePath()); final DefaultGridsets defaultGridSets = new DefaultGridsets(true, true); gridSetBroker = new GridSetBroker(Arrays.asList(defaultGridSets)); config2.setGridSetBroker(gridSetBroker); ApplicationContext appContext = createMock(ApplicationContext.class); final HashMap<String, GridSetConfiguration> beans = new HashMap<>(2); beans.put("defaultGridSets", defaultGridSets); beans.put("xmlConfig", config2); expect(appContext.getBeansOfType(GridSetConfiguration.class)).andReturn(beans); expect(appContext.getBean("defaultGridSets")).andReturn(defaultGridSets); expect(appContext.getBean("xmlConfig")).andReturn(config2); replay(appContext); GeoWebCacheExtensions gwcExtensions = new GeoWebCacheExtensions(); gwcExtensions.setApplicationContext(appContext); GridSet override4326 = gridSetBroker.get("EPSG:4326"); assertNotNull(override4326); GridSet worldEpsg4326 = gridSetBroker.getWorldEpsg4326(); assertNotNull(worldEpsg4326); assertEquals(override4326, worldEpsg4326); GridSet internal4326 = defaultGridSets.worldEpsg4326(); assertEquals("Unexpected number of Default EPSG:4326 resolution levels", 22, internal4326.getNumLevels()); assertEquals("Unexpected number of Overriden EPSG:4326 resolution levels", 14, override4326.getNumLevels()); final Grid overrideLevel = override4326.getGrid(0); final Grid defaultLevel = internal4326.getGrid(0); assertEquals("Unexpected default resolution level 0", 0.703125, defaultLevel.getResolution(), 0d); assertEquals("Unexpected override resolution level 0", 1.40625, overrideLevel.getResolution(), 0d); final String overrideDescription = override4326.getDescription(); final String defaultDescription = internal4326.getDescription(); assertFalse("Default EPSG:4326 GridSet description should not contain 'OVERRIDE'", defaultDescription.contains( "OVERRIDE")); assertTrue("Overriden EPSG:4326 GridSet description should contain 'OVERRIDE'", overrideDescription.contains( "OVERRIDE")); }