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); } }
// see GEOS-1287 public void testGetWithFeatureId() throws Exception { Document doc; doc = getAsDOM( "wfs?request=GetFeature&typeName=cdf:Fifteen&version=1.0.0&service=wfs&featureid=Fifteen.2"); // super.print(doc); assertEquals("wfs:FeatureCollection", doc.getDocumentElement().getNodeName()); XMLAssert.assertXpathEvaluatesTo("1", "count(//wfs:FeatureCollection/gml:featureMember)", doc); XMLAssert.assertXpathEvaluatesTo( "Fifteen.2", "//wfs:FeatureCollection/gml:featureMember/cdf:Fifteen/@fid", doc); doc = getAsDOM( "wfs?request=GetFeature&typeName=cite:NamedPlaces&version=1.0.0&service=wfs&featureId=NamedPlaces.1107531895891"); // super.print(doc); assertEquals("wfs:FeatureCollection", doc.getDocumentElement().getNodeName()); XMLAssert.assertXpathEvaluatesTo("1", "count(//wfs:FeatureCollection/gml:featureMember)", doc); XMLAssert.assertXpathEvaluatesTo( "NamedPlaces.1107531895891", "//wfs:FeatureCollection/gml:featureMember/cite:NamedPlaces/@fid", doc); }
@Test public void testUploadImageMosaic() throws Exception { URL zip = MockData.class.getResource("watertemp.zip"); InputStream is = null; byte[] bytes; try { is = zip.openStream(); bytes = IOUtils.toByteArray(is); } finally { IOUtils.closeQuietly(is); } MockHttpServletResponse response = putAsServletResponse( "/rest/workspaces/gs/coveragestores/watertemp/file.imagemosaic", bytes, "application/zip"); assertEquals(201, response.getStatusCode()); // check the response contents String content = response.getOutputStreamContent(); Document d = dom(new ByteArrayInputStream(content.getBytes())); XMLAssert.assertXpathEvaluatesTo("watertemp", "//coverageStore/name", d); XMLAssert.assertXpathEvaluatesTo("ImageMosaic", "//coverageStore/type", d); // check the coverage is actually there CoverageStoreInfo storeInfo = getCatalog().getCoverageStoreByName("watertemp"); assertNotNull(storeInfo); CoverageInfo ci = getCatalog().getCoverageByName("watertemp"); assertNotNull(ci); assertEquals(storeInfo, ci.getStore()); }
// see GEOS-1893 public void testGetMissingParams() throws Exception { Document doc = getAsDOM("wfs?request=GetFeature&typeNameWrongParam=cdf:Fifteen&version=1.0.0&service=wfs"); // trick: the document specifies a namespace with schema reference, as a result xpath // expressions // do work only if fully qualified XMLAssert.assertXpathEvaluatesTo("1", "count(//ogc:ServiceException)", doc); XMLAssert.assertXpathEvaluatesTo("MissingParameterValue", "//ogc:ServiceException/@code", doc); }
/** * 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); }
@Test public void testLabelFromTextSymbolizer() throws Exception { // the style selects a single feature final String requestUrl = "wms/kml?layers=" + getLayerId(MockData.NAMED_PLACES) + "&styles=labels&mode=download"; Document doc = getAsDOM(requestUrl); // print(doc); XMLAssert.assertXpathEvaluatesTo("2", "count(//kml:Placemark)", doc); XMLAssert.assertXpathEvaluatesTo("1", "count(//kml:Placemark[kml:name='Ashton'])", doc); XMLAssert.assertXpathEvaluatesTo("1", "count(//kml:Placemark[kml:name='Goose Island'])", doc); }
/** See https://osgeo-org.atlassian.net/browse/GEOS-1947 */ @Test public void testExternalGraphicBackround() throws Exception { final String requestUrl = "wms/kml?layers=" + getLayerId(MockData.BRIDGES) + "&styles=Bridge&mode=download"; Document dom = getAsDOM(requestUrl); // print(dom); // make sure we are generating icon styles, but that we're not sticking a color onto them XMLAssert.assertXpathEvaluatesTo( "1", "count(//kml:Style/kml:IconStyle/kml:Icon/kml:href)", dom); XMLAssert.assertXpathEvaluatesTo( "0", "count(//kml:Style/kml:IconStyle/kml:Icon/kml:color)", 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 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); }
@Test public void testLegend() throws Exception { String layerId = getLayerId(MockData.BASIC_POLYGONS); final String requestUrl = "wms/kml?layers=" + layerId + "&styles=polygon&mode=download&format_options=legend:true" // + "&legend_options=fontStyle:bold;fontColor:ff0000;fontSize:18"; Document doc = getAsDOM(requestUrl); // print(doc); assertEquals("kml", doc.getDocumentElement().getNodeName()); // the icon itself XpathEngine xpath = XMLUnit.newXpathEngine(); String href = xpath.evaluate("//kml:ScreenOverlay/kml:Icon/kml:href", doc); assertTrue(href.contains("request=GetLegendGraphic")); assertTrue(href.contains("layer=cite%3ABasicPolygons")); assertTrue(href.contains("style=polygon")); assertTrue( href.contains("LEGEND_OPTIONS=fontStyle%3Abold%3BfontColor%3Aff0000%3BfontSize%3A18")); // overlay location XMLAssert.assertXpathEvaluatesTo("0.0", "//kml:ScreenOverlay/kml:overlayXY/@x", doc); XMLAssert.assertXpathEvaluatesTo("0.0", "//kml:ScreenOverlay/kml:overlayXY/@y", doc); XMLAssert.assertXpathEvaluatesTo("pixels", "//kml:ScreenOverlay/kml:overlayXY/@xunits", doc); XMLAssert.assertXpathEvaluatesTo("pixels", "//kml:ScreenOverlay/kml:overlayXY/@yunits", doc); XMLAssert.assertXpathEvaluatesTo("10.0", "//kml:ScreenOverlay/kml:screenXY/@x", doc); XMLAssert.assertXpathEvaluatesTo("20.0", "//kml:ScreenOverlay/kml:screenXY/@y", doc); XMLAssert.assertXpathEvaluatesTo("pixels", "//kml:ScreenOverlay/kml:screenXY/@xunits", doc); XMLAssert.assertXpathEvaluatesTo("pixels", "//kml:ScreenOverlay/kml:screenXY/@yunits", doc); }
@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); }
private void suggestion(HTTPMixIn httpMixIn, int interaction) throws Exception { String actual = httpMixIn.postString( "http://localhost:8080/suggestion/SuggestionService", xml("request", interaction)); String expected = xml("response", interaction); XMLAssert.assertXMLEqual(expected, actual); }
protected void handleXmlContent(final byte[] reportOutput, final File goldSample) throws Exception { final byte[] goldData; final InputStream goldInput = new BufferedInputStream(new FileInputStream(goldSample)); final MemoryByteArrayOutputStream goldByteStream = new MemoryByteArrayOutputStream( Math.min(1024 * 1024, (int) goldSample.length()), 1024 * 1024); try { IOUtils.getInstance().copyStreams(goldInput, goldByteStream); goldData = goldByteStream.toByteArray(); if (Arrays.equals(goldData, reportOutput)) { return; } } finally { goldInput.close(); } final Reader reader = new InputStreamReader(new ByteArrayInputStream(goldData), "UTF-8"); final ByteArrayInputStream inputStream = new ByteArrayInputStream(reportOutput); final Reader report = new InputStreamReader(inputStream, "UTF-8"); try { XMLAssert.assertXMLEqual("File " + goldSample + " failed", new Diff(reader, report), true); } catch (AssertionFailedError afe) { debugOutput(reportOutput, goldSample); throw afe; } finally { reader.close(); } }
@Test public void verifyExtractionTemplateGenerate() throws TestEvalException, SAXException, IOException, TransformerException { for (String entityType : entityTypes) { if (entityType.contains(".json") || entityType.contains(".jpg") || entityType.contains("primary-key-as-a-ref")) { continue; } logger.info("Validating extraction template for:" + entityType); // logger.info(docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new // StringHandle()).get()); DOMHandle handle = docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new DOMHandle()); Document template = handle.get(); InputStream is = this.getClass().getResourceAsStream("/test-extraction-template/" + entityType); Document filesystemXML = builder.parse(is); // debugOutput(template); XMLUnit.setIgnoreWhitespace(true); XMLAssert.assertXMLEqual( "Must be no validation errors for schema " + entityType + ".", filesystemXML, template); } }
public void testElementConstructor() throws Exception { final SamlCredential samlPrincipal = new SamlCredential(assertionElement); final InputSource actual = new InputSource(new StringReader(samlPrincipal.getAssertionAsString())); XMLAssert.assertXMLEqual(expectedAssertion, actual); }
public void testGetNullGeometies() throws Exception { Document doc; doc = getAsDOM( "wfs?request=GetFeature&typeName=" + getLayerId(NULL_GEOMETRIES) + "&version=1.0.0&service=wfs"); // print(doc); XMLAssert.assertXpathEvaluatesTo( "1", "count(//cite:NullGeometries[@fid=\"NullGeometries.1107531701010\"]/gml:boundedBy)", doc); XMLAssert.assertXpathEvaluatesTo( "0", "count(//cite:NullGeometries[@fid=\"NullGeometries.1107531701011\"]/boundedBy)", doc); }
@Test public void verifyExtractionTempGenNoRequired() throws TestEvalException, SAXException, IOException, TransformerException { String entityType = "no-primary-required.json"; DOMHandle res = new DOMHandle(); logger.info("Validating extraction template for:" + entityType); try { res = evalOneResult("fn:doc( '" + entityType + "')=>es:extraction-template-generate()", res); } catch (TestEvalException e) { throw new RuntimeException(e); } // logger.info(docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new // StringHandle()).get()); // DOMHandle handle = docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new // DOMHandle()); Document template = res.get(); InputStream is = this.getClass() .getResourceAsStream( "/test-extraction-template/" + entityType.replace(".json", ".xml")); Document filesystemXML = builder.parse(is); // debugOutput(template); XMLUnit.setIgnoreWhitespace(true); XMLAssert.assertXMLEqual( "Must be no validation errors for schema " + entityType + ".", filesystemXML, template); }
public void doTestStartIndexMultipleTypes(String fifteen, String seven) throws Exception { String typeNames = fifteen + "," + seven; Document doc = getAsDOM( "/wfs?request=GetFeature&version=2.0.0&service=wfs&" + "typename=" + typeNames + "&startIndex=10"); XMLAssert.assertXpathEvaluatesTo("5", "count(//" + fifteen + ")", doc); XMLAssert.assertXpathEvaluatesTo("7", "count(//" + seven + ")", doc); doc = getAsDOM( "/wfs?request=GetFeature&version=2.0.0&service=wfs&" + "typename=" + typeNames + "&startIndex=16"); XMLAssert.assertXpathEvaluatesTo("0", "count(//" + fifteen + ")", doc); XMLAssert.assertXpathEvaluatesTo("6", "count(//" + seven + ")", doc); doc = getAsDOM( "/wfs?request=GetFeature&version=2.0.0&service=wfs&" + "typename=" + typeNames + "&startIndex=10&count=5"); XMLAssert.assertXpathEvaluatesTo("5", "count(//" + fifteen + ")", doc); XMLAssert.assertXpathEvaluatesTo("0", "count(//" + seven + ")", doc); doc = getAsDOM( "/wfs?request=GetFeature&version=2.0.0&service=wfs&" + "typename=" + typeNames + "&startIndex=10&count=6"); XMLAssert.assertXpathEvaluatesTo("5", "count(//" + fifteen + ")", doc); XMLAssert.assertXpathEvaluatesTo("1", "count(//" + seven + ")", doc); doc = getAsDOM( "/wfs?request=GetFeature&version=2.0.0&service=wfs&" + "typename=" + typeNames + "&startIndex=25"); XMLAssert.assertXpathEvaluatesTo("0", "count(//" + fifteen + ")", doc); XMLAssert.assertXpathEvaluatesTo("0", "count(//" + seven + ")", doc); }
public void testWorkspaceQualified() throws Exception { testGetFifteenAll("cdf/wfs?request=GetFeature&typename=cdf:Fifteen&version=1.0.0&service=wfs"); testGetFifteenAll("cdf/wfs?request=GetFeature&typename=Fifteen&version=1.0.0&service=wfs"); Document doc = getAsDOM("sf/wfs?request=GetFeature&typename=cdf:Fifteen&version=1.0.0&service=wfs"); XMLAssert.assertXpathEvaluatesTo("1", "count(//ogc:ServiceException)", doc); }
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 testCarToXml() throws Exception { String xml = beanXmlConverter.convertToXml(car); XMLUnit.setIgnoreWhitespace(true); Diff diff; diff = new Diff(TestModel.Car.DEFAULT_XML, xml); diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); XMLAssert.assertXMLEqual(diff, true); }
void doTestStartIndexSimplePOST(String typeName) throws Exception { Document doc = postAsDOM("wfs", startIndexSimpleXML(typeName, 10, -1)); XMLAssert.assertXpathEvaluatesTo("5", "count(//" + typeName + ")", doc); doc = postAsDOM("wfs", startIndexSimpleXML(typeName, 16, -1)); XMLAssert.assertXpathEvaluatesTo("0", "count(//" + typeName + ")", doc); doc = postAsDOM("wfs", startIndexSimpleXML(typeName, 0, -1)); XMLAssert.assertXpathEvaluatesTo("15", "count(//" + typeName + ")", doc); doc = postAsDOM("wfs", startIndexSimpleXML(typeName, 1, 1)); XMLAssert.assertXpathEvaluatesTo("1", "count(//" + typeName + ")", doc); doc = postAsDOM("wfs", startIndexSimpleXML(typeName, 16, 1)); XMLAssert.assertXpathEvaluatesTo("0", "count(//" + typeName + ")", doc); }
@Test public void testStyleConverter() throws Exception { // the style selects a single feature final String requestUrl = "wms/kml?layers=" + getLayerId(MockData.BASIC_POLYGONS) + "&styles=allsymbolizers&mode=download"; Document doc = getAsDOM(requestUrl); // print(doc); XMLAssert.assertXpathEvaluatesTo("1", "count(//kml:Placemark[1]/kml:Style)", doc); XMLAssert.assertXpathEvaluatesTo( "0", "count(//kml:Placemark[1]/kml:Style/kml:IconStyle/kml:Icon/kml:color)", doc); XMLAssert.assertXpathEvaluatesTo( "http://localhost:8080/geoserver/kml/icon/allsymbolizers?0.0.0=", "//kml:Placemark[1]/kml:Style/kml:IconStyle/kml:Icon/kml:href", doc); XMLAssert.assertXpathEvaluatesTo( "b24d4dff", "//kml:Placemark[1]/kml:Style/kml:PolyStyle/kml:color", doc); XMLAssert.assertXpathEvaluatesTo( "ffba3e00", "//kml:Placemark[1]/kml:Style/kml:LineStyle/kml:color", doc); XMLAssert.assertXpathEvaluatesTo( "2.0", "//kml:Placemark[1]/kml:Style/kml:LineStyle/kml:width", doc); XMLAssert.assertXpathEvaluatesTo( "1.4", "//kml:Placemark[1]/kml:Style/kml:LabelStyle/kml:scale", doc); }
@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); }
/** @throws Exception */ @Test public void testWorkspace() throws Exception { AppService appService = new AppService(); appService.getWorkspace().add(new XsdWorkspace("http://example.org")); // $NON-NLS-1$ String actual = marshall(appService); String expected = getExpectedWorkspaceXML("xsd"); // $NON-NLS-1$ XMLAssert.assertXMLEqual(expected, actual); }
@Test public void testLayerQualified() throws Exception { testGetFifteenAll( "cdf/Fifteen/wfs?request=GetFeature&typename=cdf:Fifteen&version=1.1.0&service=wfs"); Document dom = getAsDOM("cdf/Seven/wfs?request=GetFeature&typename=cdf:Fifteen&version=1.1.0&service=wfs"); XMLAssert.assertXpathEvaluatesTo("1", "count(//ows:ExceptionReport)", dom); }
public void assertXMLEqual(String expectedXml, String resultXml) { try { Diff diff = new Diff(expectedXml, resultXml); diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); XMLAssert.assertXMLEqual(diff, true); } catch (Exception e) { throw new RuntimeException("XML Assertion failure", e); } }
@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); }