コード例 #1
0
ファイル: WMSLayerTest.java プロジェクト: rockgis/geoserver
  @Test
  public void testPostAsJSON() throws Exception {
    if (!RemoteOWSTestSupport.isRemoteWMSStatesAvailable(LOGGER)) {
      LOGGER.warning("Skipping layer posting test as remote server is not available");
      return;
    }

    assertNull(catalog.getResourceByName("sf", "bugsites", WMSLayerInfo.class));

    String json =
        "{"
            + "'wmsLayer':{"
            + "'name':'bugsites',"
            + "'nativeName':'og:bugsites',"
            + "'srs':'EPSG:4326',"
            + "'nativeCRS':'EPSG:4326',"
            + "'store':'demo'"
            + "}"
            + "}";
    MockHttpServletResponse response =
        postAsServletResponse("/rest/workspaces/sf/wmsstores/demo/wmslayers/", json, "text/json");

    assertEquals(201, response.getStatusCode());
    assertNotNull(response.getHeader("Location"));
    assertTrue(
        response
            .getHeader("Location")
            .endsWith("/workspaces/sf/wmsstores/demo/wmslayers/bugsites"));

    WMSLayerInfo layer = catalog.getResourceByName("sf", "bugsites", WMSLayerInfo.class);
    assertNotNull(layer.getNativeBoundingBox());
  }
コード例 #2
0
ファイル: WMSLayerTest.java プロジェクト: rockgis/geoserver
  @Test
  public void testPostAsXML() throws Exception {
    if (!RemoteOWSTestSupport.isRemoteWMSStatesAvailable(LOGGER)) {
      LOGGER.warning("Skipping layer posting test as remote server is not available");
      return;
    }

    assertNull(catalog.getResourceByName("sf", "bugsites", WMSLayerInfo.class));

    String xml =
        "<wmsLayer>"
            + "<name>bugsites</name>"
            + "<nativeName>og:bugsites</nativeName>"
            + "<srs>EPSG:4326</srs>"
            + "<nativeCRS>EPSG:4326</nativeCRS>"
            + "<store>demo</store>"
            + "</wmsLayer>";
    MockHttpServletResponse response =
        postAsServletResponse("/rest/workspaces/sf/wmsstores/demo/wmslayers/", xml, "text/xml");

    assertEquals(201, response.getStatusCode());
    assertNotNull(response.getHeader("Location"));
    assertTrue(
        response
            .getHeader("Location")
            .endsWith("/workspaces/sf/wmsstores/demo/wmslayers/bugsites"));

    WMSLayerInfo layer = catalog.getResourceByName("sf", "bugsites", WMSLayerInfo.class);
    assertNotNull(layer.getNativeBoundingBox());
  }