use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class ProtectedModeTest method queryCollection.
@Test
public void queryCollection() throws XMLDBException {
final Collection root = DatabaseManager.getCollection("xmldb:exist:///db/protected", "admin", "");
final EXistXPathQueryService service = (EXistXPathQueryService) root.getService("XQueryService", "1.0");
try {
service.beginProtected();
final ResourceSet result = service.query("collection('/db/protected/test5')//book");
assertEquals(DOCUMENT_COUNT, result.getSize());
} finally {
service.endProtected();
}
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class ProtectedModeTest method queryRoot.
@Test
public void queryRoot() throws XMLDBException {
final Collection root = DatabaseManager.getCollection("xmldb:exist:///db/protected", "admin", "");
final EXistXPathQueryService service = (EXistXPathQueryService) root.getService("XQueryService", "1.0");
try {
service.beginProtected();
final ResourceSet result = service.query("//book");
assertEquals(COLLECTION_COUNT * DOCUMENT_COUNT, result.getSize());
} finally {
service.endProtected();
}
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class CollectionConfigurationValidationModeTest method storeDocument.
private void storeDocument(final String collection, final String name, final String document) throws XMLDBException {
final ResourceSet result = existEmbeddedServer.executeQuery("xmldb:store(\"" + collection + "\", \"" + name + "\", " + document + ")");
final String r = (String) result.getResource(0).getContent();
assertEquals("Store doc", collection + "/" + name, r);
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class JavaFunctionsTest method lists.
/**
* Tests simple list functions to make sure java functions are being
* called properly
*/
@Test
public void lists() throws XPathException {
try {
String query = "declare namespace list='java:java.util.ArrayList'; " + "let $list := list:new() " + "let $actions := (list:add($list,'a'),list:add($list,'b'),list:add($list,'c')) " + "return list:get($list,1)";
ResourceSet result = existEmbeddedServer.executeQuery(query);
String r = (String) result.getResource(0).getContent();
assertEquals("b", r);
} catch (XMLDBException e) {
// if exception is a java binding exception and java binding is disabled then this is a success
if (e.getMessage().indexOf("Java binding is disabled in the current configuration") > -1 && !javabindingenabled) {
return;
}
LOG.error(e.getMessage(), e);
fail(e.getMessage());
}
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class OptimizerTest method execute.
private void execute(String query, boolean optimize, String message, long expected) throws XMLDBException {
XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
if (optimize) {
query = NAMESPACES + OPTIMIZE + query;
} else {
query = NAMESPACES + NO_OPTIMIZE + query;
}
ResourceSet result = service.query(query);
assertEquals(message, expected, result.getSize());
}
Aggregations