@Override public int getMaxConnections() { return delegate.getMaxConnections(); }
/** * @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()); }
metadata.remove("readTimeout"); if (wmsStore.getMaxConnections() <= 0) { wmsStore.setMaxConnections( maxConnections != null && maxConnections.intValue() > 0
@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")); }
@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()); }
@Override public void visit(WMSStoreInfo wmsStore) { WMSStoreInfo otherWmsStore = otherCatalog.getStore(wmsStore.getId(), WMSStoreInfo.class); if (!(Objects.equals(wmsStore, otherWmsStore) && Objects.equals(wmsStore.getType(), otherWmsStore.getType()) && Objects.equals(wmsStore.getCapabilitiesURL(), otherWmsStore.getCapabilitiesURL()) && Objects.equals(wmsStore.getUsername(), otherWmsStore.getUsername()) && Objects.equals(wmsStore.getPassword(), otherWmsStore.getPassword()) && Objects.equals(wmsStore.getMaxConnections(), otherWmsStore.getMaxConnections()) && Objects.equals(wmsStore.getReadTimeout(), otherWmsStore.getReadTimeout()) && Objects.equals(wmsStore.getConnectTimeout(), otherWmsStore.getConnectTimeout()) && checkEquals(wmsStore.getMetadata(), otherWmsStore.getMetadata()) && checkEquals( wmsStore.getConnectionParameters(), otherWmsStore.getConnectionParameters()))) { differences.add(new InfoDiff(wmsStore, otherWmsStore)); } }
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()); }
@Test public void testPutNonDestructive() throws Exception { WMSStoreInfo wsi = catalog.getStoreByName("sf", "demo", WMSStoreInfo.class); wsi.setEnabled(true); catalog.save(wsi); assertTrue(wsi.isEnabled()); int maxConnections = wsi.getMaxConnections(); int readTimeout = wsi.getReadTimeout(); int connectTimeout = wsi.getConnectTimeout(); boolean useConnectionPooling = wsi.isUseConnectionPooling(); String xml = "<wmsStore>" + "<name>demo</name>" + "</wmsStore>"; MockHttpServletResponse response = putAsServletResponse( RestBaseController.ROOT_PATH + "/workspaces/sf/wmsstores/demo", xml, "text/xml"); assertEquals(200, response.getStatus()); wsi = catalog.getStoreByName("sf", "demo", WMSStoreInfo.class); assertTrue(wsi.isEnabled()); assertEquals(maxConnections, wsi.getMaxConnections()); assertEquals(readTimeout, wsi.getReadTimeout()); assertEquals(connectTimeout, wsi.getConnectTimeout()); assertEquals(useConnectionPooling, wsi.isUseConnectionPooling()); }