use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class VariablesTest method createCollection.
private static Collection createCollection(final String collectionName) throws XMLDBException {
Collection collection = existEmbeddedServer.getRoot().getChildCollection(collectionName);
final CollectionManagementService cmService = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
if (collection == null) {
// cmService.removeCollection(collectionName);
cmService.createCollection(collectionName);
}
collection = DatabaseManager.getCollection(XmldbURI.LOCAL_DB + "/" + collectionName, TestUtils.ADMIN_DB_USER, TestUtils.ADMIN_DB_PWD);
assertNotNull(collection);
return collection;
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class FunSubSequenceTest method cleanup.
@AfterClass
public static void cleanup() throws XMLDBException {
final CollectionManagementService collectionManagementService = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
collectionManagementService.removeCollection(test.getName());
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class XQueryFunctionsTest method base64BinaryCast.
@Test
public void base64BinaryCast() throws XMLDBException, URISyntaxException {
final String TEST_BINARY_COLLECTION = "testBinary";
final String TEST_COLLECTION = "/db/" + TEST_BINARY_COLLECTION;
final String BINARY_RESOURCE_FILENAME = "logo.jpg";
final String XML_RESOURCE_FILENAME = "logo.xml";
// create a test collection
CollectionManagementService colService = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
Collection testCollection = colService.createCollection(TEST_BINARY_COLLECTION);
assertNotNull(testCollection);
final Path fLogo = Paths.get(getClass().getResource("value/logo.jpg").toURI());
// store the eXist logo in the test collection
BinaryResource br = (BinaryResource) testCollection.createResource(BINARY_RESOURCE_FILENAME, "BinaryResource");
br.setContent(fLogo);
testCollection.storeResource(br);
// create an XML resource with the logo base64 embedded in it
String queryStore = "xquery version \"1.0\";\n\n" + "let $embedded := <logo><image>{util:binary-doc(\"" + TEST_COLLECTION + "/" + BINARY_RESOURCE_FILENAME + "\")}</image></logo> return\n" + "xmldb:store(\"" + TEST_COLLECTION + "\", \"" + XML_RESOURCE_FILENAME + "\", $embedded)";
ResourceSet resultStore = existEmbeddedServer.executeQuery(queryStore);
assertEquals("store, Expect single result", 1, resultStore.getSize());
assertEquals("Expect stored filename as result", TEST_COLLECTION + "/" + XML_RESOURCE_FILENAME, resultStore.getResource(0).getContent().toString());
// retrieve the base64 image from the XML resource and try to cast to xs:base64Binary
String queryRetreive = "xquery version \"1.0\";\n\n" + "let $image := doc(\"" + TEST_COLLECTION + "/" + XML_RESOURCE_FILENAME + "\")/logo/image return\n" + "$image/text() cast as xs:base64Binary";
ResourceSet resultRetreive = existEmbeddedServer.executeQuery(queryRetreive);
assertEquals("retreive, Expect single result", 1, resultRetreive.getSize());
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class ProtectedModeTest method cleanupDb.
@AfterClass
public static void cleanupDb() throws XMLDBException {
final CollectionManagementService cmgr = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
cmgr.removeCollection("protected");
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class AbstractTestUpdate method tearDown.
@After
public void tearDown() throws XMLDBException {
CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
service.removeCollection("test");
Collection confColl = DatabaseManager.getCollection("xmldb:exist:///db/system/config/db", TestUtils.ADMIN_DB_USER, TestUtils.ADMIN_DB_PWD);
service = (CollectionManagementService) confColl.getService("CollectionManagementService", "1.0");
service.removeCollection("test");
testCollection = null;
}
Aggregations