public void setCapabilitiesURL(String url) { delegate.setCapabilitiesURL(url); }
/** * @param source * @param target */ private void setConnectionParameters(final WMSStoreInfo source, WMSStoreInfo target) { target.setCapabilitiesURL(source.getCapabilitiesURL()); target.setUsername(source.getUsername()); target.setPassword(source.getPassword()); target.setUseConnectionPooling(source.isUseConnectionPooling()); target.setMaxConnections(source.getMaxConnections()); target.setConnectTimeout(source.getConnectTimeout()); target.setReadTimeout(source.getReadTimeout()); }
@Test public void testModifyWMSStore() throws Exception { testAddWMSStore(); WMSStoreInfo wms = catalog.getStoreByName("acme", "demowms", WMSStoreInfo.class); assertNull(wms.getCapabilitiesURL()); String capsURL = "http://demo.opengeo.org:8080/geoserver/wms?request=GetCapabilites&service=WMS"; wms.setCapabilitiesURL(capsURL); catalog.save(wms); File f = new File(testData.getDataDirectoryRoot(), "workspaces/acme/demowms/wmsstore.xml"); Document dom = dom(f); assertXpathEvaluatesTo(capsURL, "/wmsStore/capabilitiesURL/text()", dom); }
info.setCapabilitiesURL(url.toExternalForm()); info.setEnabled(true);
private WMSStoreInfo buildWmsStore() { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); WMSStoreInfo wms = cFactory.createWebMapServer(); wms.setName("bar"); wms.setWorkspace(ws); wms.setCapabilitiesURL("http://fake.host/wms?request=GetCapabilities&service=wms"); wms.setUsername("user"); wms.setPassword("password"); return wms; } }
@Test public void testWMSLayer130crs84() throws Exception { TestHttpClientProvider.startTest(); try { String baseURL = TestHttpClientProvider.MOCKSERVER + "/wms13"; MockHttpClient client = new MockHttpClient(); URL capsURL = new URL(baseURL + "?service=WMS&request=GetCapabilities&version=1.3.0"); client.expectGet( capsURL, new MockHttpResponse(getClass().getResource("caps130_crs84.xml"), "text/xml")); TestHttpClientProvider.bind(client, capsURL); CatalogBuilder cb = new CatalogBuilder(getCatalog()); WMSStoreInfo store = cb.buildWMSStore("test-store"); store.setCapabilitiesURL(capsURL.toExternalForm()); cb.setStore(store); WMSLayerInfo layer = cb.buildWMSLayer("world4326"); // check the bbox has the proper axis order assertEquals("EPSG:4326", layer.getSRS()); ReferencedEnvelope bbox = layer.getLatLonBoundingBox(); assertEquals(-180, bbox.getMinX(), 0d); assertEquals(-90, bbox.getMinY(), 0d); assertEquals(180, bbox.getMaxX(), 0d); assertEquals(90, bbox.getMaxY(), 0d); } finally { TestHttpClientProvider.endTest(); } }
@Test public void testWMSLayer111() throws Exception { TestHttpClientProvider.startTest(); try { String baseURL = TestHttpClientProvider.MOCKSERVER + "/wms11"; MockHttpClient client = new MockHttpClient(); URL capsURL = new URL(baseURL + "?service=WMS&request=GetCapabilities&version=1.1.0"); client.expectGet( capsURL, new MockHttpResponse(getClass().getResource("caps111.xml"), "text/xml")); TestHttpClientProvider.bind(client, capsURL); CatalogBuilder cb = new CatalogBuilder(getCatalog()); WMSStoreInfo store = cb.buildWMSStore("test-store"); store.setCapabilitiesURL(capsURL.toExternalForm()); cb.setStore(store); WMSLayerInfo layer = cb.buildWMSLayer("world4326"); // check the bbox has the proper axis order assertEquals("EPSG:4326", layer.getSRS()); ReferencedEnvelope bbox = layer.getLatLonBoundingBox(); assertEquals(-180, bbox.getMinX(), 0d); assertEquals(-90, bbox.getMinY(), 0d); assertEquals(180, bbox.getMaxX(), 0d); assertEquals(90, bbox.getMaxY(), 0d); } finally { TestHttpClientProvider.endTest(); } }
@Test public void testWMSLayer130() throws Exception { TestHttpClientProvider.startTest(); try { String baseURL = TestHttpClientProvider.MOCKSERVER + "/wms13"; MockHttpClient client = new MockHttpClient(); URL capsURL = new URL(baseURL + "?service=WMS&request=GetCapabilities&version=1.3.0"); client.expectGet( capsURL, new MockHttpResponse(getClass().getResource("caps130.xml"), "text/xml")); TestHttpClientProvider.bind(client, capsURL); CatalogBuilder cb = new CatalogBuilder(getCatalog()); WMSStoreInfo store = cb.buildWMSStore("test-store"); store.setCapabilitiesURL(capsURL.toExternalForm()); cb.setStore(store); WMSLayerInfo layer = cb.buildWMSLayer("world4326"); // check the bbox has the proper axis order assertEquals("EPSG:4326", layer.getSRS()); ReferencedEnvelope bbox = layer.getLatLonBoundingBox(); assertEquals(-180, bbox.getMinX(), 0d); assertEquals(-90, bbox.getMinY(), 0d); assertEquals(180, bbox.getMaxX(), 0d); assertEquals(90, bbox.getMaxY(), 0d); } finally { TestHttpClientProvider.endTest(); } }
/** Tests we can build properly the WMS store and the WMS layer */ @Test public void testWMS() throws Exception { if (!RemoteOWSTestSupport.isRemoteWMSStatesAvailable(LOGGER)) { LOGGER.warning("Remote OWS tests disabled, skipping catalog builder wms tests"); return; } Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); WMSStoreInfo wms = cb.buildWMSStore("demo"); wms.setCapabilitiesURL( RemoteOWSTestSupport.WMS_SERVER_URL + "service=WMS&request=GetCapabilities&version=1.1.0"); cb.setStore(wms); WMSLayerInfo wmsLayer = cb.buildWMSLayer("topp:states"); assertWMSLayer(wmsLayer); LayerInfo layer = cb.buildLayer(wmsLayer); assertEquals(PublishedType.WMS, layer.getType()); wmsLayer = cat.getFactory().createWMSLayer(); wmsLayer.setName("states"); wmsLayer.setNativeName("topp:states"); cb.initWMSLayer(wmsLayer); assertWMSLayer(wmsLayer); }
public WMSStoreInfo clone(final WMSStoreInfo source, boolean allowEnvParametrization) { WMSStoreInfo target; try { target = (WMSStoreInfo) SerializationUtils.clone(source); if (target instanceof StoreInfoImpl && target.getCatalog() == null) { ((StoreInfoImpl) target).setCatalog(catalog); } } catch (Exception e) { target = catalog.getFactory().createWebMapServer(); target.setDescription(source.getDescription()); target.setEnabled(source.isEnabled()); target.setName(source.getName()); target.setType(source.getType()); target.setWorkspace(source.getWorkspace()); } setConnectionParameters(source, target); if (allowEnvParametrization) { // Resolve GeoServer Environment placeholders final GeoServerEnvironment gsEnvironment = GeoServerExtensions.bean(GeoServerEnvironment.class); if (gsEnvironment != null && GeoServerEnvironment.ALLOW_ENV_PARAMETRIZATION) { target.setCapabilitiesURL( (String) gsEnvironment.resolveValue(source.getCapabilitiesURL())); target.setUsername((String) gsEnvironment.resolveValue(source.getUsername())); target.setPassword((String) gsEnvironment.resolveValue(source.getPassword())); } } return target; }
@Test public void testWMSStore() throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); WMSStoreInfo wms1 = cFactory.createWebMapServer(); wms1.setName("bar"); wms1.setWorkspace(ws); wms1.setCapabilitiesURL("http://fake.host/wms?request=GetCapabilities&service=wms"); ByteArrayOutputStream out = out(); persister.save(wms1, out); WMSStoreInfo wms2 = persister.load(in(out), WMSStoreInfo.class); assertEquals("bar", wms2.getName()); assertEquals(WMSStoreInfoImpl.DEFAULT_MAX_CONNECTIONS, wms2.getMaxConnections()); assertEquals(WMSStoreInfoImpl.DEFAULT_CONNECT_TIMEOUT, wms2.getConnectTimeout()); assertEquals(WMSStoreInfoImpl.DEFAULT_READ_TIMEOUT, wms2.getReadTimeout()); assertNotNull(wms2.getWorkspace()); assertEquals("foo", wms2.getWorkspace().getId()); Document dom = dom(in(out)); assertEquals("wmsStore", dom.getDocumentElement().getNodeName()); }
/** * Check maxConnections, connectTimeout, and readTimeout, stored as metadata properties in a * 2.1.3+ configuration are read back as actual properties. */ @Test public void testWMSStoreBackwardsCompatibility() throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); WMSStoreInfo wms1 = cFactory.createWebMapServer(); wms1.setName("bar"); wms1.setWorkspace(ws); wms1.setCapabilitiesURL("http://fake.host/wms?request=GetCapabilities&service=wms"); wms1.getMetadata().put("maxConnections", Integer.valueOf(18)); wms1.getMetadata().put("connectTimeout", Integer.valueOf(25)); wms1.getMetadata().put("readTimeout", Integer.valueOf(78)); ByteArrayOutputStream out = out(); persister.save(wms1, out); WMSStoreInfo wms2 = persister.load(in(out), WMSStoreInfo.class); assertEquals("bar", wms2.getName()); assertEquals(18, wms2.getMaxConnections()); assertEquals(25, wms2.getConnectTimeout()); assertEquals(78, wms2.getReadTimeout()); assertNull(wms2.getMetadata().get("maxConnections")); assertNull(wms2.getMetadata().get("connectTimeout")); assertNull(wms2.getMetadata().get("readTimeout")); }
wms.setWorkspace(ws); wms.setName("foo"); wms.setCapabilitiesURL("http://fake.host/wms?request=getCapabilities"); catalog.add(wms);
@Test public void testWMSStoreReferencedByName() throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); WMSStoreInfo wms1 = cFactory.createWebMapServer(); wms1.setName("bar"); wms1.setWorkspace(ws); wms1.setCapabilitiesURL("http://fake.host/wms?request=GetCapabilities&service=wms"); catalog.detach(wms1); ((WMSStoreInfoImpl) wms1).setId(null); ByteArrayOutputStream out = out(); XStreamPersister persister = new XStreamPersisterFactory().createXMLPersister(); persister.setReferenceByName(true); persister.save(wms1, out); WMSStoreInfo wms2 = persister.load(in(out), WMSStoreInfo.class); assertEquals("bar", wms2.getName()); assertEquals(WMSStoreInfoImpl.DEFAULT_MAX_CONNECTIONS, wms2.getMaxConnections()); assertEquals(WMSStoreInfoImpl.DEFAULT_CONNECT_TIMEOUT, wms2.getConnectTimeout()); assertEquals(WMSStoreInfoImpl.DEFAULT_READ_TIMEOUT, wms2.getReadTimeout()); assertNotNull(wms2.getWorkspace()); assertEquals("foo", wms2.getWorkspace().getId()); Document dom = dom(in(out)); assertEquals("wmsStore", dom.getDocumentElement().getNodeName()); }
wms.setName("wmsName"); wms.setType("WMS"); wms.setCapabilitiesURL("http://fake.url"); wms.setWorkspace(ws);
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); // we need to add a wms store CatalogBuilder cb = new CatalogBuilder(catalog); cb.setWorkspace(catalog.getWorkspaceByName("sf")); WMSStoreInfo wms = cb.buildWMSStore("demo"); wms.setCapabilitiesURL( clientMocker.getServer() + "/geoserver/wms?REQUEST=GetCapabilities&VERSION=1.3.0&SERVICE=WMS"); catalog.add(wms); // and a wms layer as well (cannot use the builder, would turn this test into an online one addStatesWmsLayer(); }
private void setupWMS110Layer() throws MalformedURLException, IOException { // prepare the WMS 1.1 mock client wms11Client = new MockHttpClient(); wms11BaseURL = new URL(TestHttpClientProvider.MOCKSERVER + "/wms11"); URL capsDocument = WMSTestSupport.class.getResource("caps111.xml"); wms11Client.expectGet( new URL(wms11BaseURL + "?service=WMS&request=GetCapabilities&version=1.1.1"), new MockHttpResponse(capsDocument, "text/xml")); URL pngImage = WMSTestSupport.class.getResource("world.png"); // we expect a getmap request with flipped coordinates wms11Client.expectGet( new URL( wms11BaseURL + "?service=WMS&version=1.1.1&request=GetMap&layers=world4326" + "&styles&bbox=-180.0,-90.0,180.0,90.0&srs=EPSG:4326&bgcolor=0xFFFFFF&transparent=FALSE&format=image/png&width=180&height=90"), new MockHttpResponse(pngImage, "image/png")); String caps = wms11BaseURL + "?service=WMS&request=GetCapabilities&version=1.1.1"; TestHttpClientProvider.bind(wms11Client, caps); // setup the WMS layer CatalogBuilder cb = new CatalogBuilder(getCatalog()); WMSStoreInfo store = cb.buildWMSStore("mock-wms-store-110"); getCatalog().add(store); cb.setStore(store); store.setCapabilitiesURL(caps); WMSLayerInfo wmsLayer = cb.buildWMSLayer("world4326"); wmsLayer.setName(WORLD4326_110); getCatalog().add(wmsLayer); LayerInfo gsLayer = cb.buildLayer(wmsLayer); getCatalog().add(gsLayer); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); // we need to add a wms store CatalogBuilder cb = new CatalogBuilder(catalog); cb.setWorkspace(catalog.getWorkspaceByName("sf")); WMSStoreInfo wms = cb.buildWMSStore("demo"); wms.setCapabilitiesURL(capabilities); catalog.add(wms); cb.setStore(wms); WMSLayerInfo layer = cb.buildWMSLayer("world4326"); catalog.add(layer); }
private void setupWMS110NfiLayer() throws MalformedURLException, IOException { // prepare the WMS 1.1 mock client wms11ClientNfi = new MockHttpClient(); wms11BaseNfiURL = new URL(TestHttpClientProvider.MOCKSERVER + "/wms11_nfi"); URL capsDocument = WMSTestSupport.class.getResource("caps111_no_feature_info.xml"); wms11ClientNfi.expectGet( new URL(wms11BaseNfiURL + "?service=WMS&request=GetCapabilities&version=1.1.1"), new MockHttpResponse(capsDocument, "text/xml")); String caps = wms11BaseNfiURL + "?service=WMS&request=GetCapabilities&version=1.1.1"; TestHttpClientProvider.bind(wms11ClientNfi, caps); // setup the WMS layer CatalogBuilder cb = new CatalogBuilder(getCatalog()); WMSStoreInfo store = cb.buildWMSStore("mock-wms-store-110-nfi"); getCatalog().add(store); cb.setStore(store); store.setCapabilitiesURL(caps); WMSLayerInfo wmsLayer = cb.buildWMSLayer("world4326"); wmsLayer.setName(WORLD4326_110_NFI); getCatalog().add(wmsLayer); LayerInfo gsLayer = cb.buildLayer(wmsLayer); getCatalog().add(gsLayer); } }
protected void clone(final WMSStoreInfo source, WMSStoreInfo target) { target.setDescription(source.getDescription()); target.setEnabled(source.isEnabled()); target.setName(source.getName()); target.setType(source.getType()); target.setCapabilitiesURL(source.getCapabilitiesURL()); target.setWorkspace(source.getWorkspace()); target.setUsername(source.getUsername()); target.setPassword(source.getPassword()); target.setUseConnectionPooling(source.isUseConnectionPooling()); target.setMaxConnections(source.getMaxConnections()); target.setConnectTimeout(source.getConnectTimeout()); target.setReadTimeout(source.getReadTimeout()); }