use of org.custommonkey.xmlunit.SimpleNamespaceContext in project jersey by jersey.
the class WadlBeanParamTest method testBeanParamConstructorInitializedBean.
private void testBeanParamConstructorInitializedBean(String resource) throws Exception {
final Response response = target("/application.wadl").request().get();
final Document d = WadlResourceTest.extractWadlAsDocument(response);
final XPath xp = XPathFactory.newInstance().newXPath();
final SimpleNamespaceResolver nsContext = new SimpleNamespaceResolver("wadl", "http://wadl.dev.java.net/2009/02");
xp.setNamespaceContext(nsContext);
final Diff diff = XMLUnit.compareXML(nodeAsString(xp.evaluate("//wadl:resource[@path='wadlBeanParamReference']/wadl:resource", d, XPathConstants.NODE)), nodeAsString(xp.evaluate("//wadl:resource[@path='" + resource + "']/wadl:resource", d, XPathConstants.NODE)));
XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(ImmutableMap.of("wadl", "http://wadl.dev.java.net/2009/02")));
diff.overrideElementQualifier(elementQualifier);
XMLAssert.assertXMLEqual(diff, true);
}
use of org.custommonkey.xmlunit.SimpleNamespaceContext in project camel by apache.
the class Utils method evaluate.
/**
* Evaluate an XPATH expression.
*
* @param xpath
* @param xml
* @return
*/
public static String evaluate(final String xpath, final String xml) {
Map<String, Object> m = new HashMap<String, Object>();
m.put("svrl", Constants.HTTP_PURL_OCLC_ORG_DSDL_SVRL);
XpathEngine xpathEngine = XMLUnit.newXpathEngine();
xpathEngine.setNamespaceContext(new SimpleNamespaceContext(m));
try {
return xpathEngine.evaluate(xpath, XMLUnit.buildControlDocument(xml));
} catch (Exception e) {
LOG.error("Failed to apply xpath {} on xml {}", xpath, xml);
throw new RuntimeCamelException(e);
}
}
use of org.custommonkey.xmlunit.SimpleNamespaceContext in project sling by apache.
the class ReferenceTypeHintTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
postUrl = HTTP_BASE_URL + TEST_BASE_PATH + "/" + System.currentTimeMillis();
Map<String, String> m = new HashMap<String, String>();
m.put("sv", "http://www.jcp.org/jcr/sv/1.0");
NamespaceContext ctx = new SimpleNamespaceContext(m);
XMLUnit.setXpathNamespaceContext(ctx);
final NameValuePairList props = new NameValuePairList();
props.add("a", "");
props.add("jcr:mixinTypes", "mix:referenceable");
firstCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
firstUuid = getProperty(firstCreatedNodeUrl, "jcr:uuid");
firstPath = getPath(firstCreatedNodeUrl);
secondCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
secondUuid = getProperty(secondCreatedNodeUrl, "jcr:uuid");
secondPath = getPath(secondCreatedNodeUrl);
}
use of org.custommonkey.xmlunit.SimpleNamespaceContext in project ddf by codice.
the class AbstractTestCompositeGeometry method setupTestClass.
@BeforeClass
public static void setupTestClass() {
HashMap map = new HashMap();
map.put("gml", "http://www.opengis.net/gml");
map.put("georss", "http://www.georss.org/georss");
NamespaceContext ctx = new SimpleNamespaceContext(map);
XMLUnit.setXpathNamespaceContext(ctx);
XMLUnit.setIgnoreWhitespace(true);
}
use of org.custommonkey.xmlunit.SimpleNamespaceContext in project ddf by codice.
the class TestCswFilterDelegate method setupTestClass.
@BeforeClass
public static void setupTestClass() throws JAXBException, ParseException {
XMLUnit.setIgnoreWhitespace(true);
marshaller = JAXB_CONTEXT.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
POS_LIST_GEO_FILTER_PROP_MAP.put(USE_POS_LIST_GEO_FILTER_PROP_MAP_KEY, "true");
SAMPLE_DISTANCE_GEO_FILTER_PROP_MAP.put(DISTANCE_GEO_FILTER_PROP_MAP_KEY, Double.toString(SAMPLE_DISTANCE));
SAMPLE_DISTANCE_POS_LIST_GEO_FILTER_PROP_MAP.put(USE_POS_LIST_GEO_FILTER_PROP_MAP_KEY, "true");
SAMPLE_DISTANCE_POS_LIST_GEO_FILTER_PROP_MAP.put(DISTANCE_GEO_FILTER_PROP_MAP_KEY, Double.toString(SAMPLE_DISTANCE));
THOUSAND_METER_DISTANCE_GEO_FILTER_PROP_MAP.put(DISTANCE_GEO_FILTER_PROP_MAP_KEY, "1000.0");
// XPath query support.
HashMap<String, String> map = new HashMap<>();
map.put("", "http://www.opengis.net/cat/csw/2.0.2");
map.put("ogc", "http://www.opengis.net/ogc");
NamespaceContext ctx = new SimpleNamespaceContext(map);
XMLUnit.setXpathNamespaceContext(ctx);
}
Aggregations