use of org.exist.xmldb.EXistXQueryService in project exist by eXist-db.
the class InternalModuleTest method moduleVariables.
@Test
public void moduleVariables() throws XMLDBException {
final Source querySource = new StringSource(getModuleVariableQuery("org.exist.xquery.InternalModuleTest$TestModuleWithVariables"));
final EXistXQueryService queryService = (EXistXQueryService) existServer.getRoot().getService("XQueryService", "1.0");
moduleVariablesQuery(queryService, querySource, COUNTER.get());
}
use of org.exist.xmldb.EXistXQueryService in project exist by eXist-db.
the class XPathQueryTest method compile.
@Test
public void compile() throws XMLDBException {
final String invalidQuery = "for $i in (1 to 10)\n return $b";
final String validQuery = "for $i in (1 to 10) return $i";
final String validModule = "module namespace foo=\"urn:foo\";\n" + "declare function foo:test() { \"Hello World!\" };";
final String invalidModule = "module namespace foo=\"urn:foo\";\n" + "declare function foo:test() { \"Hello World! };";
final EXistXQueryService service = (EXistXQueryService) getQueryService();
boolean exceptionOccurred = false;
try {
service.compile(invalidQuery);
} catch (XMLDBException e) {
assertEquals(((XPathException) e.getCause()).getLine(), 2);
exceptionOccurred = true;
}
assertTrue("Expected an exception", exceptionOccurred);
exceptionOccurred = false;
try {
service.compileAndCheck(invalidModule);
} catch (XPathException e) {
exceptionOccurred = true;
}
assertTrue("Expected an exception", exceptionOccurred);
service.compile(validQuery);
service.compile(validModule);
}
use of org.exist.xmldb.EXistXQueryService in project exist by eXist-db.
the class ConcurrencyTest method xupdateDocs.
private void xupdateDocs(final String collectionName) throws XMLDBException, IOException, URISyntaxException {
storeDocs(collectionName);
final EXistXQueryService xqs = (EXistXQueryService) test.getService("XQueryService", "1.0");
ResourceSet result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
assertEquals(118, result.getSize());
final String xupdate = LuceneIndexTest.XUPDATE_START + " <xu:remove select=\"//SPEECH[ft:query(SPEAKER, 'juliet')]\"/>" + LuceneIndexTest.XUPDATE_END;
final XUpdateQueryService xuqs = (XUpdateQueryService) test.getService("XUpdateQueryService", "1.0");
xuqs.update(xupdate);
result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
assertEquals(0, result.getSize());
result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
assertEquals(98, result.getSize());
}
use of org.exist.xmldb.EXistXQueryService in project exist by eXist-db.
the class ConcurrencyTest method storeRemoveDocs.
private void storeRemoveDocs(final String collectionName) throws XMLDBException, IOException, URISyntaxException {
storeDocs(collectionName);
final EXistXQueryService xqs = (EXistXQueryService) test.getService("XQueryService", "1.0");
ResourceSet result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
assertEquals(98, result.getSize());
result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
assertEquals(118, result.getSize());
final String[] resources = test.listResources();
for (int i = 0; i < resources.length; i++) {
final Resource resource = test.getResource(resources[i]);
test.removeResource(resource);
}
result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
assertEquals(0, result.getSize());
result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
assertEquals(0, result.getSize());
}
Aggregations