Search in sources :

Example 41 with CollectionManagementService

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");
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) AfterClass(org.junit.AfterClass)

Example 42 with CollectionManagementService

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);
    }
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Resource(org.xmldb.api.base.Resource) Collection(org.xmldb.api.base.Collection) BeforeClass(org.junit.BeforeClass)

Example 43 with CollectionManagementService

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);
    }
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService)

Example 44 with CollectionManagementService

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);
}
Also used : EXistResource(org.exist.xmldb.EXistResource) CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) EXistCollectionManagementService(org.exist.xmldb.EXistCollectionManagementService) BinaryResource(org.xmldb.api.modules.BinaryResource) XMLResource(org.xmldb.api.modules.XMLResource)

Example 45 with CollectionManagementService

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());
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) EXistCollectionManagementService(org.exist.xmldb.EXistCollectionManagementService) IndexQueryService(org.exist.xmldb.IndexQueryService) Collection(org.xmldb.api.base.Collection) ResourceSet(org.xmldb.api.base.ResourceSet)

Aggregations

CollectionManagementService (org.xmldb.api.modules.CollectionManagementService)148 Collection (org.xmldb.api.base.Collection)84 XMLResource (org.xmldb.api.modules.XMLResource)33 Resource (org.xmldb.api.base.Resource)25 Before (org.junit.Before)23 EXistCollectionManagementService (org.exist.xmldb.EXistCollectionManagementService)21 After (org.junit.After)21 Test (org.junit.Test)19 UserManagementService (org.exist.xmldb.UserManagementService)14 ResourceSet (org.xmldb.api.base.ResourceSet)14 BinaryResource (org.xmldb.api.modules.BinaryResource)13 XPathQueryService (org.xmldb.api.modules.XPathQueryService)9 Account (org.exist.security.Account)7 IndexQueryService (org.exist.xmldb.IndexQueryService)6 AfterClass (org.junit.AfterClass)6 Database (org.xmldb.api.base.Database)6 XMLDBException (org.xmldb.api.base.XMLDBException)6 Path (java.nio.file.Path)5 BeforeClass (org.junit.BeforeClass)5 InputStream (java.io.InputStream)4