@SuppressWarnings("rawtypes") @Override public Object read(Object request, Reader reader, Map kvp) throws Exception { // instantiante parsers and content handlers GetCapabilitiesRequest req = new GetCapabilitiesRequest(); CapabilitiesHandler currentRequest = new CapabilitiesHandler(req); currentRequest.setEntityResolver(resolverProvider.getEntityResolver()); // read in XML file and parse to content handler try { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); ParserAdapter adapter = new ParserAdapter(parser.getParser()); adapter.setEntityResolver(resolverProvider.getEntityResolver()); adapter.setContentHandler(currentRequest); adapter.parse(new InputSource(reader)); } catch (SAXException e) { throw new ServiceException( e, "XML capabilities request parsing error", getClass().getName()); } catch (IOException e) { throw new ServiceException( e, "XML capabilities request input error", getClass().getName()); } catch (ParserConfigurationException e) { throw new ServiceException( e, "Some sort of issue creating parser", getClass().getName()); } return req; }
@Before public void internalSetUp() throws IOException { this.catalog = getCatalog(); geosConfig = new GeoServerImpl(); geosInfo = new GeoServerInfoImpl(geosConfig); geosInfo.setContact(new ContactInfoImpl()); geosConfig.setGlobal(geosInfo); wmsInfo = new WMSInfoImpl(); geosConfig.add(wmsInfo); geosConfig.setCatalog(catalog); wmsConfig = new WMS(geosConfig); wmsConfig.setApplicationContext(applicationContext); req = new GetCapabilitiesRequest(); req.setBaseUrl(baseUrl); getTestData() .copyTo( getClass().getResourceAsStream("/legendURL/BasicPolygons.png"), LegendSampleImpl.LEGEND_SAMPLES_FOLDER + "/BasicPolygons.png"); getTestData() .copyTo( getClass().getResourceAsStream("/legendURL/Bridges.png"), LegendSampleImpl.LEGEND_SAMPLES_FOLDER + "/Bridges.png"); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); namespaces.put("wms", "http://www.opengis.net/wms"); namespaces.put("ows", "http://www.opengis.net/ows"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); XPATH = XMLUnit.newXpathEngine(); }
wms.getAllowedMapFormats(), new HashSet<ExtendedCapabilitiesProvider>()); GetCapabilitiesRequest req = new GetCapabilitiesRequest(); req.setBaseUrl(BASE_URL); req.setVersion(WMS.VERSION_1_3_0.toString());
/** * Retrieves the WMS's capabilities document. * * @param scaleHintUnitsPerDiaPixel true if the scalehint must be in units per diagonal of a * pixel * @return Capabilities as {@link Document} */ private Document findCapabilities(Boolean scaleHintUnitsPerDiaPixel) throws Exception { // set the Scalehint units per diagonal pixel setting. WMS wms = getWMS(); WMSInfo info = wms.getServiceInfo(); MetadataMap mm = info.getMetadata(); mm.put(WMS.SCALEHINT_MAPUNITS_PIXEL, scaleHintUnitsPerDiaPixel); info.getGeoServer().save(info); Capabilities_1_3_0_Transformer tr = new Capabilities_1_3_0_Transformer( wms, BASE_URL, wms.getAllowedMapFormats(), new HashSet<ExtendedCapabilitiesProvider>()); GetCapabilitiesRequest req = new GetCapabilitiesRequest(); req.setBaseUrl(BASE_URL); req.setVersion(WMS.VERSION_1_3_0.toString()); Document dom = WMSTestSupport.transform(req, tr); Element root = dom.getDocumentElement(); assertEquals(WMS.VERSION_1_3_0.toString(), root.getAttribute("version")); return dom; }
/** * Retrieves the WMS's capabilities document. * * @param scaleHintUnitsPerDiaPixel true if the scalehint must be in units per diagonal of a * pixel * @return Capabilities as {@link Document} */ private Document findCapabilities(Boolean scaleHintUnitsPerDiaPixel) throws Exception { // set the Scalehint units per diagonal pixel setting. WMS wms = getWMS(); WMSInfo info = wms.getServiceInfo(); info.setRootLayerTitle("test the title"); MetadataMap mm = info.getMetadata(); mm.put(WMS.SCALEHINT_MAPUNITS_PIXEL, scaleHintUnitsPerDiaPixel); info.getGeoServer().save(info); Capabilities_1_3_0_Transformer tr = new Capabilities_1_3_0_Transformer( wms, BASE_URL, wms.getAllowedMapFormats(), new HashSet<ExtendedCapabilitiesProvider>()); GetCapabilitiesRequest req = new GetCapabilitiesRequest(); req.setBaseUrl(BASE_URL); req.setVersion(WMS.VERSION_1_3_0.toString()); Document dom = WMSTestSupport.transform(req, tr); Element root = dom.getDocumentElement(); assertEquals(WMS.VERSION_1_3_0.toString(), root.getAttribute("version")); return dom; }
/** * Retrieves the WMS's capabilities document. * * @param scaleHintUnitsPerDiaPixel true if the scalehint must be in units per diagonal of a * pixel * @return Capabilities as {@link Document} */ private Document findCapabilities(Boolean scaleHintUnitsPerDiaPixel) throws Exception { // set the Scalehint units per diagonal pixel setting. WMS wms = getWMS(); WMSInfo info = wms.getServiceInfo(); MetadataMap mm = info.getMetadata(); mm.put(WMS.SCALEHINT_MAPUNITS_PIXEL, scaleHintUnitsPerDiaPixel); info.getGeoServer().save(info); GetCapabilitiesTransformer tr = new GetCapabilitiesTransformer(wms, BASE_URL, FORMATS, LEGEND_FORMAT, null); GetCapabilitiesRequest req = new GetCapabilitiesRequest(); req.setBaseUrl(BASE_URL); req.setVersion(WMS.VERSION_1_1_1.toString()); Document dom = WMSTestSupport.transform(req, tr); Element root = dom.getDocumentElement(); Assert.assertEquals(WMS.VERSION_1_1_1.toString(), root.getAttribute("version")); return dom; }
/** * Sets up the configuration objects with default values. Since they're live, specific tests can * modify their state before running the assertions */ @Before public void setUp() throws Exception { geosConfig = new GeoServerImpl(); geosInfo = new GeoServerInfoImpl(geosConfig); geosInfo.setContact(new ContactInfoImpl()); geosConfig.setGlobal(geosInfo); wmsInfo = new WMSInfoImpl(); geosConfig.add(wmsInfo); catalog = new CatalogImpl(); geosConfig.setCatalog(catalog); wmsConfig = new WMS(geosConfig); req = new GetCapabilitiesRequest(); req.setBaseUrl(baseUrl); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); XPATH = XMLUnit.newXpathEngine(); }