@Before public void setupMockService() throws Exception { this.storageBroker = mock(StorageBroker.class); this.tileLayerDispatcher = tileLayerDispatcher(); this.runtimeStats = mock(RuntimeStats.class); this.wmtsService = new WMTSService(storageBroker, tileLayerDispatcher, broker, runtimeStats); this.securityDispatcher = securityDispatcher(); wmtsService.setSecurityDispatcher(securityDispatcher); }
return getRestConveyor(request, response); Map<String, String> values = ServletUtils.selectedStringsFromMap(request.getParameterMap(), encoding, keys); return getKvpConveyor(request, response, values);
/** Helper method that just executes the provided test with CITE validation activated. */ private void testCiteValidationIsSuccessful(TestToExecute request) throws Exception { // mock server configuration to activate CITE compliance checks ServerConfiguration configuration = mock(ServerConfiguration.class); when(configuration.isWmtsCiteCompliant()).thenReturn(true); ServerConfiguration previousConfiguration = wmtsService.getMainConfiguration(); wmtsService.setMainConfiguration(configuration); try { // the following test should be successful request.execute(); } finally { // set whatever was the previous server configuration used by WMTS service wmtsService.setMainConfiguration(previousConfiguration); } }
boolean isCitecompliant = isCiteCompliant(); if (isCitecompliant) { performCiteValidation(request); String acceptedVersions = getParameterValue("AcceptVersions", request); boolean isRestRequest = isRestRequest(request); if (!isRestRequest && getParameterValue("Style", request) == null) { ConveyorTile tile = getTile(values, request, response, RequestType.TILE); return tile; } else if (req.equals("getcapabilities")) { return tile; } else if (req.equals("getfeatureinfo")) { ConveyorTile tile = getTile(values, request, response, RequestType.FEATUREINFO); tile.setHint(req); tile.setRequestHandler(Conveyor.RequestHandler.SERVICE);
new WMTSService(sb, tld, gsb, mock(RuntimeStats.class), new NullURLMangler(), gwcd); service.setSecurityDispatcher(secDisp); when(subset.getCoverage(2)).thenReturn(new long[] {1, 1, 8, 8}); Conveyor conv = service.getConveyor(req, resp); assertThat(conv, hasProperty("requestHandler", is(RequestHandler.SERVICE))); service.handleRequest(conv);
when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Conveyor conv = service.getConveyor(req, resp); assertNotNull(conv);
service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); @SuppressWarnings("unchecked") Map<String, String[]> kvp = new CaseInsensitiveMap(); when(req.getParameterMap()).thenReturn(kvp); service.addExtension( new WMTSExtensionImpl() { Conveyor conveyor = service.getConveyor(req, resp); assertThat(conveyor, notNullValue()); service.handleRequest(conveyor); assertThat(resp.getContentAsString(), is("CustomOperation Result"));
public MockHttpServletResponse dispatch(MockHttpServletRequest req) throws Exception { MockHttpServletResponse resp = new MockHttpServletResponse(); try { final Conveyor conveyor = wmtsService.getConveyor(req, resp); if (conveyor.reqHandler == Conveyor.RequestHandler.SERVICE) { wmtsService.handleRequest(conveyor); } else { ResponseUtils.writeTile( securityDispatcher(), conveyor, conveyor.getLayerId(), tileLayerDispatcher(), null, runtimeStats); } } catch (OWSException e) { ResponseUtils.writeFixedResponse( resp, e.getResponseCode(), e.getContentType(), e.getResponse(), Conveyor.CacheResult.OTHER, runtimeStats); } return resp; }
String requestedServiceName = getParameterValue("SERVICE", request); if (requestedServiceName == null) {
public Conveyor getRestConveyor(HttpServletRequest request, HttpServletResponse response) throws GeoWebCacheException, OWSException { final String path = request.getPathInfo(); // special simpler case for GetCapabilities if (path.endsWith("/service/wmts/rest/WMTSCapabilities.xml")) { ConveyorTile tile = new ConveyorTile(sb, null, request, response); tile.setHint(GET_CAPABILITIES); tile.setRequestHandler(ConveyorTile.RequestHandler.SERVICE); return tile; } // all other paths are handled via the RestRequest enumeration, matching patterns and // extracting variables for (RestRequest restRequest : RestRequest.values()) { Map<String, String> values = restRequest.toKVP(request); if (values != null) { return getKvpConveyor(request, response, values); } } // we implement all WMTS supported request, this means that the provided request name is // invalid throw new HttpErrorCodeException(404, "Unknown resource " + request.getPathInfo()); }
getSecurityDispatcher().checkSecurity(tile); ConveyorTile convTile = (ConveyorTile) conv; WMTSGetFeatureInfo wmsGFI = new WMTSGetFeatureInfo(convTile);
new WMTSService(sb, tld, gsb, mock(RuntimeStats.class), new NullURLMangler(), gwcd); service.setSecurityDispatcher(secDisp); when(subset.getCoverage(2)).thenReturn(new long[] {1, 1, 8, 8}); Conveyor conv = service.getConveyor(req, resp); service.handleRequest(conv); fail("Expected SecurityException"); } catch (SecurityException ex) {
when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Conveyor conv = service.getConveyor(req, resp); assertNotNull(conv);
when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Conveyor conv = service.getConveyor(req, resp); assertNotNull(conv);
when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Conveyor conv = service.getConveyor(req, resp); assertNotNull(conv);
when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Conveyor conv = service.getConveyor(req, resp); assertNotNull(conv);
service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); extensions.forEach(service::addExtension); @SuppressWarnings("unchecked") mockTileLayer("mockLayer", gridSetNames, Collections.<ParameterFilter>emptyList()); when(tld.getLayerList()).thenReturn(Collections.singletonList(tileLayer)); Conveyor conv = service.getConveyor(req, resp); assertNotNull(conv); assertEquals(Conveyor.RequestHandler.SERVICE, conv.reqHandler);
when(gwcd.getServletPrefix()).thenReturn(null); service = new WMTSService(sb, tld, null, mock(RuntimeStats.class)); Conveyor conv = service.getConveyor(req, resp); assertNotNull(conv);