示例#1
0
  @Test
  public void testGMLAttributeMapping() throws Exception {
    WFSInfo wfs = getWFS();
    GMLInfo gml = wfs.getGML().get(WFSInfo.Version.V_11);
    gml.setOverrideGMLAttributes(false);
    getGeoServer().save(wfs);

    Document dom =
        getAsDOM(
            "ows?service=WFS&version=1.1.0&request=GetFeature"
                + "&typename="
                + getLayerId(SystemTestData.PRIMITIVEGEOFEATURE));
    XMLAssert.assertXpathExists("//gml:name", dom);
    XMLAssert.assertXpathExists("//gml:description", dom);
    XMLAssert.assertXpathNotExists("//sf:name", dom);
    XMLAssert.assertXpathNotExists("//sf:description", dom);

    gml.setOverrideGMLAttributes(true);
    getGeoServer().save(wfs);

    dom =
        getAsDOM(
            "ows?service=WFS&version=1.1.0&request=GetFeature"
                + "&typename="
                + getLayerId(SystemTestData.PRIMITIVEGEOFEATURE));
    XMLAssert.assertXpathNotExists("//gml:name", dom);
    XMLAssert.assertXpathNotExists("//gml:description", dom);
    XMLAssert.assertXpathExists("//sf:name", dom);
    XMLAssert.assertXpathExists("//sf:description", dom);

    gml.setOverrideGMLAttributes(false);
    getGeoServer().save(wfs);
  }
  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);
  }
  public void testIssueNavigatorSearchRequestViews() throws Exception {
    try {
      tester.getDialog().getWebClient().setExceptionsThrownOnErrorStatus(false);

      executeIssueNavigatorSearchRequestView(
          400,
          "Error in the JQL Query: The character '#' is a reserved JQL character. You must enclose it in a string or use the escape '\\u0023' instead. (line 1, character 4)",
          "jqlQuery=" + JQL_NOT_PARSEABLE,
          "pid=123123");
      executeIssueNavigatorSearchRequestView(
          400,
          "The value 'New Component 5' does not exist for the field 'component'.",
          "jqlQuery=" + JQL_IN_VALID_DOESNOT_FIT,
          "pid=123123");
      executeIssueNavigatorSearchRequestView(
          400,
          "Function 'membersOf' can not generate a list of usernames for group 'blub'; the group does not exist.",
          "jqlQuery=" + JQL_IN_VALID_FITS,
          "pid=123123");
      executeIssueNavigatorSearchRequestView(
          200, "", "jqlQuery=" + JQL_VALID_DOESNOT_FIT, "pid=123123");

      Document doc = XMLUnit.buildControlDocument(tester.getDialog().getResponse().getText());
      XMLAssert.assertXpathExists("/rss/channel/item[key = 'HSP-1']", doc);

      executeIssueNavigatorSearchRequestView(
          200, "", "jqlQuery=" + JQL_VALID_AND_FITS, "pid=10001");

      doc = XMLUnit.buildControlDocument(tester.getDialog().getResponse().getText());
      XMLAssert.assertXpathExists("/rss/channel/item[key = 'HSP-1']", doc);
    } finally {
      tester.getDialog().getWebClient().setExceptionsThrownOnErrorStatus(true);
    }
  }
示例#4
0
  /**
   * Check the Complex Items.
   *
   * @throws Exception
   */
  private void checkComplex() throws Exception {
    XPathComponentHelper xpathHelper = new XPathComponentHelper();

    if (this.extension == null) {
      XMLTestCase.fail("Extension base name is not set.");
    }

    String xpath = xpathHelper.xpathComponentName(this.componentName);
    XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());

    xpath = xpathHelper.xpathCompExtenBase(this.componentName, this.extension);
    XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());

    if (this.sequenceFields.isEmpty() == true && this.choiceSequenceFields.isEmpty() == true) {
      XMLTestCase.assertTrue(true);
    } else {

      // Check all the fields.
      for (Iterator fields = sequenceFields.iterator(); fields.hasNext(); ) {
        ComponentField seqField = (ComponentField) fields.next();
        xpath =
            xpathHelper.xpathCompExtElements(
                this.componentName, this.extension, seqField.getFieldName());
        XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());

        // xpath = xpathHelper.xpathCompExtElementDoc(this.componentName, this.extension,
        // seqField.getFieldName());
        // xmlTest.assertXpathExists(xpath, this.getXsdSourceDocument());

        if (seqField.getMinOccurs() != null) {
          if (seqField.getMinOccurs().equalsIgnoreCase("0")) {
            xpath =
                xpathHelper.xpathCompExtElementOptional(
                    this.componentName, this.extension, seqField.getFieldName());
          } else {
            xpath =
                xpathHelper.xpathCompExtElementMinOccurs(
                    this.componentName,
                    this.extension,
                    seqField.getFieldName(),
                    seqField.getMinOccurs());
          }
          XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        }

        if (seqField.getMaxOccurs() != null) {
          xpath =
              xpathHelper.xpathCompExtElementMaxOccurs(
                  this.componentName,
                  this.extension,
                  seqField.getFieldName(),
                  seqField.getMaxOccurs());
          XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        }
      }
    }
  }
  @Test
  public void testListStoredQueries2() throws Exception {
    testCreateStoredQuery();

    Document dom = getAsDOM("wfs?request=ListStoredQueries&service=wfs&version=2.0.0");
    XMLAssert.assertXpathEvaluatesTo("2", "count(//wfs:StoredQuery)", dom);
    XMLAssert.assertXpathExists(
        "//wfs:StoredQuery[@id = '" + StoredQuery.DEFAULT.getName() + "']", dom);
    XMLAssert.assertXpathExists("//wfs:StoredQuery[@id = 'myStoredQuery']", dom);
  }
  @Test
  public void testSortingGET() throws Exception {
    Document dom =
        getAsDOM(
            "wfs?service=WFS&version=2.0.0&request=GetFeature&typeName=gs:Fifteen&sortBy=num ASC&count=1");
    XMLAssert.assertXpathExists("//gs:Fifteen/gs:num[text() = '0']", dom);

    dom =
        getAsDOM(
            "wfs?service=WFS&version=2.0.0&request=GetFeature&typeName=gs:Fifteen&sortBy=num DESC&count=1");
    XMLAssert.assertXpathExists("//gs:Fifteen/gs:num[text() = '14']", dom);
  }
示例#7
0
  /** Do some spot checks on the KML generated when an overlay hierarchy is requested. */
  @Test
  public void testSuperOverlayReflection() throws Exception {
    final String layerName =
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart();

    final String requestUrl = "wms/kml?layers=" + layerName + "&styles=&mode=superoverlay";
    Document dom = getAsDOM(requestUrl);
    // print(dom);
    assertEquals("kml", dom.getDocumentElement().getLocalName());
    assertXpathExists("kml:kml/kml:Document/kml:Folder/kml:NetworkLink/kml:Link/kml:href", dom);
    assertXpathExists("kml:kml/kml:Document/kml:LookAt/kml:longitude", dom);
  }
  @Test
  public void testDescribeDefaultStoredQuery() throws Exception {
    Document dom =
        getAsDOM(
            "wfs?request=DescribeStoredQueries&storedQueryId=" + StoredQuery.DEFAULT.getName());
    assertEquals("wfs:DescribeStoredQueriesResponse", dom.getDocumentElement().getNodeName());

    XMLAssert.assertXpathExists(
        "//wfs:StoredQueryDescription[@id = '" + StoredQuery.DEFAULT.getName() + "']", dom);
    XMLAssert.assertXpathExists("//wfs:Parameter[@name = 'ID']", dom);
    XMLAssert.assertXpathExists("//wfs:QueryExpressionText[@isPrivate = 'true']", dom);
    XMLAssert.assertXpathNotExists("//wfs:QueryExpressionText/*", dom);
  }
  @Test
  public void testCreateStoredQuery() throws Exception {
    String xml =
        "<wfs:ListStoredQueries service='WFS' version='2.0.0' "
            + " xmlns:wfs='"
            + WFS.NAMESPACE
            + "'/>";
    Document dom = postAsDOM("wfs", xml);
    print(dom);
    assertEquals("wfs:ListStoredQueriesResponse", dom.getDocumentElement().getNodeName());
    XMLAssert.assertXpathEvaluatesTo("1", "count(//wfs:StoredQuery)", dom);

    xml =
        "<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>";

    dom = postAsDOM("wfs", xml);
    assertEquals("wfs:CreateStoredQueryResponse", dom.getDocumentElement().getNodeName());
    assertEquals("OK", dom.getDocumentElement().getAttribute("status"));

    dom = getAsDOM("wfs?request=ListStoredQueries");
    XMLAssert.assertXpathEvaluatesTo("2", "count(//wfs:StoredQuery)", dom);
    XMLAssert.assertXpathExists("//wfs:StoredQuery[@id = 'myStoredQuery']", dom);
    XMLAssert.assertXpathExists("//wfs:ReturnFeatureType[text() = 'sf:PrimitiveGeoFeature']", dom);
  }
示例#10
0
  @Test
  public void exceptionBasicTest() throws Exception {
    final HttpResponse response = executeGetRequest("NoContainer.NoEntitySet()");
    assertEquals(
        HttpStatusCodes.NOT_FOUND.getStatusCode(), response.getStatusLine().getStatusCode());

    final String payload = StringHelper.inputStreamToString(response.getEntity().getContent());

    Map<String, String> prefixMap = new HashMap<String, String>();
    prefixMap.put("a", Edm.NAMESPACE_M_2007_08);
    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));

    assertXpathExists("a:error", payload);
    assertXpathExists("/a:error/a:code", payload);
    assertXpathExists("/a:error/a:message[@xml:lang=\"en\"]", payload);
  }
 @Test
 public void content_LocalTimeParameters()
     throws SAXException, IOException, XpathException, DatatypeConfigurationException,
         FeedException {
   assertXpathExists(
       "/:entry/:content/espi:LocalTimeParameters", newXML(EspiFactory.newLocalTimeParameters()));
 }
 @Test
 public void content_ElectricPowerUsageSummary()
     throws SAXException, IOException, XpathException, DatatypeConfigurationException,
         FeedException {
   assertXpathExists(
       "/:entry/:content/espi:ElectricPowerUsageSummary", newXML(newElectricPowerUsageSummary()));
 }
  public void testDataInline() throws Exception { // Standard Test A.4.4.2, A.4.4.4
    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>"
            + "<gml:Polygon xmlns:gml='http://www.opengis.net/gml'>"
            + "<gml:exterior>"
            + "<gml:LinearRing>"
            + "<gml:coordinates>1 1 2 1 2 2 1 2 1 1</gml:coordinates>"
            + "</gml:LinearRing>"
            + "</gml:exterior>"
            + "</gml:Polygon>"
            + "</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:ResponseDocument storeExecuteResponse='false'>"
            + "<wps:Output>"
            + "<ows:Identifier>result</ows:Identifier>"
            + "</wps:Output>"
            + "</wps:ResponseDocument>"
            + "</wps:ResponseForm>"
            + "</wps:Execute>";
    // System.out.println(xml);

    Document d = postAsDOM("wps", xml);
    checkValidationErrors(d);

    assertEquals("wps:ExecuteResponse", d.getDocumentElement().getNodeName());

    assertXpathExists("/wps:ExecuteResponse/wps:Status/wps:ProcessSucceeded", d);
    assertXpathExists(
        "/wps:ExecuteResponse/wps:ProcessOutputs/wps:Output/wps:Data/wps:ComplexData/gml:Polygon",
        d);
  }
示例#14
0
  void doTestSrsNameSyntax(SrsNameStyle srsNameStyle, boolean doSave) throws Exception {
    if (doSave) {
      WFSInfo wfs = getWFS();
      GMLInfo gml = wfs.getGML().get(WFSInfo.Version.V_20);
      gml.setSrsNameStyle(srsNameStyle);
      getGeoServer().save(wfs);
    }

    String q = "wfs?request=getfeature&service=wfs&version=2.0.0&typenames=cgf:Points";
    Document d = getAsDOM(q);
    assertEquals("wfs:FeatureCollection", d.getDocumentElement().getNodeName());

    XMLAssert.assertXpathExists(
        "//gml:Envelope[@srsName = '" + srsNameStyle.getPrefix() + "32615']", d);
    XMLAssert.assertXpathExists(
        "//gml:Point[@srsName = '" + srsNameStyle.getPrefix() + "32615']", d);
  }
  public void testEncode() throws Exception {
    Document d = encode(GML3MockData.linearRing(), GML.LinearRing);

    assertEquals("gml:LinearRing", d.getDocumentElement().getNodeName());
    assertXpathExists("/gml:LinearRing/gml:posList", d);

    print(d);
  }
  public void testFeatureCollectionInlineBoundedBy()
      throws Exception { // Standard Test A.4.4.2, A.4.4.4
    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=\"text/xml; subtype=wfs-collection/1.0\">"
            + readFileIntoString("restricted-FeatureCollection.xml")
            + "</wps:ComplexData>"
            + "</wps:Data>"
            + "</wps:Input>"
            + "<wps:Input>"
            + "<ows:Identifier>buffer</ows:Identifier>"
            + "<wps:Data>"
            + "<wps:LiteralData>1000</wps:LiteralData>"
            + "</wps:Data>"
            + "</wps:Input>"
            + "</wps:DataInputs>"
            + "<wps:ResponseForm>"
            + "<wps:ResponseDocument storeExecuteResponse='false'>"
            + "<wps:Output>"
            + "<ows:Identifier>result</ows:Identifier>"
            + "</wps:Output>"
            + "</wps:ResponseDocument>"
            + "</wps:ResponseForm>"
            + "</wps:Execute>";

    Document d = postAsDOM("wps", xml);
    // print(d);
    // checkValidationErrors(d);

    assertEquals("wps:ExecuteResponse", d.getDocumentElement().getNodeName());

    assertXpathExists("/wps:ExecuteResponse/wps:Status/wps:ProcessSucceeded", d);
    assertXpathExists(
        "/wps:ExecuteResponse/wps:ProcessOutputs/wps:Output/wps:Data/wps:ComplexData/wfs:FeatureCollection",
        d);
    assertXpathEvaluatesTo("0", "count(//feature:boundedBy)", d);
  }
  @Test
  public void testDescribeStoredQueries() throws Exception {
    Document dom = getAsDOM("wfs?request=DescribeStoredQueries&storedQueryId=myStoredQuery");
    assertEquals("ows:ExceptionReport", dom.getDocumentElement().getNodeName());
    XMLAssert.assertXpathExists("//ows:Exception[@exceptionCode = 'InvalidParameterValue']", dom);

    testCreateStoredQuery();

    String xml =
        "<wfs:DescribeStoredQueries xmlns:wfs='"
            + WFS.NAMESPACE
            + "' service='WFS'>"
            + "<wfs:StoredQueryId>myStoredQuery</wfs:StoredQueryId>"
            + "</wfs:DescribeStoredQueries>";

    dom = postAsDOM("wfs", xml);
    assertEquals("wfs:DescribeStoredQueriesResponse", dom.getDocumentElement().getNodeName());
    XMLAssert.assertXpathExists("//wfs:StoredQueryDescription[@id='myStoredQuery']", dom);
  }
  public void testFeatureCollectionFileReference()
      throws Exception { // Standard Test A.4.4.2, A.4.4.4
    URL collectionURL = getClass().getResource("states-FeatureCollection.xml");
    String xml =
        "<wps:Execute service='WPS' version='1.0.0' xmlns:wps='http://www.opengis.net/wps/1.0.0' xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
            + "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:Reference mimeType=\"text/xml; subtype=wfs-collection/1.1\" "
            + "xlink:href=\""
            + collectionURL.toExternalForm()
            + "\"/>\n"
            + "</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:ResponseDocument storeExecuteResponse='false'>"
            + "<wps:Output>"
            + "<ows:Identifier>result</ows:Identifier>"
            + "</wps:Output>"
            + "</wps:ResponseDocument>"
            + "</wps:ResponseForm>"
            + "</wps:Execute>";

    Document d = postAsDOM("wps", xml);
    // print(d);
    // checkValidationErrors(d);

    assertEquals("wps:ExecuteResponse", d.getDocumentElement().getNodeName());

    assertXpathExists("/wps:ExecuteResponse/wps:Status/wps:ProcessSucceeded", d);
    assertXpathExists(
        "/wps:ExecuteResponse/wps:ProcessOutputs/wps:Output/wps:Data/wps:ComplexData/wfs:FeatureCollection",
        d);
  }
  public void testRootLayer() throws Exception {
    WMSInfo serviceInfo = getWMS().getServiceInfo();
    addAuthUrl("rootAuth1", "http://geoserver/wms/auth1", serviceInfo.getAuthorityURLs());
    addAuthUrl("rootAuth2", "http://geoserver/wms/auth2", serviceInfo.getAuthorityURLs());
    addIdentifier("rootAuth1", "rootId1", serviceInfo.getIdentifiers());
    addIdentifier("rootAuth2", "rootId2", serviceInfo.getIdentifiers());
    getGeoServer().save(serviceInfo);

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

    assertXpathExists(
        "/wms:WMS_Capabilities/wms:Capability/wms:Layer/wms:AuthorityURL[@name = 'rootAuth1']",
        doc);
    assertXpathEvaluatesTo(
        "http://geoserver/wms/auth1",
        "/wms:WMS_Capabilities/wms:Capability/wms:Layer/wms:AuthorityURL[@name = 'rootAuth1']/wms:OnlineResource/@xlink:href",
        doc);

    assertXpathExists(
        "/wms:WMS_Capabilities/wms:Capability/wms:Layer/wms:AuthorityURL[@name = 'rootAuth2']",
        doc);
    assertXpathEvaluatesTo(
        "http://geoserver/wms/auth2",
        "/wms:WMS_Capabilities/wms:Capability/wms:Layer/wms:AuthorityURL[@name = 'rootAuth2']/wms:OnlineResource/@xlink:href",
        doc);

    assertXpathExists(
        "/wms:WMS_Capabilities/wms:Capability/wms:Layer/wms:Identifier[@authority = 'rootAuth1']",
        doc);
    assertXpathEvaluatesTo(
        "rootId1",
        "/wms:WMS_Capabilities/wms:Capability/wms:Layer/wms:Identifier[@authority = 'rootAuth1']",
        doc);

    assertXpathExists(
        "/wms:WMS_Capabilities/wms:Capability/wms:Layer/wms:Identifier[@authority = 'rootAuth2']",
        doc);
    assertXpathEvaluatesTo(
        "rootId2",
        "/wms:WMS_Capabilities/wms:Capability/wms:Layer/wms:Identifier[@authority = 'rootAuth2']",
        doc);
  }
  @Test
  public void testDescribeStoredQueries2() throws Exception {
    Document dom = getAsDOM("wfs?request=DescribeStoredQueries&storedQuery_Id=myStoredQuery");
    assertEquals("ows:ExceptionReport", dom.getDocumentElement().getNodeName());

    testCreateStoredQuery();

    dom = getAsDOM("wfs?request=DescribeStoredQueries&storedQuery_Id=myStoredQuery");
    assertEquals("wfs:DescribeStoredQueriesResponse", dom.getDocumentElement().getNodeName());
    XMLAssert.assertXpathExists("//wfs:StoredQueryDescription[@id='myStoredQuery']", dom);
  }
 /**
  * @param index TODO
  * @param output
  * @throws IOException
  * @throws SAXException
  * @throws XpathException
  */
 private void verifyDefaults(String index, String output)
     throws IOException, SAXException, XpathException {
   assertXpathEvaluatesTo(
       DEFAULT_TYPE_NAME, "/mc:metacards/mc:metacard[" + index + "]/mc:type", output);
   assertXpathExists(
       "/mc:metacards/mc:metacard[" + index + "]/mc:geometry[@name='location']//gml:Polygon",
       output);
   assertXpathExists(
       "/mc:metacards/mc:metacard[" + index + "]/mc:dateTime[@name='expiration']", output);
   assertXpathExists(
       "/mc:metacards/mc:metacard[" + index + "]/mc:stringxml[@name='metadata']", output);
   assertXpathEvaluatesTo(
       DEFAULT_TITLE,
       "/mc:metacards/mc:metacard[" + index + "]/mc:string[@name='title']/mc:value",
       output);
   assertXpathEvaluatesTo(
       DEFAULT_BASE64,
       "/mc:metacards/mc:metacard[" + index + "]/mc:base64Binary[@name='thumbnail']/mc:value",
       output);
 }
  public void testFeatureCollectionInlineKVP() throws Exception {
    String request =
        "wps?service=WPS&version=1.0.0&request=Execute&Identifier=gt:BufferFeatureCollection"
            + "&DataInputs="
            + urlEncode(
                "features="
                    + readFileIntoString("states-FeatureCollection.xml")
                    + "@mimetype=application/wfs-collection-1.1;buffer=10")
            + "&ResponseDocument="
            + urlEncode("result");

    Document d = getAsDOM(request);
    // print(d);
    // checkValidationErrors(d);

    assertEquals("wps:ExecuteResponse", d.getDocumentElement().getNodeName());

    assertXpathExists("/wps:ExecuteResponse/wps:Status/wps:ProcessSucceeded", d);
    assertXpathExists(
        "/wps:ExecuteResponse/wps:ProcessOutputs/wps:Output/wps:Data/wps:ComplexData/wfs:FeatureCollection",
        d);
  }
示例#23
0
  @Test
  public void testEncodeSrsDimension() throws Exception {
    Document dom =
        getAsDOM(
            "wfs?request=GetFeature&version=1.1.0&service=wfs&typename="
                + getLayerId(SystemTestData.PRIMITIVEGEOFEATURE));
    XMLAssert.assertXpathExists("//gml:Point[@srsDimension = '2']", dom);

    WFSInfo wfs = getWFS();
    wfs.setCiteCompliant(true);
    getGeoServer().save(wfs);

    dom =
        getAsDOM(
            "wfs?request=GetFeature&version=1.1.0&service=wfs&typename="
                + getLayerId(SystemTestData.PRIMITIVEGEOFEATURE));
    XMLAssert.assertXpathNotExists("//gml:Point[@srsDimension = '2']", dom);
  }
示例#24
0
  public void testNoLocalChanges() throws Exception {
    // run a postdiff that will merge some central changes. There are no local ones
    MockHttpServletResponse response =
        postAsServletResponse(root(true), loadTextResource("PostDiffInitial.xml"));
    checkPostDiffSuccessResponse(response);

    // now run a GetDiff that should get a positive, empty response
    response = postAsServletResponse(root(true), loadTextResource("GetDiffInitial.xml"));
    validate(response);
    Document dom = dom(response);
    // print(dom);

    // we should have got back a GetDiffResponse with an empty transation in it
    assertXpathEvaluatesTo("-1", "/gss:GetDiffResponse/@fromVersion", dom);
    assertXpathEvaluatesTo("4", "/gss:GetDiffResponse/@toVersion", dom);
    assertXpathEvaluatesTo("sf:restricted", "/gss:GetDiffResponse/@typeName", dom);
    assertXpathExists("/gss:GetDiffResponse/gss:Changes", dom);
    assertXpathEvaluatesTo("0", "count(/gss:GetDiffResponse/gss:Changes/*)", dom);
  }
示例#25
0
  @Test
  public void testNonAdvertisedLayer() throws Exception {
    String layerId = getLayerId(MockData.TASMANIA_DEM);
    LayerInfo layer = getCatalog().getLayerByName(layerId);
    try {
      // now you see me
      Document dom = getAsDOM("wcs?request=GetCapabilities");
      assertXpathExists("//wcs:CoverageSummary[ows:Title='DEM']", dom);

      // now you don't!
      layer.setAdvertised(false);
      getCatalog().save(layer);
      dom = getAsDOM("wcs?request=GetCapabilities");
      assertXpathNotExists("//wcs:CoverageSummary[ows:Title='DEM']", dom);
    } finally {
      layer.setAdvertised(true);
      getCatalog().save(layer);
    }
  }
示例#26
0
  @Test
  public void testExternalImageSize() throws Exception {
    GetMapRequest req = createGetMapRequest(MockData.STREAMS);
    req.setWidth(256);
    req.setHeight(256);

    WMSMapContent mapContent = new WMSMapContent(req);
    mapContent.addLayer(createMapLayer(MockData.STREAMS, "big-local-image"));

    mapContent
        .getViewport()
        .setBounds(new ReferencedEnvelope(-180, 0, -90, 90, DefaultGeographicCRS.WGS84));
    mapContent.setMapHeight(256);
    mapContent.setMapWidth(256);

    KMLMapOutputFormat of = new KMLMapOutputFormat(getWMS());
    KMLMap map = of.produceMap(mapContent);

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    new KMLEncoder().encode(map.getKml(), bout, null);

    Document document = dom(new ByteArrayInputStream(bout.toByteArray()));

    assertEquals("kml", document.getDocumentElement().getNodeName());
    assertEquals(1, document.getElementsByTagName("Style").getLength());

    XMLAssert.assertXpathExists("//kml:IconStyle/kml:scale", document);

    XPath xPath = XPathFactory.newInstance().newXPath();
    initXPath(xPath);

    Double scale =
        (Double)
            xPath.evaluate(
                "//kml:IconStyle/kml:scale", document.getDocumentElement(), XPathConstants.NUMBER);
    assertEquals(42d / 16d, scale, 0.01);
  }
示例#27
0
  private void checkSequence() throws Exception {
    XPathComponentHelper xpathHelper = new XPathComponentHelper();

    if (this.sequenceFields.isEmpty() == true && this.choiceSequenceFields.isEmpty() == true) {
      XMLTestCase.fail("Component has no fields");
    }

    String xpath = xpathHelper.xpathComponentName(this.componentName);
    XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());

    // Check all the fields.
    for (Iterator fields = sequenceFields.iterator(); fields.hasNext(); ) {
      ComponentField seqField = (ComponentField) fields.next();
      xpath = xpathHelper.xpathCompElement(this.componentName, seqField.getFieldName());
      XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
      // xpath = xpathHelper.xpathCompElementDoc(this.componentName, seqField.getFieldName());
      // xmlTest.assertXpathExists(xpath, this.getXsdSourceDocument());
      if (seqField.getMinOccurs() != null) {
        if (seqField.getMinOccurs().equalsIgnoreCase("0")) {
          xpath = xpathHelper.xpathCompElementOptional(this.componentName, seqField.getFieldName());
        } else {
          xpath =
              xpathHelper.xpathCompElementMinOccurs(
                  this.componentName, seqField.getFieldName(), seqField.getMinOccurs());
        }
        XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
      }
      if (seqField.getMaxOccurs() != null) {
        xpath =
            xpathHelper.xpathCompElementMaxOccurs(
                this.componentName, seqField.getFieldName(), seqField.getMaxOccurs());
        XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
      }
    }

    // Check all Choices

    if (choiceSequenceFields.isEmpty() == false) {
      for (Iterator fields = choiceSequenceFields.iterator(); fields.hasNext(); ) {
        ComponentField choiceField = (ComponentField) fields.next();
        xpath =
            xpathHelper.xpathSequenceChoiceSequenceElement(
                this.componentName, choiceField.getFieldName(), choiceField.getDataType());
        XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        // xpath = xpathHelper.xpathSequenceChoiceSequenceElementDoc(this.componentName,
        // choiceField.getFieldName());
        // xmlTest.assertXpathExists(xpath, this.getXsdSourceDocument());
        if (choiceField.getMinOccurs() != null) {
          if (choiceField.getMinOccurs().equalsIgnoreCase("0")) {
            xpath =
                xpathHelper.xpathSequenceChoiceSequenceElementOptional(
                    this.componentName, choiceField.getFieldName(), choiceField.getDataType());
          } else {
            xpath =
                xpathHelper.xpathSequenceChoiceSequenceElementMinOccurs(
                    this.componentName,
                    choiceField.getFieldName(),
                    choiceField.getDataType(),
                    choiceField.getMinOccurs());
          }
          XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        }
        if (choiceField.getMaxOccurs() != null) {
          xpath =
              xpathHelper.xpathSequenceChoiceSequenceElementMaxOccurs(
                  this.componentName,
                  choiceField.getFieldName(),
                  choiceField.getDataType(),
                  choiceField.getMaxOccurs());
          XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        }
      }
    }
  }
 @Test
 public void testListStoredQueries() throws Exception {
   Document dom = getAsDOM("wfs?request=ListStoredQueries&service=wfs&version=2.0.0");
   XMLAssert.assertXpathExists(
       "//wfs:StoredQuery[@id = '" + StoredQuery.DEFAULT.getName() + "']", dom);
 }
 @Test
 public void content_UsagePoint()
     throws SAXException, IOException, XpathException, DatatypeConfigurationException,
         FeedException {
   assertXpathExists("/:entry/:content/espi:UsagePoint", newXML(newUsagePoint()));
 }
 @Test
 public void entry_updated()
     throws SAXException, IOException, XpathException, DatatypeConfigurationException,
         FeedException {
   assertXpathExists("/:entry/:updated", newXML());
 }