org.springframework.shell.support.util.OsUtils Java Examples
The following examples show how to use
org.springframework.shell.support.util.OsUtils.
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: LayerCommands.java From geoserver-shell with MIT License | 6 votes |
@CliCommand(value = "layer style list", help = "List the Styles for a layer.") public String listStyles( @CliOption(key = "name", mandatory = true, help = "The name") String name ) throws Exception { String url = geoserver.getUrl() + "/rest/layers/" + URLUtil.encode(name) + "/styles.xml"; String xml = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword()); Element element = JDOMBuilder.buildElement(xml); List<Element> styleElements = element.getChildren("style"); List<String> names = new ArrayList<String>(); for (Element styleElement : styleElements) { names.add(styleElement.getChildText("name")); } Collections.sort(names); StringBuilder builder = new StringBuilder(); for (String nm : names) { builder.append(nm).append(OsUtils.LINE_SEPARATOR); } return builder.toString(); }
Example #2
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 #3
Source File: StreamListRenderer.java From Decision with Apache License 2.0 | 6 votes |
@Override public String render(List<StratioStream> streams) throws ShellException { StringBuilder queryTables = new StringBuilder(); List<Map<String, Object>> data = new ArrayList<>(); for (StratioStream stratioStream : streams) { Map<String, Object> row = new HashMap<>(); row.put(STREAM_NAME, stratioStream.getStreamName()); row.put(USER_DEFINED, stratioStream.getUserDefined()); row.put(QUERIES, stratioStream.getQueries().size()); row.put(ELEMENTS, stratioStream.getColumns().size()); row.put(ACTIVE_ACTIONS, stratioStream.getActiveActions().toString()); queryTables.append(renderQueriesTable(stratioStream.getQueries(), stratioStream.getStreamName())); data.add(row); } StringBuilder result = new StringBuilder(); result.append(TableRenderer.renderMapDataAsTable(data, columns)); result.append(OsUtils.LINE_SEPARATOR); result.append(queryTables); return result.toString(); }
Example #4
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 #5
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 #6
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 #7
Source File: DataStoreCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void getDataStore() throws Exception { String url = "/geoserver/rest/workspaces/topp/datastores/taz_shapes.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("datastore.xml")), 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 actual = commands.get("topp", "taz_shapes"); String expected = "taz_shapes" + OsUtils.LINE_SEPARATOR + " Enabled? true" + OsUtils.LINE_SEPARATOR + " Description: null" + OsUtils.LINE_SEPARATOR + " Store Type: null" + OsUtils.LINE_SEPARATOR + " Type: UNKNOWN" + OsUtils.LINE_SEPARATOR + " Workspace: topp" + OsUtils.LINE_SEPARATOR + " Connection Parameters:" + OsUtils.LINE_SEPARATOR + " namespace: http://www.openplans.org/topp" + OsUtils.LINE_SEPARATOR + " url: file:data/taz_shapes" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #8
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 #9
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 #10
Source File: TemplateCommands.java From geoserver-shell with MIT License | 6 votes |
@CliCommand(value = "template list", help = "List templates.") public String list( @CliOption(key = "workspace", mandatory = false, help = "The workspace") String workspace, @CliOption(key = "datastore", mandatory = false, help = "The datastore") String datastore, @CliOption(key = "featuretype", mandatory = false, help = "The featuretype") String featureType, @CliOption(key = "coveragestore", mandatory = false, help = "The coveragestore") String coverageStore, @CliOption(key = "coverage", mandatory = false, help = "The coverage") String coverage ) throws Exception { StringBuilder urlBuilder = buildUrl(geoserver.getUrl(), workspace, datastore, featureType, coverageStore, coverage); urlBuilder.append("/templates.xml"); String xml = HTTPUtils.get(urlBuilder.toString(), geoserver.getUser(), geoserver.getPassword()); Element rootElement = JDOMBuilder.buildElement(xml); List<Element> templateElements = rootElement.getChildren("template"); List<String> names = new ArrayList<String>(); Collections.sort(names); for (Element templateElement : templateElements) { names.add(templateElement.getChildText("name")); } StringBuilder builder = new StringBuilder(); for (String name : names) { builder.append(name).append(OsUtils.LINE_SEPARATOR); } return builder.toString(); }
Example #11
Source File: AboutCommands.java From geoserver-shell with MIT License | 6 votes |
@CliCommand(value = "version list", help = "Get versions.") public String versionList() throws Exception { String TAB = " "; String xml = HTTPUtils.get(geoserver.getUrl() + "/rest/about/versions.xml", geoserver.getUser(), geoserver.getPassword()); StringBuilder builder = new StringBuilder(); Element root = JDOMBuilder.buildElement(xml); List<Element> resources = root.getChildren("resource"); for (Element resource : resources) { String name = resource.getAttributeValue("name"); String buildTime = resource.getChildText("Build-Timestamp"); String gitRevision = resource.getChildText("Git-Revision"); String version = resource.getChildText("Version"); builder.append(name).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Version: ").append(version).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Build Time: ").append(buildTime).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Git Revision: ").append(gitRevision).append(OsUtils.LINE_SEPARATOR); builder.append(OsUtils.LINE_SEPARATOR); } return builder.toString(); }
Example #12
Source File: OWSCommandsTest.java From geoserver-shell with MIT License | 6 votes |
@Test public void listWcsSettingsForWorkspace() throws Exception { String url = "/geoserver/rest/services/wcs/workspaces/topp/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("topp"); 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 #13
Source File: ScriptCommands.java From geoserver-shell with MIT License | 6 votes |
@CliCommand(value = "scripting session list", help = "List scripting sessions.") public String listSession( @CliOption(key = "ext", mandatory = false, help = "The script extension") String ext ) throws Exception { String url = geoserver.getUrl() + "/rest/sessions"; if (ext != null) { url += "/" + URLUtil.encode(ext); } String result = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword()); JSONObject rootJsonObject = new JSONObject(result); JSONArray jsonArray = rootJsonObject.getJSONArray("sessions"); StringBuilder builder = new StringBuilder(); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); builder.append(jsonObject.getString("id")).append(" ") .append(jsonObject.get("engine")) .append(OsUtils.LINE_SEPARATOR); } return builder.toString(); }
Example #14
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 #15
Source File: CoverageStoreCommands.java From geoserver-shell with MIT License | 6 votes |
@CliCommand(value = "coverage store get", help = "Get a coverage store.") public String get( @CliOption(key = "workspace", mandatory = true, help = "The workspace") String workspace, @CliOption(key = "coveragestore", mandatory = true, help = "The coveragestore") String coveragestore ) throws Exception { String url = geoserver.getUrl() + "/rest/workspaces/" + URLUtil.encode(workspace) + "/coveragestores/" + URLUtil.encode(coveragestore) + ".xml"; String xml = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword()); Element coverageStoreElement = JDOMBuilder.buildElement(xml); String name = coverageStoreElement.getChildText("name"); String type = coverageStoreElement.getChildText("type"); String enabled = coverageStoreElement.getChildText("enabled"); String covUrl = coverageStoreElement.getChildText("url"); // @TODO RESTCoverageStore doesn't have access to type, enabled /*GeoServerRESTReader reader = new GeoServerRESTReader(geoserver.getUrl(), geoserver.getUser(), geoserver.getPassword()); RESTCoverageStore store = reader.getCoverageStore(workspace, coveragestore);*/ String TAB = " "; StringBuilder builder = new StringBuilder(); builder.append(name).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Type: ").append(type).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("URL: ").append(covUrl).append(OsUtils.LINE_SEPARATOR); builder.append(TAB).append("Enabled: ").append(enabled).append(OsUtils.LINE_SEPARATOR); return builder.toString(); }
Example #16
Source File: DataStoreCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listDataStores() throws Exception { String url = "/geoserver/rest/workspaces/topp/datastores.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("datastores.xml")), 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 actual = commands.list("topp"); String expected = "geology" + OsUtils.LINE_SEPARATOR + "rivers" + OsUtils.LINE_SEPARATOR + "states" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #17
Source File: LayerGroupCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void getLayerGroup() throws Exception { String url = "/geoserver/rest/layergroups/spearfish.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("layergroup.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.get("spearfish", null); String expected = "spearfish" + OsUtils.LINE_SEPARATOR + " Title: null" + OsUtils.LINE_SEPARATOR + " Abstract: null" + OsUtils.LINE_SEPARATOR + " Workspace: null" + OsUtils.LINE_SEPARATOR + " Mode: SINGLE" + OsUtils.LINE_SEPARATOR + " CRS: EPSG:26713" + OsUtils.LINE_SEPARATOR + " Bounds: 589425.9342365642, 4913959.224611808, 609518.6719560538, 4928082.949945881" + OsUtils.LINE_SEPARATOR + " Layers: " + OsUtils.LINE_SEPARATOR + " None" + OsUtils.LINE_SEPARATOR + " Publishables: " + OsUtils.LINE_SEPARATOR + " sfdem" + OsUtils.LINE_SEPARATOR + " streams" + OsUtils.LINE_SEPARATOR + " roads" + OsUtils.LINE_SEPARATOR + " restricted" + OsUtils.LINE_SEPARATOR + " archsites" + OsUtils.LINE_SEPARATOR + " bugsites" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #18
Source File: OWSCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listWfsSettings() throws Exception { String url = "/geoserver/rest/services/wfs/settings.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("wfs.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.wfsList(null); String expected = "WFS" + 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 + " serviceLevel: COMPLETE" + OsUtils.LINE_SEPARATOR + " maxFeatures: 1000000" + OsUtils.LINE_SEPARATOR + " featureBounding: true" + OsUtils.LINE_SEPARATOR + " canonicalSchemaLocation: false" + OsUtils.LINE_SEPARATOR + " encodeFeatureMember: false" + OsUtils.LINE_SEPARATOR + " GML:" + OsUtils.LINE_SEPARATOR + " Version: V_20" + OsUtils.LINE_SEPARATOR + " SRS Name Style: URN2" + OsUtils.LINE_SEPARATOR + " Override GML Attributes: false" + OsUtils.LINE_SEPARATOR + " Version: V_10" + OsUtils.LINE_SEPARATOR + " SRS Name Style: XML" + OsUtils.LINE_SEPARATOR + " Override GML Attributes: true" + OsUtils.LINE_SEPARATOR + " Version: V_11" + OsUtils.LINE_SEPARATOR + " SRS Name Style: URN" + OsUtils.LINE_SEPARATOR + " Override GML Attributes: false" + OsUtils.LINE_SEPARATOR + " Versions:" + OsUtils.LINE_SEPARATOR + " 1.0.0" + OsUtils.LINE_SEPARATOR + " 1.1.0" + OsUtils.LINE_SEPARATOR + " 2.0.0" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }
Example #19
Source File: LayerGroupCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listLayerGroups() throws Exception { String url = "/geoserver/rest/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(null); 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)); }
Example #20
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 #21
Source File: ScriptCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listSession() throws Exception { whenHttp(server).match(get("/geoserver/rest/sessions")).then(stringContent(getResourceString("sessions.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.listSession(null); String expected = "0 groovy" + OsUtils.LINE_SEPARATOR + "1 python" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri("/geoserver/rest/sessions")); }
Example #22
Source File: ScriptCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listApp() throws Exception { whenHttp(server).match(get("/geoserver/rest/scripts/apps.json")).then(stringContent(getResourceString("scripts.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.listApps(); String expected = "buffer.groovy" + OsUtils.LINE_SEPARATOR + "merge.groovy" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri("/geoserver/rest/scripts/apps.json")); }
Example #23
Source File: NamespaceCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void getDefaultNamespace() throws Exception { whenHttp(server).match(get("/geoserver/rest/namespaces/default.xml")).then(stringContent("<namespace><prefix>cite</prefix><uri>http://cite.org</uri></namespace>"), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); NamespaceCommands commands = new NamespaceCommands(); commands.setGeoserver(geoserver); String actual = commands.getDefault(); String expected = "cite" + OsUtils.LINE_SEPARATOR + "http://cite.org"; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri("/geoserver/rest/namespaces/default.xml")); }
Example #24
Source File: ScriptCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listWfsTx() throws Exception { whenHttp(server).match(get("/geoserver/rest/scripts/wfs/tx.json")).then(stringContent(getResourceString("scripts.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.listWfsTx(); String expected = "buffer.groovy" + OsUtils.LINE_SEPARATOR + "merge.groovy" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri("/geoserver/rest/scripts/wfs/tx.json")); }
Example #25
Source File: ScriptCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listFunction() throws Exception { whenHttp(server).match(get("/geoserver/rest/scripts/function.json")).then(stringContent(getResourceString("scripts.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.listFunctions(); String expected = "buffer.groovy" + OsUtils.LINE_SEPARATOR + "merge.groovy" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri("/geoserver/rest/scripts/function.json")); }
Example #26
Source File: ScriptCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listWps() throws Exception { whenHttp(server).match(get("/geoserver/rest/scripts/wps.json")).then(stringContent(getResourceString("scripts.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.listWps(); String expected = "buffer.groovy" + OsUtils.LINE_SEPARATOR + "merge.groovy" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri("/geoserver/rest/scripts/wps.json")); }
Example #27
Source File: LayerGroupCommands.java From geoserver-shell with MIT License | 5 votes |
@CliCommand(value = "layer group list", help = "List layer groups.") public String list( @CliOption(key = "workspace", mandatory = false, help = "The workspace") String workspace ) throws Exception { StringBuilder builder = new StringBuilder(); GeoServerRESTReader reader = new GeoServerRESTReader(geoserver.getUrl(), geoserver.getUser(), geoserver.getPassword()); RESTLayerGroupList layerGroups = workspace == null ? reader.getLayerGroups() : reader.getLayerGroups(workspace); List<String> names = layerGroups.getNames(); Collections.sort(names); for (String name : names) { builder.append(name + OsUtils.LINE_SEPARATOR); } return builder.toString(); }
Example #28
Source File: FontCommands.java From geoserver-shell with MIT License | 5 votes |
@CliCommand(value = "font list", help = "List fonts.") public String list( @CliOption(key = "search", mandatory = false, help = "The font name search string") String search ) throws Exception { String fonts = HTTPUtils.get(geoserver.getUrl() + "/rest/fonts.xml", geoserver.getUser(), geoserver.getPassword()); List<String> names = getFontNames(fonts); Collections.sort(names); StringBuilder builder = new StringBuilder(); for (String name : names) { if (search == null || name.startsWith(search)) { builder.append(name).append(OsUtils.LINE_SEPARATOR); } } return builder.toString(); }
Example #29
Source File: NamespaceCommands.java From geoserver-shell with MIT License | 5 votes |
@CliCommand(value = "namespace default get", help = "Get the default namespace.") public String getDefault() throws Exception { String result = HTTPUtils.get(geoserver.getUrl() + "/rest/namespaces/default.xml", geoserver.getUser(), geoserver.getPassword()); Element elem = JDOMBuilder.buildElement(result); StringBuilder builder = new StringBuilder(); builder.append(elem.getChildText("prefix")).append(OsUtils.LINE_SEPARATOR); builder.append(elem.getChildText("uri")); return builder.toString(); }
Example #30
Source File: StyleCommandsTest.java From geoserver-shell with MIT License | 5 votes |
@Test public void listStylesWithWorkspace() throws Exception { String url = "/geoserver/rest/workspaces/topp/styles.xml"; whenHttp(server).match(get(url)).then(stringContent(getResourceString("styles.xml")), status(HttpStatus.OK_200)); Geoserver geoserver = new Geoserver("http://00.0.0.0:8888/geoserver", "admin", "geoserver"); StyleCommands commands = new StyleCommands(); commands.setGeoserver(geoserver); String actual = commands.list("topp"); String expected = "burg" + OsUtils.LINE_SEPARATOR + "capitals" + OsUtils.LINE_SEPARATOR + "cite_lakes" + OsUtils.LINE_SEPARATOR + "dem" + OsUtils.LINE_SEPARATOR; assertEquals(expected, actual); verifyHttp(server).once(method(Method.GET), uri(url)); }