use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class AbstractPsychoPathWTPTest method assertXPathTrue.
protected void assertXPathTrue(String xpath, DynamicContext dc, Document domDoc) {
XSBoolean result = evaluateBoolXPath(xpath, dc, domDoc);
assertEquals(true, result.value());
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class TestBugs method testDocumentUriBug.
public void testDocumentUriBug() throws Exception {
// Bug 274731
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbf.newDocumentBuilder();
InputSource inputSource = getTestSource("http://resolved-locally/xml/note.xml");
domDoc = docBuilder.parse(inputSource);
setupDynamicContext(null);
String xpath = "document-uri(/) eq xs:anyURI('http://resolved-locally/xml/note.xml')";
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
XSBoolean result = (XSBoolean) rs.first();
String actual = "false";
if (result != null) {
actual = result.getStringValue();
}
assertEquals("true", actual);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class TestBugs method evaluateBoolean.
// I can't stand to see so much duplicated code!!!
private boolean evaluateBoolean(String xpath) throws Exception {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
XSBoolean result = (XSBoolean) rs.first();
return result.value();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class TestBugs method testBug334842.
public void testBug334842() throws Exception {
// Bug 334842
bundle = Platform.getBundle("org.w3c.xqts.testsuite");
URL fileURL = bundle.getEntry("/TestSources/emptydoc.xml");
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
// test a)
String xpath = "xs:Name('x:abc') eq xs:Name('x:abc')";
compileXPath(xpath);
ResultSequence rsRes = evaluate(domDoc);
XSBoolean result = (XSBoolean) rsRes.get(0);
assertEquals("true", result.getStringValue());
// test b)
xpath = "xs:NCName('x:abc') eq xs:NCName('x:abc')";
compileXPath(xpath);
try {
rsRes = evaluate(domDoc);
assertTrue(false);
} catch (DynamicError ex) {
// a 'DynamicError' exception indicates, that this test is a success
assertTrue(true);
}
// test c)
xpath = "xs:NCName('abc') eq xs:NCName('abc')";
compileXPath(xpath);
rsRes = evaluate(domDoc);
result = (XSBoolean) rsRes.get(0);
assertEquals("true", result.getStringValue());
// test d)
xpath = "xs:ID('x:abc') eq xs:ID('x:abc')";
compileXPath(xpath);
try {
rsRes = evaluate(domDoc);
assertTrue(false);
} catch (DynamicError ex) {
// a 'DynamicError' exception indicates, that this test is a success
assertTrue(true);
}
// test e)
xpath = "xs:ID('abc') eq xs:ID('abc')";
compileXPath(xpath);
rsRes = evaluate(domDoc);
result = (XSBoolean) rsRes.get(0);
assertEquals("true", result.getStringValue());
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class TestBugs method testXSPositiveInteger.
public void testXSPositiveInteger() throws Exception {
// Bug 277632
bundle = Platform.getBundle("org.w3c.xqts.testsuite");
URL fileURL = bundle.getEntry("/TestSources/emptydoc.xml");
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
// min value of xs:positiveInteger is 1
// max value of xs:positiveInteger is INF
String xpath = "xs:positiveInteger('1') eq 1";
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
XSBoolean result = (XSBoolean) rs.first();
String actual = result.getStringValue();
assertEquals("true", actual);
}
Aggregations