Package com.boundlessgeo.geoserver.json

Examples of com.boundlessgeo.geoserver.json.JSONObj


        MvcResult result = mvc.perform(get("/api/workspaces/foo"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON))
            .andReturn();

        JSONObj obj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject();
        assertEquals("foo", obj.str("name"));
        assertEquals("http://scratch.org", obj.str("uri"));
        assertTrue(obj.bool("default"));

        assertEquals(0, obj.integer("maps").intValue());
        assertEquals(1, obj.integer("layers").intValue());
        assertEquals(0, obj.integer("stores").intValue());

        result = mvc.perform(get("/api/workspaces/bar"))
                .andExpect(status().isOk())
                .andExpect(content().contentType(MediaType.APPLICATION_JSON))
                .andReturn();

        obj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject();
        assertEquals("bar", obj.str("name"));
        assertEquals("http://bar.org", obj.str("uri"));
        assertFalse(obj.bool("default"));
    }
View Full Code Here


    @Test
    public void testPost() throws Exception {
        MockGeoServer.get().build(geoServer);

        JSONObj obj = new JSONObj().put("name", "foo").put("uri", "http://foo.org");

        MockHttpServletRequestBuilder request = post("/api/workspaces")
            .contentType(MediaType.APPLICATION_JSON)
            .content(obj.toString());

        MvcResult result = mvc.perform(request)
            .andExpect(status().isCreated())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON))
            .andReturn();
View Full Code Here

        MockGeoServer.get().catalog()
            .workspace("foo", "http://scratch.org", true).catalog()
            .workspace("bar", "http://bar.org", false).catalog()
            .geoServer().build(geoServer);

        JSONObj obj = new JSONObj().put("name", "blah");

        MockHttpServletRequestBuilder request = put("/api/workspaces/foo")
            .contentType(MediaType.APPLICATION_JSON)
            .content(obj.toString());

        mvc.perform(request)
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON))
            .andReturn();
View Full Code Here

        request.setMethod("post");

        createMultiPartFormContent(request, "form-data; name=\"upload\"; filename=\"point.zip\"", "application/zip",
                IOUtils.toByteArray(getClass().getResourceAsStream("point.shp.zip")));

        JSONObj result = ctrl.importFile("gs", request);

        assertEquals(1, result.array("imported").size());
        JSONObj obj = result.array("imported").object(0);

        assertEquals("gs", obj.object("layer").str("workspace"));
        assertEquals("point", obj.object("layer").str("name"));

        assertNotNull(catalog.getLayerByName("gs:point"));
    }
View Full Code Here

    @Test
    public void testCreateLayerFromCopy() throws Exception {
        Catalog catalog = getCatalog();
        assertNull(catalog.getLayerByName("sf:foo"));

        JSONObj obj = new JSONObj();
        obj.put("name", "foo");
        obj.putObject("layer")
            .put("name", "PrimitiveGeoFeature")
            .put("workspace", "sf");

        com.mockrunner.mock.web.MockHttpServletResponse resp =
            postAsServletResponse("/app/api/layers/sf", obj.toString(), MediaType.APPLICATION_JSON_VALUE);
        assertEquals(resp.getStatusCode(), 201);

        assertNotNull(catalog.getLayerByName("sf:foo"));
    }
View Full Code Here

    @Test
    public void testCreateLayerFromResource() throws Exception {
        Catalog catalog = getCatalog();
        assertNull(catalog.getLayerByName("sf:foo"));

        JSONObj obj = new JSONObj();
        obj.put("name", "foo");
        obj.putObject("resource")
            .put("name", "PrimitiveGeoFeature")
            .put("store", "sf")
            .put("workspace", "sf");

        com.mockrunner.mock.web.MockHttpServletResponse resp =
                postAsServletResponse("/app/api/layers/sf", obj.toString(), MediaType.APPLICATION_JSON_VALUE);
        assertEquals(resp.getStatusCode(), 201);

        assertNotNull(catalog.getLayerByName("sf:foo"));
    }
View Full Code Here

    public void testCreateLayerFromRasterResource() throws Exception {
        Catalog catalog = getCatalog();
        assertNull(catalog.getLayerByName("cdf:foo"));
        assertNotNull(catalog.getLayerByName("cdf:usa"));

        JSONObj obj = new JSONObj();
        obj.put("name", "foo");
        obj.putObject("resource")
                .put("name", "usa")
                .put("store", "usa")
                .put("workspace", "cdf");

        com.mockrunner.mock.web.MockHttpServletResponse resp =
            postAsServletResponse("/app/api/layers/cdf", obj.toString(), MediaType.APPLICATION_JSON_VALUE);
        assertEquals(resp.getStatusCode(), 201);

        assertNotNull(catalog.getLayerByName("cdf:foo"));

    }
View Full Code Here

    public void cleanup() throws IOException {
        FileUtils.deleteDirectory(temp.toFile());
    }

    void persistBundleInfo() throws IOException {
        JSONObj obj = new JSONObj();
        obj.put("name", options.name());

        JSONObj meta = obj.putObject("metadata");
        try {
            GeoServerInfo info = new GeoServerInfo(catalog.getResourceLoader());

            GeoServerInfo.BuildInfo suiteInfo = info.suite();
            meta.putObject("suite").put("version", suiteInfo.version()).put("revision", suiteInfo.revision());

            GeoServerInfo.BuildInfo gsInfo = info.geoserver();
            meta.putObject("geoserver").put("version", suiteInfo.version()).put("revision", suiteInfo.revision());

        } catch (Exception e) {
            throw new IOException(e);
        }
View Full Code Here

        MvcResult result = mvc.perform(get("/api/projections/epsg:3005"))
                .andExpect(status().isOk())
                .andExpect(content().contentType(MediaType.APPLICATION_JSON))
                .andReturn();

        JSONObj proj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject();
        assertEquals("EPSG:3005", proj.str("srs"));
        assertNotNull(proj.str("wkt"));
    }
View Full Code Here

    @Test
    public void testGet() {
        ctrl = new FormatController(geoServer);

        JSONObj obj = ctrl.get("shapefile");
        assertEquals("shapefile", obj.get("name"));
        assertEquals("vector", obj.get("kind"));
        assertEquals("file", obj.get("type"));

        obj = ctrl.get("h2");
        assertEquals("h2", obj.get("name"));
        assertEquals("vector", obj.get("kind"));
        assertEquals("database", obj.get("type"));

        obj = ctrl.get("geotiff");
        assertEquals("geotiff", obj.get("name"));
        assertEquals("raster", obj.get("kind"));
        assertEquals("file", obj.get("type"));

        obj = ctrl.get("wms");
        assertEquals("wms", obj.get("name"));
        assertEquals("service", obj.get("kind"));

        try {
            ctrl.get("foo");
            fail();
        }
View Full Code Here

TOP

Related Classes of com.boundlessgeo.geoserver.json.JSONObj

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.