Exemplo n.º 1
0
  @Test
  public void testElevationSecond() throws Exception {
    String request = getWaterTempElevationRequest("100.0");

    MockHttpServletResponse response = postAsServletResponse("wcs", request);
    assertEquals("image/tiff", response.getContentType());

    // save
    File tiffFile = File.createTempFile("wcs", "", new File("target"));
    IOUtils.copy(getBinaryInputStream(response), new FileOutputStream(tiffFile));

    // make sure we can read the coverage back
    GeoTiffReader reader = new GeoTiffReader(tiffFile);
    GridCoverage2D result = reader.read(null);

    /*
     gdallocationinfo NCOM_wattemp_100_20081101T0000000_12.tiff  10 10
     Report:
      Location: (10P,10L)
      Band 1:
      Value: 13.337999683572
    */

    // check a pixel
    double[] pixel = new double[1];
    result.getRenderedImage().getData().getPixel(10, 10, pixel);
    assertEquals(13.337999683572, pixel[0], 1e-6);

    tiffFile.delete();
  }
Exemplo n.º 2
0
  public void testPlainAddition() throws Exception { // Standard Test A.4.4.3
    String xml =
        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\r\n"
            + "<wps:Execute service=\"WPS\" version=\"1.0.0\"\r\n"
            + "        xmlns:wps=\"http://www.opengis.net/wps/1.0.0\" xmlns:ows=\"http://www.opengis.net/ows/1.1\"\r\n"
            + "        xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n"
            + "        <ows:Identifier>gt:DoubleAddition</ows:Identifier>\r\n"
            + "        <wps:DataInputs>\r\n"
            + "                <wps:Input>\r\n"
            + "                        <ows:Identifier>input_a</ows:Identifier>\r\n"
            + "                        <wps:Data>\r\n"
            + "                                <wps:LiteralData>7</wps:LiteralData>\r\n"
            + "                        </wps:Data>\r\n"
            + "                </wps:Input>\r\n"
            + "                <wps:Input>\r\n"
            + "                        <ows:Identifier>input_b</ows:Identifier>\r\n"
            + "                        <wps:Data>\r\n"
            + "                                <wps:LiteralData>7</wps:LiteralData>\r\n"
            + "                        </wps:Data>\r\n"
            + "                </wps:Input>\r\n"
            + "        </wps:DataInputs>\r\n"
            + "        <wps:ResponseForm>\r\n"
            + "                <wps:RawDataOutput>\r\n"
            + "                        <ows:Identifier>result</ows:Identifier>\r\n"
            + "                </wps:RawDataOutput>\r\n"
            + "        </wps:ResponseForm>\r\n"
            + "</wps:Execute>";

    MockHttpServletResponse response = postAsServletResponse(root(), xml);
    assertEquals("text/plain", response.getContentType());
    assertEquals("14.0", response.getOutputStreamContent());
  }
Exemplo n.º 3
0
  public void testShapeZip() throws Exception {
    String xml =
        "<wps:Execute service='WPS' version='1.0.0' xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
            + "xmlns:wps='http://www.opengis.net/wps/1.0.0' xmlns:wfs='http://www.opengis.net/wfs' "
            + "xmlns:ows='http://www.opengis.net/ows/1.1'>"
            + "<ows:Identifier>gt:BufferFeatureCollection</ows:Identifier>"
            + "<wps:DataInputs>"
            + "    <wps:Input>\n"
            + "<ows:Identifier>features</ows:Identifier>"
            + "<wps:Data>"
            + "<wps:ComplexData>"
            + readFileIntoString("states-FeatureCollection.xml")
            + "</wps:ComplexData>"
            + "</wps:Data>"
            + "</wps:Input>"
            + "<wps:Input>"
            + "<ows:Identifier>buffer</ows:Identifier>"
            + "<wps:Data>"
            + "<wps:LiteralData>10</wps:LiteralData>"
            + "</wps:Data>"
            + "</wps:Input>"
            + "</wps:DataInputs>"
            + "<wps:ResponseForm>"
            + "<wps:RawDataOutput mimeType=\"application/zip\">"
            + "<ows:Identifier>result</ows:Identifier>"
            + "</wps:RawDataOutput>"
            + "</wps:ResponseForm>"
            + "</wps:Execute>";

    MockHttpServletResponse r = postAsServletResponse("wps", xml);
    assertEquals("application/zip", r.getContentType());
    checkShapefileIntegrity(new String[] {"states"}, getBinaryInputStream(r));
  }
Exemplo n.º 4
0
  public void testInlineGeoJSON() throws Exception {
    String xml =
        "<wps:Execute service='WPS' version='1.0.0' xmlns:wps='http://www.opengis.net/wps/1.0.0' "
            + "xmlns:ows='http://www.opengis.net/ows/1.1'>"
            + "<ows:Identifier>gt:BufferFeatureCollection</ows:Identifier>"
            + "<wps:DataInputs>"
            + "<wps:Input>"
            + "<ows:Identifier>features</ows:Identifier>"
            + "<wps:Data>"
            + "<wps:ComplexData mimeType=\"application/json\"><![CDATA["
            + readFileIntoString("states-FeatureCollection.json")
            + "]]></wps:ComplexData>"
            + "</wps:Data>"
            + "</wps:Input>"
            + "<wps:Input>"
            + "<ows:Identifier>buffer</ows:Identifier>"
            + "<wps:Data>"
            + "<wps:LiteralData>10</wps:LiteralData>"
            + "</wps:Data>"
            + "</wps:Input>"
            + "</wps:DataInputs>"
            + "<wps:ResponseForm>"
            + "<wps:RawDataOutput mimeType=\"application/json\">"
            + "<ows:Identifier>result</ows:Identifier>"
            + "</wps:RawDataOutput>"
            + "</wps:ResponseForm>"
            + "</wps:Execute>";

    MockHttpServletResponse r = postAsServletResponse("wps", xml);
    assertEquals("application/json", r.getContentType());
    // System.out.println(r.getOutputStreamContent());
    FeatureCollection fc = new FeatureJSON().readFeatureCollection(r.getOutputStreamContent());
    assertEquals(2, fc.size());
  }
Exemplo n.º 5
0
  int putNewTask(int imp, String data) throws Exception {
    File zip = getTestDataFile(data);
    byte[] payload = new byte[(int) zip.length()];
    FileInputStream fis = new FileInputStream(zip);
    fis.read(payload);
    fis.close();

    MockHttpServletRequest req =
        createRequest("/rest/imports/" + imp + "/tasks/" + new File(data).getName());
    req.setHeader("Content-Type", MediaType.APPLICATION_ZIP.toString());
    req.setMethod("PUT");
    req.setBodyContent(payload);

    MockHttpServletResponse resp = dispatch(req);
    assertEquals(201, resp.getStatusCode());
    assertNotNull(resp.getHeader("Location"));

    assertTrue(resp.getHeader("Location").matches(".*/imports/" + imp + "/tasks/\\d"));
    assertEquals("application/json", resp.getContentType());

    JSONObject json = (JSONObject) json(resp);

    JSONObject task = json.getJSONObject("task");
    return task.getInt("id");
  }
Exemplo n.º 6
0
  int postNewTaskAsMultiPartForm(int imp, String data) throws Exception {
    File dir = unpack(data);

    List<Part> parts = new ArrayList<Part>();
    for (File f : dir.listFiles()) {
      parts.add(new FilePart(f.getName(), f));
    }
    MultipartRequestEntity multipart =
        new MultipartRequestEntity(
            parts.toArray(new Part[parts.size()]), new PostMethod().getParams());

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    multipart.writeRequest(bout);

    MockHttpServletRequest req = createRequest("/rest/imports/" + imp + "/tasks");
    req.setContentType(multipart.getContentType());
    req.addHeader("Content-Type", multipart.getContentType());
    req.setMethod("POST");
    req.setBodyContent(bout.toByteArray());

    MockHttpServletResponse resp = dispatch(req);
    assertEquals(201, resp.getStatusCode());
    assertNotNull(resp.getHeader("Location"));

    assertTrue(resp.getHeader("Location").matches(".*/imports/" + imp + "/tasks/\\d"));
    assertEquals("application/json", resp.getContentType());

    JSONObject json = (JSONObject) json(resp);

    JSONObject task = json.getJSONObject("task");
    return task.getInt("id");
  }
Exemplo n.º 7
0
  @Test
  public void testElevationFirst() throws Exception {
    String request = getWaterTempElevationRequest("0.0");

    MockHttpServletResponse response = postAsServletResponse("wcs", request);
    assertEquals("image/tiff", response.getContentType());

    // same result as time first
    checkTimeCurrent(response);
  }
Exemplo n.º 8
0
  public void testPlainAdditionKVP() throws Exception { // Standard Test A.4.4.3
    String request =
        "wps?service=WPS&version=1.0.0&request=Execute&Identifier=gt:DoubleAddition"
            + "&DataInputs="
            + urlEncode("input_a=7;input_b=7")
            + "&RawDataOutput=result";

    MockHttpServletResponse response = getAsServletResponse(request);
    assertEquals("text/plain", response.getContentType());
    assertEquals("14.0", response.getOutputStreamContent());
  }
 /**
  * Test basic extension functionality: mime/type, headers, not empty output generation.
  *
  * @param resp
  * @param featureName
  * @return sResponse
  * @throws Exception
  */
 public ByteArrayInputStream testBasicResult(MockHttpServletResponse resp, String featureName)
     throws Exception {
   // check mime type
   assertEquals("application/x-sqlite3", resp.getContentType());
   // check the content disposition
   assertEquals(
       "attachment; filename=" + featureName + ".sqlite", resp.getHeader("Content-Disposition"));
   ByteArrayInputStream sResponse = getBinaryInputStream(resp);
   // check for content (without checking in detail)
   assertNotNull(sResponse);
   return sResponse;
 }
Exemplo n.º 10
0
  int postNewImport() throws Exception {
    MockHttpServletResponse resp = postAsServletResponse("/rest/imports", "");

    assertEquals(201, resp.getStatusCode());
    assertNotNull(resp.getHeader("Location"));
    assertTrue(resp.getHeader("Location").matches(".*/imports/\\d"));
    assertEquals("application/json", resp.getContentType());

    JSONObject json = (JSONObject) json(resp);
    JSONObject imprt = json.getJSONObject("import");
    return imprt.getInt("id");
  }
Exemplo n.º 11
0
 public void testWKTInlineKVPRawOutput() throws Exception {
   String request =
       "wps?service=WPS&version=1.0.0&request=Execute&Identifier=gt:buffer"
           + "&DataInputs="
           + urlEncode(
               "geom1=POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))@mimetype=application/wkt;buffer=1")
           + "&RawDataOutput="
           + urlEncode("result=@mimetype=application/wkt");
   MockHttpServletResponse response = getAsServletResponse(request);
   // System.out.println(response.getOutputStreamContent());
   assertEquals("application/wkt", response.getContentType());
   Geometry g = new WKTReader().read(response.getOutputStreamContent());
   assertTrue(g instanceof Polygon);
 }
Exemplo n.º 12
0
  @Test
  public void testLayerQualified() throws Exception {
    String queryString =
        "&request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff&bbox=146,-45,147,-42"
            + "&crs=EPSG:4326&width=150&height=150";

    MockHttpServletResponse response =
        getAsServletResponse("wcs/BlueMarble/wcs?sourcecoverage=BlueMarble" + queryString);
    assertTrue(response.getContentType().startsWith("image/tiff"));
    String disposition = response.getHeader("Content-Disposition");
    assertTrue(disposition.endsWith("BlueMarble.tif"));

    Document dom = getAsDOM("wcs/DEM/wcs?sourcecoverage=BlueMarble" + queryString);
    assertEquals("ServiceExceptionReport", dom.getDocumentElement().getNodeName());
  }
Exemplo n.º 13
0
  @Test
  public void testReproject() throws Exception {
    String xml =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<GetCoverage version=\"1.0.0\" service=\"WCS\" "
            + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
            + "xmlns=\"http://www.opengis.net/wcs\" "
            + "xmlns:ows=\"http://www.opengis.net/ows/1.1\" "
            + "xmlns:gml=\"http://www.opengis.net/gml\" "
            + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
            + "xsi:schemaLocation=\"http://www.opengis.net/wcs http://schemas.opengis.net/wcs/1.0.0/getCoverage.xsd\">\n"
            + "  <sourceCoverage>"
            + getLayerId(TASMANIA_BM)
            + "</sourceCoverage>\n"
            + "  <domainSubset>\n"
            + "    <spatialSubset>\n"
            + "      <gml:Envelope srsName=\"EPSG:4326\">\n"
            + "        <gml:pos>146 -45</gml:pos>\n"
            + "        <gml:pos>147 42</gml:pos>\n"
            + "      </gml:Envelope>\n"
            + "      <gml:Grid dimension=\"2\">\n"
            + "        <gml:limits>\n"
            + "          <gml:GridEnvelope>\n"
            + "            <gml:low>0 0</gml:low>\n"
            + "            <gml:high>150 150</gml:high>\n"
            + "          </gml:GridEnvelope>\n"
            + "        </gml:limits>\n"
            + "        <gml:axisName>x</gml:axisName>\n"
            + "        <gml:axisName>y</gml:axisName>\n"
            + "      </gml:Grid>\n"
            + "    </spatialSubset>\n"
            + "  </domainSubset>\n"
            + "  <output>\n"
            + "    <crs>EPSG:3857</crs>\n"
            + "    <format>image/geotiff</format>\n"
            + "  </output>\n"
            + "</GetCoverage>";

    MockHttpServletResponse response = postAsServletResponse("wcs", xml);
    assertEquals("image/tiff", response.getContentType());

    GeoTiffFormat format = new GeoTiffFormat();
    AbstractGridCoverage2DReader reader = format.getReader(getBinaryInputStream(response));

    assertEquals(
        CRS.decode("EPSG:3857"), reader.getOriginalEnvelope().getCoordinateReferenceSystem());
  }
Exemplo n.º 14
0
  public void testProcessChaining() throws Exception {
    // chain two JTS processes
    String xml =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<wps:Execute version=\"1.0.0\" service=\"WPS\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.opengis.net/wps/1.0.0\" xmlns:wfs=\"http://www.opengis.net/wfs\" xmlns:wps=\"http://www.opengis.net/wps/1.0.0\" xmlns:ows=\"http://www.opengis.net/ows/1.1\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:wcs=\"http://www.opengis.net/wcs/1.1.1\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xsi:schemaLocation=\"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\">\n"
            + "  <ows:Identifier>JTS:area</ows:Identifier>\n"
            + "  <wps:DataInputs>\n"
            + "    <wps:Input>\n"
            + "      <ows:Identifier>geom</ows:Identifier>\n"
            + "      <wps:Reference mimeType=\"text/xml; subtype=gml/3.1.1\" xlink:href=\"http://geoserver/wps\" method=\"POST\">\n"
            + "        <wps:Execute>\n"
            + "          <ows:Identifier>JTS:buffer</ows:Identifier>\n"
            + "          <wps:DataInputs>\n"
            + "            <wps:Input>\n"
            + "              <ows:Identifier>geom</ows:Identifier>\n"
            + "              <wps:Data>\n"
            + "                <wps:ComplexData mimeType=\"application/wkt\"><![CDATA[POINT(0 0)]]></wps:ComplexData>\n"
            + "              </wps:Data>\n"
            + "            </wps:Input>\n"
            + "            <wps:Input>\n"
            + "              <ows:Identifier>distance</ows:Identifier>\n"
            + "              <wps:Data>\n"
            + "                <wps:LiteralData>10</wps:LiteralData>\n"
            + "              </wps:Data>\n"
            + "            </wps:Input>\n"
            + "          </wps:DataInputs>\n"
            + "          <wps:ResponseForm>\n"
            + "            <wps:RawDataOutput mimeType=\"text/xml; subtype=gml/3.1.1\">\n"
            + "              <ows:Identifier>result</ows:Identifier>\n"
            + "            </wps:RawDataOutput>\n"
            + "          </wps:ResponseForm>\n"
            + "        </wps:Execute>\n"
            + "      </wps:Reference>\n"
            + "    </wps:Input>\n"
            + "  </wps:DataInputs>\n"
            + "  <wps:ResponseForm>\n"
            + "    <wps:RawDataOutput>\n"
            + "      <ows:Identifier>result</ows:Identifier>\n"
            + "    </wps:RawDataOutput>\n"
            + "  </wps:ResponseForm>\n"
            + "</wps:Execute>";

    MockHttpServletResponse resp = postAsServletResponse(root(), xml);
    assertEquals("text/plain", resp.getContentType());
    // the result is inaccurate since the buffer is just a poor approximation of a circle
    assertTrue(resp.getOutputStreamContent().matches("312\\..*"));
  }
Exemplo n.º 15
0
  public void testProcessChainingKVP() throws Exception {
    String nested =
        "http://geoserver/wps?service=WPS&version=1.0.0&request=Execute&Identifier=JTS:buffer"
            + "&DataInputs="
            + urlEncode("geom=POINT(0 0)@mimetype=application/wkt;distance=10")
            + "&RawDataOutput=result";
    String request =
        "wps?service=WPS&version=1.0.0&request=Execute&Identifier=JTS:area"
            + "&DataInputs="
            + urlEncode("geom=@href=" + nested)
            + "&RawDataOutput=result";

    MockHttpServletResponse resp = getAsServletResponse(request);
    assertEquals("text/plain", resp.getContentType());
    // the result is inaccurate since the buffer is just a poor approximation of a circle
    assertTrue(resp.getOutputStreamContent().matches("312\\..*"));
  }
  /**
   * Ensures there is at most one feature at the specified location, and returns its feature id
   *
   * @param baseFeatureInfo The GetFeatureInfo request, minus x and y
   * @param x
   * @param y
   * @param layerName TODO
   * @return
   */
  Double getFeatureAt(String baseFeatureInfo, int x, int y, String layerName) throws Exception {
    MockHttpServletResponse response =
        getAsServletResponse(
            baseFeatureInfo + "&info_format=application/vnd.ogc.gml&x=" + x + "&y=" + y);
    assertEquals("application/vnd.ogc.gml", response.getContentType());
    Document doc = dom(new ByteArrayInputStream(response.getOutputStreamContent().getBytes()));
    String sCount = xpath.evaluate("count(//" + layerName + ")", doc);
    int count = Integer.valueOf(sCount);

    if (count == 0) {
      return null;
    } else if (count == 1) {
      return Double.valueOf(xpath.evaluate("//" + layerName + "/sf:GRAY_INDEX", doc));
    } else {
      fail("Found more than one feature: " + count);
      return null; // just to make the compiler happy, fail throws an unchecked exception
    }
  }
Exemplo n.º 17
0
  @Test
  public void testDoubleRequest() throws Exception {
    String request =
        "wfs?request=GetFeature&typename="
            + getLayerId(MockData.BUILDINGS)
            + ","
            + getLayerId(MockData.BRIDGES)
            + "&version=1.0.0&service=wfs&outputFormat=OGR-KML";
    MockHttpServletResponse resp = getAsServletResponse(request);

    // check content type
    assertEquals("application/zip", resp.getContentType());

    // check content disposition
    assertEquals("attachment; filename=Buildings.zip", resp.getHeader("Content-Disposition"));

    // read back
    ZipInputStream zis = new ZipInputStream(getBinaryInputStream(resp));

    // get buildings entry
    ZipEntry entry = null;
    entry = zis.getNextEntry();
    while (entry != null) {
      if (entry.getName().equals("Buildings.kml")) {
        break;
      }
      entry = zis.getNextEntry();
    }

    assertNotNull(entry);
    assertEquals("Buildings.kml", entry.getName());

    // parse the kml to check it's really xml...
    Document dom = dom(zis);
    // print(dom);

    // some very light assumptions on the contents, since we
    // cannot control how ogr encodes the kml... let's just assess
    // it's kml with the proper number of features
    assertEquals("kml", dom.getDocumentElement().getTagName());
    assertEquals(2, dom.getElementsByTagName("Placemark").getLength());
  }
  @Test
  public void testHTMLGetFeatureInfoCharset() throws Exception {
    String layer = getLayerId(MockData.FORESTS);
    String request =
        "wms?version=1.1.1&bbox=-0.002,-0.002,0.002,0.002&styles=&format=jpeg"
            + "&request=GetFeatureInfo&layers="
            + layer
            + "&query_layers="
            + layer
            + "&width=20&height=20&x=10&y=10"
            + "&info_format=text/html";

    MockHttpServletResponse response = getAsServletResponse(request, "");

    // MimeType
    assertEquals("text/html", response.getContentType());

    // Check if the character encoding is the one expected
    assertTrue("UTF-8".equals(response.getCharacterEncoding()));
  }
Exemplo n.º 19
0
  @Test
  public void testCreateStoredQuerySOAP() throws Exception {
    String xml =
        "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'> "
            + " <soap:Header/> "
            + " <soap:Body>"
            + "<wfs:CreateStoredQuery service='WFS' version='2.0.0' "
            + "   xmlns:wfs='http://www.opengis.net/wfs/2.0' "
            + "   xmlns:fes='http://www.opengis.org/fes/2.0' "
            + "   xmlns:gml='http://www.opengis.net/gml/3.2' "
            + "   xmlns:myns='http://www.someserver.com/myns' "
            + "   xmlns:sf='"
            + MockData.SF_URI
            + "'>"
            + "   <wfs:StoredQueryDefinition id='myStoredQuery'> "
            + "      <wfs:Parameter name='AreaOfInterest' type='gml:Polygon'/> "
            + "      <wfs:QueryExpressionText "
            + "           returnFeatureTypes='sf:PrimitiveGeoFeature' "
            + "           language='urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression' "
            + "           isPrivate='false'> "
            + "         <wfs:Query typeNames='sf:PrimitiveGeoFeature'> "
            + "            <fes:Filter> "
            + "               <fes:Within> "
            + "                  <fes:ValueReference>pointProperty</fes:ValueReference> "
            + "                  ${AreaOfInterest} "
            + "               </fes:Within> "
            + "            </fes:Filter> "
            + "         </wfs:Query> "
            + "      </wfs:QueryExpressionText> "
            + "   </wfs:StoredQueryDefinition> "
            + "</wfs:CreateStoredQuery>"
            + " </soap:Body> "
            + "</soap:Envelope> ";

    MockHttpServletResponse resp = postAsServletResponse("wfs", xml, "application/soap+xml");
    assertEquals("application/soap+xml", resp.getContentType());

    Document dom = dom(new ByteArrayInputStream(resp.getOutputStreamContent().getBytes()));
    assertEquals("soap:Envelope", dom.getDocumentElement().getNodeName());
    assertEquals(1, dom.getElementsByTagName("wfs:CreateStoredQueryResponse").getLength());
  }
Exemplo n.º 20
0
  @Test
  public void testSimpleRequest() throws Exception {
    String request =
        "wfs?request=GetFeature&typename="
            + getLayerId(MockData.BUILDINGS)
            + "&version=1.0.0&service=wfs&outputFormat=OGR-KML";
    MockHttpServletResponse resp = getAsServletResponse(request);

    // check content type
    assertEquals("application/vnd.google-earth.kml", resp.getContentType());

    // read back
    Document dom = dom(getBinaryInputStream(resp));
    // print(dom);

    // some very light assumptions on the contents, since we
    // cannot control how ogr encodes the kml... let's just assess
    // it's kml with the proper number of features
    assertEquals("kml", dom.getDocumentElement().getTagName());
    assertEquals(2, dom.getElementsByTagName("Placemark").getLength());
  }
Exemplo n.º 21
0
  @Test
  public void testDropStoredQuerySOAP() throws Exception {
    testCreateStoredQuery();

    String xml =
        "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'> "
            + " <soap:Header/> "
            + " <soap:Body>"
            + "<wfs:DropStoredQuery service='WFS' version='2.0.0' "
            + " xmlns:wfs='"
            + WFS.NAMESPACE
            + "' id='myStoredQuery'/>"
            + " </soap:Body> "
            + "</soap:Envelope> ";

    MockHttpServletResponse resp = postAsServletResponse("wfs", xml, "application/soap+xml");
    assertEquals("application/soap+xml", resp.getContentType());

    Document dom = dom(new ByteArrayInputStream(resp.getOutputStreamContent().getBytes()));
    assertEquals("soap:Envelope", dom.getDocumentElement().getNodeName());
    assertEquals(1, dom.getElementsByTagName("wfs:DropStoredQueryResponse").getLength());
  }
Exemplo n.º 22
0
  public void testWKTInlineRawOutput() throws Exception { // Standard Test A.4.4.3
    String xml =
        "<wps:Execute service='WPS' version='1.0.0' xmlns:wps='http://www.opengis.net/wps/1.0.0' "
            + "xmlns:ows='http://www.opengis.net/ows/1.1'>"
            + "<ows:Identifier>gt:buffer</ows:Identifier>"
            + "<wps:DataInputs>"
            + "<wps:Input>"
            + "<ows:Identifier>geom1</ows:Identifier>"
            + "<wps:Data>"
            + "<wps:ComplexData mimeType=\"application/wkt\">"
            + "<![CDATA[POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))]]>"
            + "</wps:ComplexData>"
            + "</wps:Data>"
            + "</wps:Input>"
            + "<wps:Input>"
            + "<ows:Identifier>buffer</ows:Identifier>"
            + "<wps:Data>"
            + "<wps:LiteralData>1</wps:LiteralData>"
            + "</wps:Data>"
            + "</wps:Input>"
            + "</wps:DataInputs>"
            + "<wps:ResponseForm>"
            + "    <wps:RawDataOutput mimeType=\"application/wkt\">"
            + "        <ows:Identifier>result</ows:Identifier>"
            + "    </wps:RawDataOutput>"
            + "  </wps:ResponseForm>"
            + "</wps:Execute>";

    // print(dom(new StringInputStream("<?xml version=\"1.0\" encoding=\"UTF-16\"?>\n" + xml)));

    MockHttpServletResponse response = postAsServletResponse("wps", xml);
    System.out.println(response.getOutputStreamContent());
    assertEquals("application/wkt", response.getContentType());
    Geometry g = new WKTReader().read(response.getOutputStreamContent());
    assertTrue(g instanceof Polygon);
  }
 /**
  * Test SPATIALITE Mime format.
  *
  * @throws Exception
  */
 public void testMIMEOutput() throws Exception {
   MockHttpServletResponse resp =
       getAsServletResponse("wfs?request=GetFeature&typeName=Points&outputFormat=spatialite");
   assertEquals("application/x-sqlite3", resp.getContentType());
 }
 /**
  * Test if exist WFS Error, checking for Mime Type. If Mime Type is "application/xml", then an
  * error has occurred
  *
  * @throws Exception
  */
 public void testWFSError() throws Exception {
   MockHttpServletResponse resp =
       getAsServletResponse("wfs?request=GetFeature&typeName=Points&outputFormat=spatialite");
   assertNotSame("application/xml", resp.getContentType());
 }