use of com.evolveum.midpoint.prism.marshaller.XPathHolder in project midpoint by Evolveum.
the class XPathTest method variableTest.
@Test
public void variableTest() {
String xpathStr = "declare namespace v='http://vvv.com';" + "declare namespace x='http://www.xxx.com';" + "$v:var/x:xyz[10]";
XPathHolder xpath = new XPathHolder(xpathStr);
AssertJUnit.assertEquals("$v:var/x:xyz[10]", xpath.getXPathWithoutDeclarations());
AssertJUnit.assertEquals("http://vvv.com", xpath.getNamespaceMap().get("v"));
AssertJUnit.assertEquals("http://www.xxx.com", xpath.getNamespaceMap().get("x"));
}
use of com.evolveum.midpoint.prism.marshaller.XPathHolder in project midpoint by Evolveum.
the class XPathTest method strangeCharsTest.
@Test
public void strangeCharsTest() throws FileNotFoundException, UnsupportedEncodingException, IOException {
String xpathStr;
// The file contains strange chanrs (no-break spaces), so we need to pull
// it in exactly as it is.
File file = new File(FILENAME_STRANGECHARS);
FileInputStream stream = new FileInputStream(file);
try {
FileChannel fc = stream.getChannel();
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
xpathStr = Charset.forName("UTF-8").decode(bb).toString();
} finally {
stream.close();
}
XPathHolder xpath = new XPathHolder(xpathStr);
System.out.println("Stragechars Pure XPath: " + xpath.getXPathWithoutDeclarations());
AssertJUnit.assertEquals("$i:user/i:extension/ri:foobar", xpath.getXPathWithoutDeclarations());
System.out.println("Stragechars ROUND TRIP: " + xpath.getXPathWithDeclarations());
}
use of com.evolveum.midpoint.prism.marshaller.XPathHolder in project midpoint by Evolveum.
the class XPathTest method testUndefinedPrefix.
//not actual anymore..we have something like "wildcard" in xpath..there don't need to be prefix specified.we will try to match the local names
@Test(enabled = false)
public void testUndefinedPrefix() throws ParserConfigurationException, SAXException, IOException {
// GIVEN
Element el1 = parseDataGetEl1();
String xpathString = "/root/undef:el1";
el1.setTextContent(xpathString);
try {
// WHEN
XPathHolder xpath = new XPathHolder(el1);
AssertJUnit.fail("Unexpected success");
} catch (IllegalArgumentException e) {
// This is expected
}
}
Aggregations