Refine search
@Override protected void setUp() throws Exception { super.setUp(); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("test", TEST.TestFeature.getNamespaceURI()); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); }
public GetCapabilitiesScaleHintTest() { Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); xpath = XMLUnit.newXpathEngine(); }
@BeforeClass public static void beforeClass() { XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalize(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); Map<String,String> namespaces = new HashMap<>(); namespaces.put("rapi", "http://marklogic.com/rest-api"); namespaces.put("prop", "http://marklogic.com/xdmp/property"); namespaces.put("xs", "http://www.w3.org/2001/XMLSchema"); namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); namespaces.put("search", "http://marklogic.com/appservices/search"); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(namespaces); xpather = XMLUnit.newXpathEngine(); xpather.setNamespaceContext(namespaceContext); }
public PomAssert(String content) { this.content = content; this.eng = XMLUnit.newXpathEngine(); Map<String, String> context = new LinkedHashMap<>(); context.put("pom", "http://maven.apache.org/POM/4.0.0"); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(context); this.eng.setNamespaceContext(namespaceContext); try { this.doc = XMLUnit.buildControlDocument(content); } catch (Exception ex) { throw new IllegalArgumentException("Cannot parse XML", ex); } this.parentPom = parseParent(); parseProperties(); parseDependencies(); parseBoms(); parseRepositories(); }
@Override protected void setUp() throws Exception { out = new ByteArrayOutputStream(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); builder = factory.newDocumentBuilder(); Map<String, String> nsMap = new HashMap<String, String>(); nsMap.put(NS_FCFG_PREFIX, NS_FCFG); NamespaceContext ctx = new SimpleNamespaceContext(nsMap); XMLUnit.setXpathNamespaceContext(ctx); XMLUnit.setIgnoreWhitespace(false); }
SimpleNamespaceContext ctx = new SimpleNamespaceContext(); ctx.bindNamespaceUri("g", namespace); // the same URI as before ctx.bindNamespaceUri("c", ...); // the namespace bound to gl-cor: xPath.setNamespaceContext(ctx); NodeList nodes = (NodeList) xPath.evaluate("/c:entityInformation/g:entityPhoneNumber/g:phoneNumber", xmlDoc, XPathConstants.NODESET);
@Override public void setUp() throws Exception { Map<String, String> nsMap = new HashMap<String, String>(); nsMap.put(OAI_DC.prefix, OAI_DC.uri); nsMap.put(DC.prefix, DC.uri); NamespaceContext ctx = new SimpleNamespaceContext(nsMap); engine = XMLUnit.newXpathEngine(); engine.setNamespaceContext(ctx); }
XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); HashMap<String, String> prefMap = new HashMap<String, String>() {{ put("main", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"); put("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); }}; SimpleNamespaceContext namespaces = new SimpleNamespaceContext(prefMap); xpath.setNamespaceContext(namespaces); XPathExpression expr = xpath .compile("/main:workbook/main:sheets/main:sheet[1]"); Object result = expr.evaluate(doc, XPathConstants.NODESET);
@Test public void testOpenLayersProxy() throws Exception { NamespaceContext oldContext = XMLUnit.getXpathNamespaceContext(); try { Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xhtml", "http://www.w3.org/1999/xhtml"); registerNamespaces(namespaces); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); // setup a proxy base url GeoServerInfo global = getGeoServer().getGlobal(); global.getSettings().setProxyBaseUrl("http://www.geoserver.org:1234/gs"); getGeoServer().save(global); Document dom = getAsDOM( "wms?LAYERS=sf:indexed&STYLES=&FORMAT=application/openlayers&SERVICE=WMS&VERSION=1.1.1" + "&REQUEST=GetMap&SRS=EPSG:4326&BBOX=100,78,104,80&WIDTH=300&HEIGHT=150"); assertXpathEvaluatesTo( "http://www.geoserver.org:1234/gs/openlayers/OpenLayers.js", "//xhtml:script[contains(@src, 'OpenLayers.js')]/@src", dom); } finally { XMLUnit.setXpathNamespaceContext(oldContext); } }
XPath xPath = XPathFactory.newInstance().newXPath(); SimpleNamespaceContext nsContext = new SimpleNamespaceContext(); nsContext.addNamespace("t", "http://www.w3.org/2001/XMLSchema"); xPath.setNamespaceContext(nsContext); xPath.evaluate("//t:schema", dDoc, XPathConstants.NODESET);
nsCtx = new SimpleNamespaceContext(); xpath.setNamespaceContext(nsCtx); nsCtx.bindNamespaceUri(namespaces[i], namespaces[++i]); throw new HanaHttpConnectivityException(e); } finally { nsCtx.clear();
this.namespaces.push(new SimpleNamespaceContext()); SimpleNamespaceContext newSnc = new SimpleNamespaceContext(); for (Iterator<?> prefixes = snc.getBoundPrefixes(); prefixes.hasNext();) { String pfx = (String)prefixes.next(); newSnc.bindNamespaceUri(pfx, snc.getNamespaceURI(pfx)); newSnc.bindNamespaceUri("", snc.getNamespaceURI("")); newSnc.setBindings(_namespaces); this.namespaces.push(newSnc); this.lastNSContextsDifferent = true;
/** Instantiates a new gets the capabilities SRC order test. */ public GetCapabilitiesSRCOrderTest() { Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); namespaces.put("wms", "http://www.opengis.net/wms"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); xpath = XMLUnit.newXpathEngine(); }
@BeforeClass public static void beforeClass() { Common.connect(); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalize(true); XMLUnit.setNormalizeWhitespace(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); Map<String,String> namespaces = new HashMap<>(); namespaces.put("rapi", "http://marklogic.com/rest-api"); namespaces.put("prop", "http://marklogic.com/xdmp/property"); namespaces.put("xs", "http://www.w3.org/2001/XMLSchema"); namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(namespaces); xpather = XMLUnit.newXpathEngine(); xpather.setNamespaceContext(namespaceContext); } @AfterClass
@Test public void testSayHello() throws Exception { HTTPMixIn httpMixIn = new HTTPMixIn(); httpMixIn.initialize(); try { String response = httpMixIn.postString("http://localhost:8080/SayHelloService/SayHelloService", SOAP_REQUEST); org.w3c.dom.Document d = XMLUnit.buildControlDocument(response); java.util.HashMap<String,String> m = new java.util.HashMap<String,String>(); m.put("tns", "http://www.jboss.org/bpel/examples"); NamespaceContext ctx = new SimpleNamespaceContext(m); XpathEngine engine = XMLUnit.newXpathEngine(); engine.setNamespaceContext(ctx); NodeList l = engine.getMatchingNodes("//tns:result", d); assertEquals(1, l.getLength()); assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType()); if (!l.item(0).getTextContent().equals("Hello Fred")) { fail("Expecting 'Hello Fred'"); } } finally { httpMixIn.uninitialize(); } }
@Test public void testDeployment() throws Exception { HTTPMixIn httpMixIn = new HTTPMixIn(); httpMixIn.initialize(); try { XMLUnit.setIgnoreWhitespace(true); String response = httpMixIn.postString("http://localhost:8080/quickstart-cdi-bus/OrderService", SOAP_REQUEST); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("ns", "urn:switchyard-quickstart:cdi-bus:1.0"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); XMLAssert.assertXpathEvaluatesTo("PO-19838-XYZ", "//ns:orderAck/orderId", response); XMLAssert.assertXpathEvaluatesTo("true", "//ns:orderAck/accepted", response); XMLAssert.assertXpathEvaluatesTo("Order Accepted", "//ns:orderAck/status", response); } finally { httpMixIn.uninitialize(); } }
XPath xpath = xPathfactory.newXPath(); SimpleNamespaceContext nsCtx = new SimpleNamespaceContext(); xpath.setNamespaceContext(nsCtx); nsCtx.bindNamespaceUri("pom", "http://maven.apache.org/POM/4.0.0"); // ... Node node = (Node)xpath.evaluate("/pom:project/pom:parent/pom:version/text()", source, XPathConstants.NODE);
XpathEngine xpathEngine = XMLUnit.newXpathEngine(); Map<String, String> finalNamespaces = new HashMap<>(); xpathEngine.setNamespaceContext(new SimpleNamespaceContext(finalNamespaces)); return xpathEngine;
private void regenerateContext() { namespaceContext = new SimpleNamespaceContext(namespaces); }
public GetCapabilitiesScaleDenominatorTest() { Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); namespaces.put("wms", "http://www.opengis.net/wms"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); xpath = XMLUnit.newXpathEngine(); }