org.glassfish.grizzly.http.Method Java Examples
The following examples show how to use
org.glassfish.grizzly.http.Method.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LayerGroupCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void createLayerGroupWithWorspace() throws Exception { String url = "/geoserver/rest/workspaces/topp/layergroups.xml"; whenHttp(server).match(post(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); LayerGroupCommands commands = new LayerGroupCommands(); commands.setGeoserver(geoserver); String name = "census"; String layers = "tracts,block groups,blocks"; String styles = "tracts,block groups, blocks"; String workspace = "topp"; boolean result = commands.create(name, layers, styles, workspace); assertTrue(result); String actual = server.getCalls().get(0).getPostBody(); String expected = "<layerGroup><name>census</name><layers><layer>tracts</layer><layer>block groups</layer>" + "<layer>blocks</layer></layers><styles><style>tracts</style><style>block groups</style>" + "<style>blocks</style></styles></layerGroup>"; assertEquals(expected, actual); verifyHttp(server).once(method(Method.POST), uri(url)); }
Example #2
Source File: GeoWebCacheCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void getLayer() throws Exception { String url = "/geoserver/gwc/rest/layers/sf:roads.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("gwc_layer.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); GeoWebCacheCommands commands = new GeoWebCacheCommands(); commands.setGeoserver(geoserver); String actual = commands.getLayer("sf:roads"); String expected = "sf:roads" + OsUtils.LINE_SEPARATOR + " Enabled: true" + OsUtils.LINE_SEPARATOR + " Gutter: 0" + OsUtils.LINE_SEPARATOR + " Auto Cache Styles: true" + OsUtils.LINE_SEPARATOR + " Mime Formats:" + OsUtils.LINE_SEPARATOR + " image/png" + OsUtils.LINE_SEPARATOR + " image/jpeg" + OsUtils.LINE_SEPARATOR + " Grid Subsets:" + OsUtils.LINE_SEPARATOR + " EPSG:900913" + OsUtils.LINE_SEPARATOR + " EPSG:4326" + OsUtils.LINE_SEPARATOR + " Meta Dimensions:" + OsUtils.LINE_SEPARATOR + " Width: 4" + OsUtils.LINE_SEPARATOR + " Height: 4" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #3
Source File: BomGoalTest.java From steady with Apache License 2.0 | 6 votes |
/** * One app PUT will be made, as the app is said to exist in the backend. * * @throws GoalConfigurationException * @throws GoalExecutionException */ @Test public void testBomSkipSaveEmptyApp() throws GoalConfigurationException, GoalExecutionException { // Mock REST services this.configureBackendServiceUrl(server); this.setupMockServices(this.testApp, false); // Set config this.vulasConfiguration.setProperty(CoreConfiguration.TENANT_TOKEN, "foo"); this.vulasConfiguration.setProperty(CoreConfiguration.APP_CTX_GROUP, this.testApp.getMvnGroup()); this.vulasConfiguration.setProperty(CoreConfiguration.APP_CTX_ARTIF, this.testApp.getArtifact()); this.vulasConfiguration.setProperty(CoreConfiguration.APP_CTX_VERSI, this.testApp.getVersion()); // Execute goal final AbstractGoal goal = GoalFactory.create(GoalType.APP, GoalClient.CLI); goal.setConfiguration(this.vulasConfiguration).executeSync(); // Check the HTTP calls made verifyHttp(server).times(0, method(Method.PUT), uri("/backend" + PathBuilder.app(this.testApp))); verifyHttp(server).times(0, method(Method.POST), uri("/backend" + PathBuilder.goalExcecutions(null, null, this.testApp))); }
Example #4
Source File: DataStoreCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void createDataStore() throws Exception { String url = "/geoserver/rest/workspaces/topp/datastores.xml"; whenHttp(server).match(post(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); DataStoreCommands commands = new DataStoreCommands(); commands.setGeoserver(geoserver); String workspace = "topp"; String name = "hydro"; String connectionParams = "dbtype=h2 database=test.db"; String description = null; boolean enabled = true; boolean result = commands.create(workspace, name, connectionParams, description, enabled); assertTrue(result); String actual = server.getCalls().get(0).getPostBody(); String expected = "<dataStore><name>hydro</name><enabled>true</enabled>" + "<connectionParameters><database>test.db</database><dbtype>h2</dbtype></connectionParameters>" + "</dataStore>"; assertEquals(expected, actual); verifyHttp(server).once(method(Method.POST), uri(url)); }
Example #5
Source File: CoverageStoreCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void uploadCoverageStore() throws Exception { String workspace = "nurc"; String coverageStore = "terrain"; File file = getResourceFile("coveragestore.xml"); String type = "geotiff"; String configure = "first"; String coverage = "myterrain"; String recalculate = "nativebbox"; String url = "/geoserver/rest/workspaces/nurc/coveragestores/terrain/file.geotiff"; whenHttp(server).match(put(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); CoverageStoreCommands commands = new CoverageStoreCommands(); commands.setGeoserver(geoserver); boolean result = commands.upload(workspace, coverageStore, file, type, configure, coverage, recalculate); assertTrue(result); String body = server.getCalls().get(0).getPostBody(); String contentType = server.getCalls().get(0).getContentType(); assertEquals("image/tiff", contentType); Map<String, String[]> params = server.getCalls().get(0).getParameters(); assertEquals(configure, params.get("configure")[0]); assertEquals(recalculate, params.get("recalculate")[0]); assertEquals(coverage, params.get("coverageName")[0]); verifyHttp(server).once(method(Method.PUT), uri(url)); }
Example #6
Source File: BomGoalTest.java From steady with Apache License 2.0 | 6 votes |
/** * Two HTTP requests shall be made * * @throws GoalConfigurationException * @throws GoalExecutionException */ @Test public void testBomSaveEmptyApp() throws GoalConfigurationException, GoalExecutionException { // Mock REST services this.configureBackendServiceUrl(server); this.setupMockServices(this.testApp, true); // Set config this.vulasConfiguration.setProperty(CoreConfiguration.TENANT_TOKEN, "foo"); this.vulasConfiguration.setProperty(CoreConfiguration.APP_CTX_GROUP, this.testApp.getMvnGroup()); this.vulasConfiguration.setProperty(CoreConfiguration.APP_CTX_ARTIF, this.testApp.getArtifact()); this.vulasConfiguration.setProperty(CoreConfiguration.APP_CTX_VERSI, this.testApp.getVersion()); this.vulasConfiguration.setProperty(CoreConfiguration.APP_UPLOAD_EMPTY, new Boolean(true)); // Execute goal final AbstractGoal goal = GoalFactory.create(GoalType.APP, GoalClient.CLI); goal.setConfiguration(this.vulasConfiguration).executeSync(); // Check (some of) the HTTP calls made (1 app PUT, 1 goal exe POST) verifyHttp(server).times(1, method(Method.PUT), uri("/backend" + PathBuilder.app(this.testApp))); verifyHttp(server).times(2, method(Method.POST), uri("/backend" + PathBuilder.goalExcecutions(null, null, this.testApp))); }
Example #7
Source File: DataStoreCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void modifyDataStore() throws Exception { String url = "/geoserver/rest/workspaces/topp/datastores/hydro.xml"; whenHttp(server).match(put(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); DataStoreCommands commands = new DataStoreCommands(); commands.setGeoserver(geoserver); String workspace = "topp"; String name = "hydro"; String connectionParams = null; String description = "The hydro lines for Tasmania"; String enabled = null; boolean result = commands.modify(workspace, name, connectionParams, description, enabled); assertTrue(result); String actual = server.getCalls().get(0).getPostBody(); String expected = "<dataStore><name>hydro</name>" + "<description>The hydro lines for Tasmania</description></dataStore>"; assertEquals(expected, actual); verifyHttp(server).once(method(Method.PUT), uri(url)); }
Example #8
Source File: SettingsCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void listContactSettings() throws Exception { String url = "/geoserver/rest/settings/contact.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("contactSettings.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); SettingsCommands commands = new SettingsCommands(); commands.setGeoserver(geoserver); String actual = commands.listContact(); String expected = "City: Somewhere" + OsUtils.LINE_SEPARATOR + "Country: USA" + OsUtils.LINE_SEPARATOR + "Type: Home" + OsUtils.LINE_SEPARATOR + "Email: [email protected]" + OsUtils.LINE_SEPARATOR + "Organization: Geoserver" + OsUtils.LINE_SEPARATOR + "Name: John Doe" + OsUtils.LINE_SEPARATOR + "Position: Map Maker" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #9
Source File: DataStoreCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void createNeo4jDataStore() throws Exception { String url = "/geoserver/rest/workspaces/topp/datastores.json"; whenHttp(server).match(post(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); DataStoreCommands commands = new DataStoreCommands(); commands.setGeoserver(geoserver); String workspace = "topp"; String name = "neo4j"; String connectionParams = "'The directory path of the neo4j database: '=/opt/neo4j/data/graph.db"; String description = null; boolean enabled = true; boolean result = commands.create(workspace, name, connectionParams, description, enabled); assertTrue(result); String actual = server.getCalls().get(0).getPostBody(); JSONObject json = new JSONObject(actual); assertNotNull(json.getJSONObject("dataStore")); assertEquals("neo4j", json.getJSONObject("dataStore").get("name")); assertNotNull(json.getJSONObject("dataStore").getJSONObject("connectionParameters")); assertNotNull(json.getJSONObject("dataStore").getJSONObject("connectionParameters").getJSONArray("entry")); assertEquals("The directory path of the neo4j database: ", json.getJSONObject("dataStore").getJSONObject("connectionParameters") .getJSONArray("entry").getJSONObject(0).get("@key")); assertEquals("/opt/neo4j/data/graph.db", json.getJSONObject("dataStore").getJSONObject("connectionParameters") .getJSONArray("entry").getJSONObject(0).get("$")); verifyHttp(server).once(method(Method.POST), uri(url)); }
Example #10
Source File: OWSCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void listWcsSettings() throws Exception { String url = "/geoserver/rest/services/wcs/settings.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("wcs.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); OWSCommands commands = new OWSCommands(); commands.setGeoserver(geoserver); String actual = commands.wcsList(null); String expected = "WCS" + OsUtils.LINE_SEPARATOR + " Enabled: true" + OsUtils.LINE_SEPARATOR + " Cite Compliant: false" + OsUtils.LINE_SEPARATOR + " Schema Base URL: http://schemas.opengis.net" + OsUtils.LINE_SEPARATOR + " Verbose: false" + OsUtils.LINE_SEPARATOR + " GML Prefixing: false" + OsUtils.LINE_SEPARATOR + " LatLon: false" + OsUtils.LINE_SEPARATOR + " Max Input Memory: -1" + OsUtils.LINE_SEPARATOR + " Max Output Memory: -1" + OsUtils.LINE_SEPARATOR + " Subsampling Enabled: false" + OsUtils.LINE_SEPARATOR + " Versions:" + OsUtils.LINE_SEPARATOR + " 1.0.0" + OsUtils.LINE_SEPARATOR + " 1.1.1" + OsUtils.LINE_SEPARATOR + " 2.0.1" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #11
Source File: SettingsCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void listLocalSettings() throws Exception { String url = "/geoserver/rest/workspaces/topp/settings.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("localSettings.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); SettingsCommands commands = new SettingsCommands(); commands.setGeoserver(geoserver); String actual = commands.listLocal("topp"); String expected = "Settings" + OsUtils.LINE_SEPARATOR + " Charset: UTF-8" + OsUtils.LINE_SEPARATOR + " Number of Decimals: 4" + OsUtils.LINE_SEPARATOR + " Online Resource: null" + OsUtils.LINE_SEPARATOR + " Verbose: false" + OsUtils.LINE_SEPARATOR + " Verbose Exceptions: false" + OsUtils.LINE_SEPARATOR + "" + OsUtils.LINE_SEPARATOR + "Contact" + OsUtils.LINE_SEPARATOR + " City: null" + OsUtils.LINE_SEPARATOR + " Country: null" + OsUtils.LINE_SEPARATOR + " Type: work" + OsUtils.LINE_SEPARATOR + " Email: null" + OsUtils.LINE_SEPARATOR + " Organization: Work" + OsUtils.LINE_SEPARATOR + " Name: John Doe" + OsUtils.LINE_SEPARATOR + " Position: null" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #12
Source File: NvdRestServiceMockup.java From steady with Apache License 2.0 | 6 votes |
/** * Starts the server and registers URIs for the different vulnerabilities in {@link NvdRestServiceMockup#CVES}. * @throws IOException */ public NvdRestServiceMockup() { server = new StubServer().run(); RestAssured.port = server.getPort(); System.setProperty(VulasConfiguration.getServiceUrlKey(Service.CVE), "http://localhost:" + server.getPort() + "/nvdrest/vulnerabilities/<ID>"); int cves_registered = 0; for(String cve: CVES) { try { whenHttp(server). match(composite(method(Method.GET), uri("/nvdrest/vulnerabilities/" + cve))). then( stringContent(FileUtil.readFile(Paths.get("./src/test/resources/cves/" + cve + "-new.json"))), contentType("application/json"), charset("UTF-8"), status(HttpStatus.OK_200)); cves_registered++; } catch (IOException e) { System.err.println("Could not register URI for cve [" + cve + "]: " + e.getMessage()); } } if(cves_registered==0) { throw new IllegalStateException("None of the CVEs could be registered"); } }
Example #13
Source File: AboutCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void manifestGet() throws Exception { whenHttp(server).match(get("/geoserver/rest/about/manifests.xml")).then(stringContent(getResourceString("manifests.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); AboutCommands commands = new AboutCommands(); commands.setGeoserver(geoserver); String actual = commands.manifestGet("gt-xsd-ows-9.1"); String expected = "gt-xsd-ows-9.1" + OsUtils.LINE_SEPARATOR + " Manifest-Version: 1.0" + OsUtils.LINE_SEPARATOR + " Archiver-Version: Plexus Archiver" + OsUtils.LINE_SEPARATOR + " Built-By: jetty" + OsUtils.LINE_SEPARATOR + " Build-Timestamp: 20-Apr-2013 11:03" + OsUtils.LINE_SEPARATOR + " Git-Revision: f25b08094d1bf7e0949994f4971bc21fb117d37b" + OsUtils.LINE_SEPARATOR + " Build-Jdk: 1.6.0_22" + OsUtils.LINE_SEPARATOR + " Project-Version: 9.1" + OsUtils.LINE_SEPARATOR + " Created-By: Apache Maven" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri("/geoserver/rest/about/manifests.xml")); }
Example #14
Source File: OWSCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void createWcsSettingsForWorkspace() throws Exception { String url = "/geoserver/rest/services/wcs/workspaces/topp/settings.xml"; whenHttp(server).match(put(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); OWSCommands commands = new OWSCommands(); commands.setGeoserver(geoserver); String workspace = "topp"; boolean enabled = true; boolean verbose = true; boolean gmlPrefixing = false; boolean latlon = false; int maxInputMemory = 512; int maxOutputMemory = 256; boolean subsamplingEnabled = true; boolean result = commands.wcsCreate(workspace, enabled, verbose, gmlPrefixing, latlon, maxInputMemory, maxOutputMemory, subsamplingEnabled); assertTrue(result); String actual = server.getCalls().get(0).getPostBody(); String expected = "<wcs><workspace>topp</workspace><name>WCS</name><enabled>true</enabled>" + "<verbose>true</verbose><gmlPrefixing>false</gmlPrefixing><latLon>false</latLon>" + "<maxInputMemory>512</maxInputMemory><maxOutputMemory>256</maxOutputMemory>" + "<subsamplingEnabled>true</subsamplingEnabled></wcs>"; assertEquals(expected, actual); verifyHttp(server).once(method(Method.PUT), uri(url)); }
Example #15
Source File: WmsStoreCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void listAvailableLayers() throws Exception { String url = "/geoserver/rest/workspaces/topp/wmsstores/massgis/wmslayers.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("wms_available_layers.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); WmsStoreCommands commands = new WmsStoreCommands(); commands.setGeoserver(geoserver); String actual = commands.listAvailableLayers("topp", "massgis"); String expected = "massgis:AFREEMAN.AUDUBON_BIRD_S_V" + OsUtils.LINE_SEPARATOR + "massgis:AFREEMAN.AUDUBON_BUTTERFLY_S_V" + OsUtils.LINE_SEPARATOR + "massgis:AFREEMAN.AUDUBON_GRID_POLY" + OsUtils.LINE_SEPARATOR + "massgis:AFREEMAN.BLDGS_TEST_POLY" + OsUtils.LINE_SEPARATOR + "massgis:AFREEMAN.CAMPUS_BLDGS_POLY" + OsUtils.LINE_SEPARATOR + "massgis:AFREEMAN.CAMPUS_SITES_POLY" + OsUtils.LINE_SEPARATOR + "massgis:AFREEMAN.CPA_COMBINED_V_PT" + OsUtils.LINE_SEPARATOR + "massgis:AFREEMAN.CPA_PT" + OsUtils.LINE_SEPARATOR + "massgis:AFREEMAN.DCAM_BLDG_PTS_20120229" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); assertEquals("available", server.getCalls().get(0).getParameters().get("list")[0]); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #16
Source File: FeatureTypeCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void publishFeatureType() throws Exception { String url = "/geoserver/rest/workspaces/topp/datastores/taz_shapes/featuretypes.xml"; whenHttp(server).match(post(url)).then(stringContent(getResourceString("featuretypes.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); FeatureTypeCommands commands = new FeatureTypeCommands(); commands.setGeoserver(geoserver); String workspace = "topp"; String dataStore = "taz_shapes"; String featureType = "taz_soils"; boolean result = commands.publish(workspace, dataStore, featureType); assertTrue(result); String actual = server.getCalls().get(0).getPostBody(); String expected = "<featureType><name>taz_soils</name></featureType>"; assertEquals(expected, actual); verifyHttp(server).once(method(Method.POST), uri(url)); }
Example #17
Source File: WmsStoreCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void getStore() throws Exception { String url = "/geoserver/rest/workspaces/topp/wmsstores/massgis.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("wmsStore.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); WmsStoreCommands commands = new WmsStoreCommands(); commands.setGeoserver(geoserver); String actual = commands.getStore("topp", "massgis"); String expected = "massgis" + OsUtils.LINE_SEPARATOR + " Type: WMS" + OsUtils.LINE_SEPARATOR + " Enabled: true" + OsUtils.LINE_SEPARATOR + " Workspace: topp" + OsUtils.LINE_SEPARATOR + " Capabilities URL: " + OsUtils.LINE_SEPARATOR + " http://giswebservices.massgis.state.ma.us/geoserver/wms?request=GetCapabilities&version=1.1.0&service=wms" + OsUtils.LINE_SEPARATOR + " " + OsUtils.LINE_SEPARATOR + " Max Connections: 6" + OsUtils.LINE_SEPARATOR + " Read Timeout: 60" + OsUtils.LINE_SEPARATOR + " Connect Timeout: 30" + OsUtils.LINE_SEPARATOR + " Metadata: " + OsUtils.LINE_SEPARATOR + " useConnectionPooling: true" + OsUtils.LINE_SEPARATOR; assertStringsEquals(expected, actual, true); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #18
Source File: ScriptCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void modifyWfsTx() throws Exception { whenHttp(server).match(put("/geoserver/rest/scripts/wfs/tx/buffer.groovy")).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); ScriptCommands commands = new ScriptCommands(); commands.setGeoserver(geoserver); File file = File.createTempFile("buffer", ".groovy"); FileWriter writer = new FileWriter(file); writer.write(getResourceString("script.groovy")); writer.close(); boolean result = commands.modifyWfsTx("buffer.groovy", file); assertTrue(result); verifyHttp(server).once(method(Method.PUT), uri("/geoserver/rest/scripts/wfs/tx/buffer.groovy")); }
Example #19
Source File: GeoWebCacheCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void seed() throws Exception { String url = "/geoserver/gwc/rest/seed/topp:states.xml"; whenHttp(server).match(post(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); GeoWebCacheCommands commands = new GeoWebCacheCommands(); commands.setGeoserver(geoserver); String name = "topp:states"; String bounds = "0,0,100,100"; String gridSet = "EPSG:4326"; int start = 0; int stop = 5; String format = "image/png"; int threads = 4; boolean result = commands.seed(name, bounds, gridSet, start, stop, format, threads); assertTrue(result); String actual = server.getCalls().get(0).getPostBody(); String expected = "<seedRequest><name>topp:states</name><bounds><coords><double>0</double><double>100</double>" + "<double>0</double><double>100</double></coords></bounds><gridSetId>EPSG:4326</gridSetId>" + "<zoomStart>0</zoomStart><zoomStop>5</zoomStop><format>image/png</format><type>seed</type>" + "<threadCount>4</threadCount></seedRequest>"; assertEquals(expected, actual); verifyHttp(server).once(method(Method.POST), uri(url)); }
Example #20
Source File: VulasCliTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testCleanGoal() throws GoalConfigurationException, GoalExecutionException { // Mock REST services this.configureBackendServiceUrl(server); this.setupMockServices(this.testApp); final String[] args = new String[] { "-goal", "clean" }; VulasCli.main(args); // Check the HTTP calls made verifyHttp(server).times(1, method(Method.POST), uri("/backend" + PathBuilder.app(testApp))); verifyHttp(server).times(2, method(Method.POST), uri("/backend" + PathBuilder.goalExcecutions(null, null, this.testApp))); }
Example #21
Source File: LayerCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void getLayer() throws Exception { String url = "/geoserver/rest/layers/streams.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("layer.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); LayerCommands commands = new LayerCommands(); commands.setGeoserver(geoserver); String actual = commands.get("streams"); String expected = "streams" + OsUtils.LINE_SEPARATOR + " Title: null" + OsUtils.LINE_SEPARATOR + " Type: VECTOR" + OsUtils.LINE_SEPARATOR + " Abstract: null" + OsUtils.LINE_SEPARATOR + " Default Style: simple_streams" + OsUtils.LINE_SEPARATOR + " Namespace: Type String: VECTOR" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #22
Source File: GeoWebCacheCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void reseed() throws Exception { String url = "/geoserver/gwc/rest/seed/topp:states.xml"; whenHttp(server).match(post(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); GeoWebCacheCommands commands = new GeoWebCacheCommands(); commands.setGeoserver(geoserver); String name = "topp:states"; String bounds = "0,0,100,100"; String gridSet = "EPSG:4326"; int start = 0; int stop = 5; String format = "image/png"; int threads = 4; boolean result = commands.reseed(name, bounds, gridSet, start, stop, format, threads); assertTrue(result); String actual = server.getCalls().get(0).getPostBody(); String expected = "<seedRequest><name>topp:states</name><bounds><coords><double>0</double><double>100</double>" + "<double>0</double><double>100</double></coords></bounds><gridSetId>EPSG:4326</gridSetId>" + "<zoomStart>0</zoomStart><zoomStop>5</zoomStop><format>image/png</format><type>reseed</type>" + "<threadCount>4</threadCount></seedRequest>"; assertEquals(expected, actual); verifyHttp(server).once(method(Method.POST), uri(url)); }
Example #23
Source File: CoverageCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void createCoverage() throws Exception { String url = "/geoserver/rest/workspaces/nurc/coveragestores/mosaic/coverages.xml"; whenHttp(server).match(post(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); CoverageCommands commands = new CoverageCommands(); commands.setGeoserver(geoserver); String workspace = "nurc"; String coveragestore = "mosaic"; String coverage = "new"; String title = null; String description = null; String keywords = null; String srs = null; boolean enabled = true; boolean result = commands.create(workspace, coveragestore, coverage, title, description, keywords, srs, enabled); assertTrue(result); String expected = "<coverage><metadata /><keywords /><metadataLinks /><supportedFormats /><name>new</name><enabled>true</enabled></coverage>"; String actual = server.getCalls().get(0).getPostBody(); assertEquals(expected, actual); verifyHttp(server).once(method(Method.POST), uri(url)); }
Example #24
Source File: ScriptCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void createApp() throws Exception { whenHttp(server).match(put("/geoserver/rest/scripts/apps/buffer/main.groovy")).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); ScriptCommands commands = new ScriptCommands(); commands.setGeoserver(geoserver); File file = File.createTempFile("buffer", ".groovy"); FileWriter writer = new FileWriter(file); writer.write(getResourceString("script.groovy")); writer.close(); boolean result = commands.createApp("buffer", "groovy", file); assertTrue(result); verifyHttp(server).once(method(Method.PUT), uri("/geoserver/rest/scripts/apps/buffer/main.groovy")); }
Example #25
Source File: NamespaceCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void createNamespace() throws Exception { whenHttp(server).match(post("/geoserver/rest/namespaces")).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); NamespaceCommands commands = new NamespaceCommands(); commands.setGeoserver(geoserver); boolean actual = commands.create("topp","http://topp.org"); assertTrue(actual); String expectedXml = "<namespace><prefix>topp</prefix><uri>http://topp.org</uri></namespace>"; String actualXml = server.getCalls().get(0).getPostBody(); assertEquals(expectedXml, actualXml); verifyHttp(server).once(method(Method.POST), uri("/geoserver/rest/namespaces")); }
Example #26
Source File: SecurityCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void getAclCatalog() throws Exception { String url = "/geoserver/rest/security/acl/catalog.json"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("acl_catalog.json")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); SecurityCommands commands = new SecurityCommands(); commands.setGeoserver(geoserver); String result = commands.getAclCatalog(); assertEquals("HIDE", result); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #27
Source File: ScriptCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void getSession() throws Exception { whenHttp(server).match(get("/geoserver/rest/sessions/groovy/1")).then(stringContent(getResourceString("session.json")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); ScriptCommands commands = new ScriptCommands(); commands.setGeoserver(geoserver); String actual = commands.getSession("groovy","1"); String expected = "1 groovy" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri("/geoserver/rest/sessions/groovy/1")); }
Example #28
Source File: OWSCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listWmsSettingsForWorkspace() throws Exception { String url = "/geoserver/rest/services/wms/workspaces/topp/settings.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("wms.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); OWSCommands commands = new OWSCommands(); commands.setGeoserver(geoserver); String actual = commands.wmsList("topp"); String expected = "WMS" + OsUtils.LINE_SEPARATOR + " Enabled: true" + OsUtils.LINE_SEPARATOR + " Cite Compliant: false" + OsUtils.LINE_SEPARATOR + " Schema Base URL: http://schemas.opengis.net" + OsUtils.LINE_SEPARATOR + " Verbose: false" + OsUtils.LINE_SEPARATOR + " Interpolation: Nearest" + OsUtils.LINE_SEPARATOR + " Max Buffer: 0" + OsUtils.LINE_SEPARATOR + " Max Request Memory: 0" + OsUtils.LINE_SEPARATOR + " Max Rendering Time: 0" + OsUtils.LINE_SEPARATOR + " Max Rendering Errors: 0" + OsUtils.LINE_SEPARATOR + " Watermark:" + OsUtils.LINE_SEPARATOR + " Enabled: false" + OsUtils.LINE_SEPARATOR + " Position: BOT_RIGHT" + OsUtils.LINE_SEPARATOR + " Transparency: 100" + OsUtils.LINE_SEPARATOR + " Versions:" + OsUtils.LINE_SEPARATOR + " 1.1.1" + OsUtils.LINE_SEPARATOR + " 1.3.0" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #29
Source File: LayerGroupCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void deleteLayerGroup() throws Exception { String url = "/geoserver/rest/layergroups/spearfish.xml"; whenHttp(server).match(delete(url)).then(stringContent("true"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); LayerGroupCommands commands = new LayerGroupCommands(); commands.setGeoserver(geoserver); boolean result = commands.delete("spearfish", null); assertTrue(result); verifyHttp(server).once(method(Method.DELETE), uri(url)); }
Example #30
Source File: LayerGroupCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listLayerGroupsWithWorkspace() throws Exception { String url = "/geoserver/rest/workspaces/topp/layergroups.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("layergroups.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); LayerGroupCommands commands = new LayerGroupCommands(); commands.setGeoserver(geoserver); String actual = commands.list("topp"); String expected = "basemap" + OsUtils.LINE_SEPARATOR + "census" + OsUtils.LINE_SEPARATOR + "spearfish" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }