Exemplo n.º 1
0
  void assertFeatureTypeList(WFSCapabilitiesType caps) {
    FeatureTypeListType ftl = caps.getFeatureTypeList();
    assertNotNull(ftl);

    assertEquals(14, ftl.getFeatureType().size());

    FeatureTypeType featureType = (FeatureTypeType) ftl.getFeatureType().get(0);
    assertEquals("poly_landmarks", featureType.getName().getLocalPart());
    assertEquals("tiger", featureType.getName().getPrefix());
    assertEquals("http://www.census.gov", featureType.getName().getNamespaceURI());

    assertEquals("urn:ogc:def:crs:EPSG::4326", featureType.getDefaultCRS());

    List<WGS84BoundingBoxType> wgs84BoundingBox = featureType.getWGS84BoundingBox();
    assertEquals(1, wgs84BoundingBox.size());

    WGS84BoundingBoxType bbox = wgs84BoundingBox.get(0);
    assertEquals("EPSG:4326", bbox.getCrs());
    assertEquals(BigInteger.valueOf(2), bbox.getDimensions());

    assertEquals(-74.047185D, (Double) bbox.getLowerCorner().get(0), 1E-6);
    assertEquals(40.679648D, (Double) bbox.getLowerCorner().get(1), 1E-6);
    assertEquals(-73.90782D, (Double) bbox.getUpperCorner().get(0), 1E-6);
    assertEquals(40.882078D, (Double) bbox.getUpperCorner().get(1), 1E-6);
  }
Exemplo n.º 2
0
  void assertOperationsMetadata(WFSCapabilitiesType caps) {
    OperationsMetadataType om = caps.getOperationsMetadata();
    assertNotNull(om);

    // assertEquals(6, om.getOperation().size());

    OperationType getCapsOp = (OperationType) om.getOperation().get(0);
    assertEquals("GetCapabilities", getCapsOp.getName());
    assertEquals(1, getCapsOp.getDCP().size());

    DCPType dcp1 = (DCPType) getCapsOp.getDCP().get(0);
    assertEquals(1, dcp1.getHTTP().getGet().size());
    assertEquals(1, dcp1.getHTTP().getPost().size());

    assertEquals(
        "http://localhost:8080/geoserver/wfs?get",
        ((RequestMethodType) dcp1.getHTTP().getGet().get(0)).getHref());
    assertEquals(
        "http://localhost:8080/geoserver/wfs?post",
        ((RequestMethodType) dcp1.getHTTP().getPost().get(0)).getHref());

    int i = 1;
    assertEquals("DescribeFeatureType", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("GetFeature", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("GetPropertyValue", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("ListStoredQueries", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("DescribeStoredQueries", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("CreateStoredQuery", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("DropStoredQuery", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("LockFeature", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("GetFeatureWithLock", ((OperationType) om.getOperation().get(i++)).getName());
    assertEquals("Transaction", ((OperationType) om.getOperation().get(i++)).getName());
  }
Exemplo n.º 3
0
  public void testParseGetCapabilitiesCuzk() throws Exception {
    configuration = new org.geotools.wfs.v2_0.WFSCapabilitiesConfiguration();

    Parser parser = new Parser(configuration);
    Object parsed = parser.parse(getClass().getResourceAsStream("cuzk-GetCapabilities_2_0_0.xml"));

    assertNotNull(parsed);
    assertTrue(parsed.getClass().getName(), parsed instanceof WFSCapabilitiesType);
    WFSCapabilitiesType caps = (WFSCapabilitiesType) parsed;

    assertNotNull(caps);
    assertEquals("2.0.0", caps.getVersion());

    FilterCapabilitiesType fct = caps.getFilterCapabilities();
    assertNotNull(fct);
  }
Exemplo n.º 4
0
  public void testParseGetCapabilitiesFMI() throws Exception {
    configuration = new org.geotools.wfs.v2_0.WFSCapabilitiesConfiguration();

    Parser parser = new Parser(configuration);
    Object parsed = parser.parse(getClass().getResourceAsStream("fmi-GetCapabilities_2_0_0.xml"));

    assertNotNull(parsed);
    assertTrue(parsed.getClass().getName(), parsed instanceof WFSCapabilitiesType);
    WFSCapabilitiesType caps = (WFSCapabilitiesType) parsed;

    assertNotNull(caps);
    assertEquals("2.0.0", caps.getVersion());

    // test stored query parsing
    // TODO:
  }
Exemplo n.º 5
0
  public void testParseGetCapabilities() throws Exception {
    configuration = new org.geotools.wfs.v2_0.WFSCapabilitiesConfiguration();

    Parser parser = new Parser(configuration);
    Object parsed =
        parser.parse(getClass().getResourceAsStream("geoserver-GetCapabilities_2_0_0.xml"));

    assertNotNull(parsed);
    assertTrue(parsed.getClass().getName(), parsed instanceof WFSCapabilitiesType);
    WFSCapabilitiesType caps = (WFSCapabilitiesType) parsed;

    assertNotNull(caps);
    assertEquals("2.0.0", caps.getVersion());
    /*
            assertServiceIdentification(caps);
            assertOperationsMetadata(caps);
            assertFeatureTypeList(caps);
            assertFilterCapabilities(caps);
    */
  }
Exemplo n.º 6
0
  public void testParseEmptyGetCapabilities() throws Exception {
    String xml =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            + "<WFS_Capabilities "
            + "  version=\"2.0.0\" "
            + "  xmlns=\"http://www.opengis.net/wfs/2.0\""
            + "  xmlns:fes=\"http://www.opengis.net/fes/2.0\""
            + "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
            + "  xsi:schemaLocation=\"http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd\">"
            + "</WFS_Capabilities>";

    configuration = new org.geotools.wfs.v2_0.WFSCapabilitiesConfiguration();

    Parser parser = new Parser(configuration);
    Object parsed = parser.parse(new ByteArrayInputStream(xml.getBytes()));
    assertNotNull(parsed);
    assertTrue(parsed.getClass().getName(), parsed instanceof WFSCapabilitiesType);
    WFSCapabilitiesType caps = (WFSCapabilitiesType) parsed;

    assertNotNull(caps);
    assertEquals("2.0.0", caps.getVersion());
  }
Exemplo n.º 7
0
  void assertFilterCapabilities(WFSCapabilitiesType caps) {
    FilterCapabilities fc = (FilterCapabilities) caps.getFilterCapabilities();

    assertNotNull(fc.getSpatialCapabilities());
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators());
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperators());
    assertEquals(11, fc.getSpatialCapabilities().getSpatialOperators().getOperators().size());

    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Disjoint"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Equals"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("DWithin"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Beyond"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Intersect"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Touches"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Crosses"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Within"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Contains"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Overlaps"));
    assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("BBOX"));

    assertNotNull(fc.getScalarCapabilities());
    assertTrue(fc.getScalarCapabilities().hasLogicalOperators());
    assertNotNull(fc.getScalarCapabilities().getArithmeticOperators());
    assertNotNull(fc.getScalarCapabilities().getComparisonOperators());

    assertTrue(fc.getScalarCapabilities().getArithmeticOperators().hasSimpleArithmetic());
    assertNotNull(fc.getScalarCapabilities().getArithmeticOperators().getFunctions());
    assertEquals(
        7,
        fc.getScalarCapabilities()
            .getArithmeticOperators()
            .getFunctions()
            .getFunctionNames()
            .size());

    Collection<Operator> operators =
        fc.getScalarCapabilities().getComparisonOperators().getOperators();

    assertEquals(3, operators.size()); // "Simple_Comparisons" is commented out on purpose

    assertNotNull(fc.getScalarCapabilities().getComparisonOperators().getOperator("Between"));
    assertNotNull(fc.getScalarCapabilities().getComparisonOperators().getOperator("Like"));
    assertNotNull(fc.getScalarCapabilities().getComparisonOperators().getOperator("NullCheck"));
  }
Exemplo n.º 8
0
  void assertServiceIdentification(WFSCapabilitiesType caps) {
    ServiceIdentificationType sa = caps.getServiceIdentification();
    assertNotNull(sa);

    assertEquals(1, sa.getKeywords().size());

    KeywordsType keywords = (KeywordsType) sa.getKeywords().get(0);
    List<String> simpleKeywords = new ArrayList<String>();
    for (Object o : keywords.getKeyword()) {
      LanguageStringType lst = (LanguageStringType) o;
      simpleKeywords.add(lst.getValue());
    }
    assertTrue(simpleKeywords.contains("WFS"));
    assertTrue(simpleKeywords.contains("WMS"));
    assertTrue(simpleKeywords.contains("GEOSERVER"));

    assertEquals("WFS", sa.getServiceType().getValue());
    assertEquals("2.0.0", sa.getServiceTypeVersion().get(0));
  }