Refine search
private PomAssert hasPluginRepository(String name) { NodeList nodes; try { nodes = this.eng.getMatchingNodes( createRootNodeXPath("pluginRepositories/pom:pluginRepository/pom:id"), this.doc); } catch (XpathException ex) { throw new IllegalStateException("Cannot find path", ex); } for (int i = 0; i < nodes.getLength(); i++) { if (name.equals(nodes.item(i).getTextContent())) { return this; } } throw new IllegalArgumentException("No plugin repository found with id " + name); }
@Test public void testLayerQualified() throws Exception { int all = getCatalog().getCoverageStores().size() - 1; Document dom = getAsDOM("wcs?request=GetCapabilities&service=WCS"); assertEquals(all, xpath.getMatchingNodes("//wcs:CoverageSummary", dom).getLength()); dom = getAsDOM("wcs/BlueMarble/wcs?request=GetCapabilities&service=WCS"); assertEquals(1, xpath.getMatchingNodes("//wcs:CoverageSummary", dom).getLength()); }
@Test public void testGetAllAsHTML() throws Exception { Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/styles.html"); print(dom); List<StyleInfo> styles = catalog.getStylesByWorkspace(CatalogFacade.NO_WORKSPACE); NodeList links = xp.getMatchingNodes("//html:a", dom); for (int i = 0; i < styles.size(); i++) { StyleInfo s = styles.get(i); Element link = (Element) links.item(i); final String href = link.getAttribute("href"); assertTrue( "Expected href to bed with " + s.getName() + ".html but was " + href, href.endsWith(s.getName() + ".html")); } }
@Test public void testGetAsHTML() throws Exception { Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/namespaces/sf.html"); List<ResourceInfo> resources = catalog.getResourcesByNamespace("sf", ResourceInfo.class); NodeList listItems = xp.getMatchingNodes("//html:li", dom); assertEquals(resources.size(), listItems.getLength()); for (int i = 0; i < resources.size(); i++) { ResourceInfo resource = resources.get(i); Element listItem = (Element) listItems.item(i); assertTrue(listItem.getFirstChild().getNodeValue().endsWith(resource.getName())); } }
private void parseProperties() { NodeList nodes; try { nodes = this.eng.getMatchingNodes(createRootNodeXPath("properties/*"), this.doc); } catch (XpathException ex) { throw new IllegalStateException("Cannot find path", ex); } for (int i = 0; i < nodes.getLength(); i++) { Node item = nodes.item(i); if (item instanceof Element) { Element element = (Element) item; this.properties.put(element.getTagName(), element.getTextContent()); } } }
/** * Expected response for app data in json with non-existant key: TODO: Double * check this output with the spec * * { "entry" : { "john.doe" : {}, } } * * @throws Exception * if test encounters an error */ @Test public void testGetSelfAppDataJsonWithInvalidKeys() throws Exception { // app id is mocked out Map<String, String> extraParams = Maps.newHashMap(); extraParams.put("fields", "peabody"); String resp = getResponse("/appdata/john.doe/@self/app", "GET", extraParams, "xml", "application/xml"); XSDValidator.validateOpenSocial(resp); NodeList result = xp.getMatchingNodes("/:appdata/:entry", XMLUnit.buildTestDocument(resp)); Map<String, Map<String, List<String>>> v = childNodesToMapofMap(result); assertEquals(1, v.size()); assertTrue(v.containsKey("john.doe")); assertEquals(0, v.get("john.doe").size()); }
@Test public void testWorkspaceQualified() throws Exception { int all = getCatalog().getCoverageStores().size() - 1; Document dom = getAsDOM("wcs?request=GetCapabilities&service=WCS"); assertEquals(all, xpath.getMatchingNodes("//wcs:CoverageSummary", dom).getLength()); int some = getCatalog().getCoverageStoresByWorkspace("cdf").size(); assertTrue(some < all); dom = getAsDOM("cdf/wcs?request=GetCapabilities&service=WCS"); assertEquals(some, xpath.getMatchingNodes("//wcs:CoverageSummary", dom).getLength()); }
public PomAssert hasPackaging(String packaging) { try { String path = createRootNodeXPath("packaging"); if ("jar".equals(packaging)) { assertThat(this.eng.getMatchingNodes(path, this.doc).getLength()) .isEqualTo(0); } else { assertThat(this.eng.evaluate(path, this.doc)).isEqualTo(packaging); } } catch (XpathException ex) { throw new IllegalStateException("Cannot find path", ex); } return this; }
@Test public void testGetAllAsHTML() throws Exception { Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/namespaces.html"); List<NamespaceInfo> namespaces = catalog.getNamespaces(); NodeList links = xp.getMatchingNodes("//html:a", dom); assertEquals(namespaces.size(), links.getLength()); for (int i = 0; i < namespaces.size(); i++) { NamespaceInfo ws = namespaces.get(i); Element link = (Element) links.item(i); assertTrue(link.getAttribute("href").endsWith(ws.getPrefix() + ".html")); } }
public PomAssert hasNoRepository() { try { Assertions.assertEquals(0, this.eng .getMatchingNodes(createRootNodeXPath("repositories"), this.doc) .getLength()); } catch (XpathException ex) { throw new IllegalStateException("Cannot find path", ex); } return this; }
@Test public void testGetAllAsHTML() throws Exception { Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/workspaces.html"); List<WorkspaceInfo> workspaces = catalog.getWorkspaces(); NodeList links = xp.getMatchingNodes("//html:a", dom); assertEquals(workspaces.size(), links.getLength()); for (int i = 0; i < workspaces.size(); i++) { WorkspaceInfo ws = workspaces.get(i); Element link = (Element) links.item(i); assertTrue(link.getAttribute("href").endsWith(ws.getName() + ".html")); } }
private void parseRepositories() { NodeList nodes; try { nodes = this.eng.getMatchingNodes( createRootNodeXPath("repositories/pom:repository"), this.doc); for (int i = 0; i < nodes.getLength(); i++) { Node item = nodes.item(i); if (item instanceof Element) { String id = type.item(0).getTextContent(); NodeList name = element.getElementsByTagName("name"); if (name.getLength() > 0) { repository.setName(name.item(0).getTextContent()); if (url.getLength() > 0) { try { repository.setUrl(new URL(url.item(0).getTextContent()));
@Test public void testGetAsHTML() throws Exception { List<StoreInfo> stores = catalog.getStoresByWorkspace("sf", StoreInfo.class); Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/workspaces/sf.html"); NodeList links = xp.getMatchingNodes("//html:a", dom); assertEquals(stores.size(), links.getLength()); for (int i = 0; i < stores.size(); i++) { StoreInfo store = stores.get(i); Element link = (Element) links.item(i); assertTrue(link.getAttribute("href").endsWith(store.getName() + ".html")); } }
private void parseDependencies() { NodeList nodes; try { nodes = this.eng.getMatchingNodes( createRootNodeXPath("dependencies/pom:dependency"), this.doc); throw new IllegalStateException("Cannot find path", ex); for (int i = 0; i < nodes.getLength(); i++) { Node item = nodes.item(i); if (item instanceof Element) { Element element = (Element) item; NodeList groupId = element.getElementsByTagName("groupId"); if (groupId.getLength() > 0) { dependency.setGroupId(groupId.item(0).getTextContent()); if (artifactId.getLength() > 0) { dependency.setArtifactId(artifactId.item(0).getTextContent());
@Test public void testFilteredCapabilitiesCite() throws Exception { Document dom = dom(get("wms?request=getCapabilities&version=1.1.1&namespace=cite"), true); Element e = dom.getDocumentElement(); assertEquals("WMT_MS_Capabilities", e.getLocalName()); XpathEngine xpath = XMLUnit.newXpathEngine(); assertTrue( xpath.getMatchingNodes("//Layer/Name[starts-with(., cite)]", dom).getLength() > 0); assertEquals( 0, xpath.getMatchingNodes("//Layer/Name[not(starts-with(., cite))]", dom).getLength()); }
private void parseBoms() { NodeList nodes; try { nodes = this.eng.getMatchingNodes( createRootNodeXPath( "dependencyManagement/pom:dependencies/pom:dependency"), throw new IllegalStateException("Cannot find path", ex); for (int i = 0; i < nodes.getLength(); i++) { Node item = nodes.item(i); if (item instanceof Element) { BillOfMaterials bom = new BillOfMaterials(); NodeList groupId = element.getElementsByTagName("groupId"); if (groupId.getLength() > 0) { bom.setGroupId(groupId.item(0).getTextContent()); if (artifactId.getLength() > 0) { bom.setArtifactId(artifactId.item(0).getTextContent());
@Test public void testGetAllAsHTML() throws Exception { Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/workspaces/sf/wmtsstores.html"); List<WMTSStoreInfo> stores = catalog.getStoresByWorkspace("sf", WMTSStoreInfo.class); NodeList links = xp.getMatchingNodes("//html:a", dom); assertEquals(stores.size(), links.getLength()); for (int i = 0; i < stores.size(); i++) { WMTSStoreInfo store = stores.get(i); Element link = (Element) links.item(i); assertTrue(link.getAttribute("href").endsWith(store.getName() + ".html")); } }
public void testCircle() throws Exception { PolygonEncoder encoder = new PolygonEncoder(gtEncoder, "gml", GML.NAMESPACE); Geometry geometry = new WKTReader2() .read("CURVEPOLYGON(CIRCULARSTRING(-10 0, -8 2, -6 0, -8 -2, -10 0))"); Document doc = encode(encoder, geometry); // XMLTestSupport.print(doc); assertEquals(1, xpath.getMatchingNodes("//gml:Polygon", doc).getLength()); assertEquals(1, xpath.getMatchingNodes("//gml:Polygon/gml:exterior", doc).getLength()); assertEquals(0, xpath.getMatchingNodes("//gml:Polygon/gml:interior", doc).getLength()); String ext1 = "//gml:Polygon/gml:exterior/gml:Ring/gml:curveMember[1]"; assertEquals( "circularArc3Points", xpath.evaluate(ext1 + "/gml:Curve/gml:segments/gml:ArcString/@interpolation", doc)); assertEquals( "-10 0 -8 2 -6 0 -8 -2 -10 0", xpath.evaluate(ext1 + "/gml:Curve/gml:segments/gml:ArcString/gml:posList", doc)); }
@Test public void testGetAllAsHTML() throws Exception { Document dom = getAsDOM(ROOT_PATH + "/workspaces/sf/datastores.html"); List<DataStoreInfo> datastores = catalog.getDataStoresByWorkspace("sf"); NodeList links = xp.getMatchingNodes("//html:a", dom); assertEquals(datastores.size(), links.getLength()); for (int i = 0; i < datastores.size(); i++) { DataStoreInfo ds = datastores.get(i); Element link = (Element) links.item(i); assertTrue(link.getAttribute("href").endsWith(ds.getName() + ".html")); } }
Document doc = encode(encoder, geometry); assertEquals(1, xpath.getMatchingNodes("//gml:MultiCurve", doc).getLength()); assertEquals( 2, xpath.getMatchingNodes("//gml:MultiCurve/gml:curveMember", doc).getLength()); assertEquals( "105 105 125 125", assertEquals( 1, xpath.getMatchingNodes( "//gml:MultiCurve/gml:curveMember[2]/gml:Curve/gml:segments/*", doc) .getLength());