예제 #1
0
  @Test
  public void testPostXSLT() throws Exception {
    String xslt =
        FileUtils.readFileToString(
            new File("src/test/resources/org/geoserver/wfs/xslt/general2.xslt"));

    // test for missing params
    MockHttpServletResponse response =
        postAsServletResponse(
            "rest/services/wfs/transforms?name=general2", xslt, "application/xslt+xml");
    assertEquals(400, response.getStatusCode());

    // now pass all
    response =
        postAsServletResponse(
            "rest/services/wfs/transforms?name=general2&sourceFormat=gml&outputFormat=HTML&outputMimeType=text/html",
            xslt,
            "application/xslt+xml");
    assertEquals(201, response.getStatusCode());
    assertNotNull(response.getHeader("Location"));
    assertTrue(response.getHeader("Location").endsWith("/rest/services/wfs/transforms/general2"));

    TransformInfo info = repository.getTransformInfo("general2");
    assertNotNull(info);
    assertEquals("gml", info.getSourceFormat());
    assertEquals("HTML", info.getOutputFormat());
    assertEquals("text/html", info.getOutputMimeType());
  }
예제 #2
0
  @Test
  public void testPutXML() throws Exception {
    // let's change the output format
    String xml =
        "<transform>\n"
            + "  <sourceFormat>text/xml; subtype=gml/2.1.2</sourceFormat>\n"
            + "  <outputFormat>text/html</outputFormat>\n"
            + "  <fileExtension>html</fileExtension>\n"
            + "  <xslt>general.xslt</xslt>\n"
            + "</transform>";

    MockHttpServletResponse response =
        putAsServletResponse("rest/services/wfs/transforms/general", xml, "text/xml");
    assertEquals(200, response.getStatusCode());

    TransformInfo info = repository.getTransformInfo("general");
    assertEquals("text/html", info.getOutputFormat());
  }