コード例 #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());
  }