@Override public @Nullable ZoomContext get(String name) { GridSet set = broker.get(name); if(set!=null) { return new GWCZoomContext(set); } else { return null; } }
@Test public void testRemoveGridsetOld() throws IOException { String gridsetToRemove = GWCConfigIntegrationTestData.GRIDSET_EPSG2163; // remove the only layer referencing the gridset first gridSetBroker.remove(gridsetToRemove); assertFalse(gridSetBroker.getNames().contains(gridsetToRemove)); assertNull(gridSetBroker.get(gridsetToRemove)); }
@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); }
@RequestMapping( path = "/{gridSetName}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE } ) public GridSet gridSetGet(@PathVariable String gridSetName) { if (broker.get(gridSetName) != null) { return broker.get(gridSetName); } else { throw new RestException( String.format( "Failed to get GridSet. A GridSet with name \"%s\" does not exist.", gridSetName), HttpStatus.NOT_FOUND); } }
@Test public void testRemoveGridset() throws IOException { String gridsetToRemove = GWCConfigIntegrationTestData.GRIDSET_EPSG2163; // remove the only layer referencing the gridset first tileLayerDispatcher.removeLayer(GWCConfigIntegrationTestData.LAYER_TOPP_STATES); tileLayerDispatcher.removeGridSet(gridsetToRemove); assertFalse(gridSetBroker.getNames().contains(gridsetToRemove)); assertNull(gridSetBroker.get(gridsetToRemove)); }
@RequestMapping(path = "/{gridSetName}", method = RequestMethod.DELETE) public void gridSetDelete(@PathVariable String gridSetName) { if (broker.get(gridSetName) != null) { broker.removeGridSet(gridSetName); } else { throw new RestException( String.format( "Failed to remove GridSet. A GridSet with name \"%s\" does not exist.", gridSetName), HttpStatus.NOT_FOUND); } } }
@Test public void testAddGridset() throws GeoWebCacheException, IOException { String gridsetName = "EPSG:3005"; GridSet epsg3005 = GridSetFactory.createGridSet( gridsetName, SRS.getSRS(gridsetName), new BoundingBox(35043.6538, 440006.8768, 1885895.3117, 1735643.8497), false, null, new double[] {25000000, 1250000, 500000, 250000}, null, GridSetFactory.DEFAULT_PIXEL_SIZE_METER, null, 256, 256, false); gridSetBroker.addGridSet(epsg3005); assertTrue(gridSetBroker.getNames().contains(gridsetName)); assertEquals(gridSetBroker.get(gridsetName), epsg3005); }
@RequestMapping( path = "/{gridSetName}", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE } ) public ResponseEntity<?> gridSetPut( @PathVariable String gridSetName, @RequestBody GridSet gridSet) { if (broker.get(gridSetName) != null) { broker.put(gridSet); } else { broker.addGridSet(gridSet); return new ResponseEntity<Object>("", HttpStatus.CREATED); } return null; }
@Test public void testAddGridset() throws GeoWebCacheException, IOException { String gridsetName = "EPSG:3005"; GridSet epsg3005 = GridSetFactory.createGridSet( gridsetName, SRS.getSRS(gridsetName), new BoundingBox(35043.6538, 440006.8768, 1885895.3117, 1735643.8497), false, null, new double[] {25000000, 1250000, 500000, 250000}, null, GridSetFactory.DEFAULT_PIXEL_SIZE_METER, null, 256, 256, false); tileLayerDispatcher.addGridSet(epsg3005); assertTrue(gridSetBroker.getNames().contains(gridsetName)); assertEquals(gridSetBroker.get(gridsetName), epsg3005); }
public synchronized void addGridSet(final GridSet gridSet) throws IllegalArgumentException, IOException { if (null != gridSetBroker.get(gridSet.getName())) { throw new IllegalArgumentException("GridSet " + gridSet.getName() + " already exists"); } saveGridSet(gridSet); }
@Test public void testGetNotPresentGridsetOld() throws IOException { GridSet existingGridSet = gridSetBroker.get("DOESNOTEXIST"); assertThat(existingGridSet, nullValue()); }
public GridSubset getGridSubSet(GridSetBroker gridSetBroker) { GridSet gridSet = gridSetBroker.get(getGridSetName()); if (gridSet == null) { log.error("Unable to find GridSet for \"" + getGridSetName() + "\""); return null; } return GridSubsetFactory.createGridSubSet( gridSet, getExtent(), getZoomStart(), getZoomStop(), minCachedLevel, maxCachedLevel); }
static class CustomLayerImplementation { private String name; private String title; private boolean isAuthorized; private List<String> formats; public CustomLayerImplementation( String name, String title, boolean isAuthorized, List<String> formats) { this.name = name; this.title = title; this.isAuthorized = isAuthorized; this.formats = formats; } }
@Test public void testGetDefaultGridsetOld() throws IOException { GridSet existingGridSet = gridSetBroker.get(GWCConfigIntegrationTestData.GRIDSET_EPSG4326); assertThat( existingGridSet, hasProperty("name", equalTo(GWCConfigIntegrationTestData.GRIDSET_EPSG4326))); }
@Test public void testGetGridsetOld() throws IOException { GridSet existingGridSet = gridSetBroker.get(GWCConfigIntegrationTestData.GRIDSET_EPSG2163); assertThat( existingGridSet, hasProperty("name", equalTo(GWCConfigIntegrationTestData.GRIDSET_EPSG2163))); }
@Test public void testScalePastEnd() throws Exception { GridSetBroker broker = createMock(GridSetBroker.class); GridSet set = createMock(GridSet.class); expect(broker.get("test")).andStubReturn(set); expect(set.getNumLevels()).andStubReturn(5); replay(broker, set); ZoomContextFinder finder = new GWCZoomContextFinder(broker); ZoomContext zContext = finder.get("test"); double denom = zContext.getScaleDenominator(5); assertThat(denom, is(0d)); verify(broker, set); }
@Test public void testScaleNegativeLevel() throws Exception { GridSetBroker broker = createMock(GridSetBroker.class); GridSet set = createMock(GridSet.class); expect(broker.get("test")).andStubReturn(set); expect(set.getNumLevels()).andStubReturn(5); replay(broker, set); ZoomContextFinder finder = new GWCZoomContextFinder(broker); ZoomContext zContext = finder.get("test"); double denom = zContext.getScaleDenominator(-1); assertThat(denom, is(Double.POSITIVE_INFINITY)); verify(broker, set); }
@Test public void testAddBadGridset() throws IOException { // existing GridSet existingGridSet = gridSetBroker.get(GWCConfigIntegrationTestData.GRIDSET_EPSG2163); try { gridSetBroker.addGridSet(existingGridSet); fail("Expected exception adding existing gridset"); } catch (IllegalArgumentException e) { } try { gridSetBroker.addGridSet(null); fail("Expected exception adding null gridset"); } catch (NullPointerException e) { } }
@Test public void testAddBadGridset() throws IOException { // existing GridSet existingGridSet = gridSetBroker.get(GWCConfigIntegrationTestData.GRIDSET_EPSG2163); try { tileLayerDispatcher.addGridSet(existingGridSet); fail("Expected exception adding existing gridset"); } catch (IllegalArgumentException e) { } try { tileLayerDispatcher.addGridSet(null); fail("Expected exception adding null gridset"); } catch (NullPointerException e) { } }
public void testModifyGridsetPreconditions() throws Exception { GridSet oldGridset = gridSetBroker.get("EPSG:4326"); try { mediator.modifyGridSet(null, oldGridset); fail(); } catch (NullPointerException e) { assertTrue(true); } try { mediator.modifyGridSet("oldname", null); fail(); } catch (NullPointerException e) { assertTrue(true); } try { mediator.modifyGridSet("wrongOldName", oldGridset); fail(); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("does not exist")); } }