use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class ConcurrencyTest method cleanup.
@AfterClass
public static void cleanup() throws XMLDBException {
final CollectionManagementService cmgr = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
cmgr.removeCollection("test");
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class ConcurrencyTest method initDB.
@BeforeClass
public static void initDB() throws XMLDBException {
final CollectionManagementService mgmt = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
final Collection test = mgmt.createCollection("test");
for (int i = 1; i <= DOC_COUNT; i++) {
final Resource r = test.createResource("test" + i + ".xml", "XMLResource");
final String XML = "<test id='" + i + "'>" + " <a>b</a>" + " <c>d</c>" + "</test>";
r.setContent(XML);
test.storeResource(r);
}
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class TriggerConfigTest method initDB.
@BeforeClass
public static void initDB() throws XMLDBException {
CollectionManagementService mgmt = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
Collection testCol = mgmt.createCollection("triggers");
for (int i = 1; i <= 2; i++) {
mgmt = (CollectionManagementService) testCol.getService("CollectionManagementService", "1.0");
testCol = mgmt.createCollection("sub" + i);
}
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class XQueryTriggerTest method setup.
/**
* create "log" document that will be updated by the trigger,
* and store the XQuery module implementing the trigger under test
*/
@Before
public void setup() throws XMLDBException {
final CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
testCollection = service.createCollection(TEST_COLLECTION);
assertNotNull(testCollection);
final XMLResource doc = (XMLResource) testCollection.createResource(LOG_NAME, "XMLResource");
doc.setContent(EMPTY_LOG);
testCollection.storeResource(doc);
final BinaryResource module = (BinaryResource) testCollection.createResource(MODULE_NAME, "BinaryResource");
((EXistResource) module).setMimeType("application/xquery");
module.setContent(MODULE.getBytes());
testCollection.storeResource(module);
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class XQueryTriggerTest method collectionDelete.
/**
* test a trigger fired by a Collection manipulations
*/
@Test
public void collectionDelete() throws XMLDBException {
final IndexQueryService idxConf = (IndexQueryService) testCollection.getService("IndexQueryService", "1.0");
idxConf.configureCollection(COLLECTION_CONFIG);
final CollectionManagementService service = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0");
final Collection collection = service.createCollection("test");
assertNotNull(collection);
service.removeCollection("test");
// remove the trigger for the Collection under test
idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);
ResourceSet result = existEmbeddedServer.executeQuery(BEFORE + CREATE + COLLECTION + testCollectionURI);
assertEquals(1, result.getSize());
result = existEmbeddedServer.executeQuery(AFTER + CREATE + COLLECTION + testCollectionURI);
assertEquals(1, result.getSize());
result = existEmbeddedServer.executeQuery(BEFORE + DELETE + COLLECTION + testCollectionURI);
assertEquals(1, result.getSize());
result = existEmbeddedServer.executeQuery(AFTER + DELETE + COLLECTION + testCollectionURI);
assertEquals(1, result.getSize());
result = existEmbeddedServer.executeQuery("/events/event");
assertEquals(4, result.getSize());
}
Aggregations