public void testLayer() throws Exception {

    String layerId = getLayerId(MockData.PRIMITIVEGEOFEATURE);
    LayerInfo layer = getCatalog().getLayerByName(layerId);
    addAuthUrl("layerAuth1", "http://geoserver/wms/auth1", layer.getAuthorityURLs());
    addIdentifier("layerAuth1", "layerId1", layer.getIdentifiers());
    getCatalog().save(layer);

    Document doc =
        getAsDOM(
            "sf/PrimitiveGeoFeature/wms?service=WMS&request=getCapabilities&version=1.3.0", true);

    String layerName = MockData.PRIMITIVEGEOFEATURE.getLocalPart();
    assertXpathExists(
        "//wms:Layer[wms:Name='" + layerName + "']/wms:AuthorityURL[@name = 'layerAuth1']", doc);
    assertXpathEvaluatesTo(
        "http://geoserver/wms/auth1",
        "//wms:Layer[wms:Name='"
            + layerName
            + "']/wms:AuthorityURL[@name = 'layerAuth1']/wms:OnlineResource/@xlink:href",
        doc);

    assertXpathExists(
        "//wms:Layer[wms:Name='" + layerName + "']/wms:Identifier[@authority = 'layerAuth1']", doc);
    assertXpathEvaluatesTo(
        "layerId1",
        "//wms:Layer[wms:Name='" + layerName + "']/wms:Identifier[@authority = 'layerAuth1']",
        doc);
  }
コード例 #2
0
  @Before
  public void setUp() throws Exception {
    // setup property file
    data = File.createTempFile("retype", "data", new File("./target"));
    data.delete();
    data.mkdir();
    final String fileName = MockData.PRIMITIVEGEOFEATURE.getLocalPart() + ".properties";
    URL properties = MockData.class.getResource(fileName);
    IOUtils.copy(properties.openStream(), new File(data, fileName));

    // build a feature type with less attributes, extra attributes, type changes
    SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder();
    ftb.add("description", String.class);
    ftb.add("pointProperty", MultiPoint.class); // poly -> multi-poly
    ftb.add("intProperty", Long.class); // int -> long
    ftb.add("dateTimeProperty", Date.class); // timestamp -> date
    ftb.add("newProperty", String.class); // new property
    ftb.setName(RENAMED); // rename type
    primitive = ftb.buildFeatureType();

    PropertyDataStore pds = new PropertyDataStore(data);
    rts =
        new RetypingDataStore(pds) {

          @Override
          protected SimpleFeatureType transformFeatureType(SimpleFeatureType original)
              throws IOException {
            if (original.getTypeName().equals(MockData.PRIMITIVEGEOFEATURE.getLocalPart()))
              return primitive;
            else return super.transformFeatureType(original);
          }

          @Override
          protected String transformFeatureTypeName(String originalName) {
            if (originalName.equals(MockData.PRIMITIVEGEOFEATURE.getLocalPart()))
              return primitive.getTypeName();
            else return super.transformFeatureTypeName(originalName);
          }
        };

    // build a filter that will retrieve one feature only
    FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
    fid = RENAMED + ".f001";
    fidFilter = ff.id(Collections.singleton(ff.featureId(fid)));
  }