Search in sources :

Example 71 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class DuplicateAttributesTest method setup.

@BeforeClass
public static void setup() throws XMLDBException {
    final CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
    testCollection = service.createCollection("test");
    assertNotNull(testCollection);
    Resource resource = testCollection.createResource("stored1.xml", "XMLResource");
    resource.setContent(STORED_DOC1);
    testCollection.storeResource(resource);
    resource = testCollection.createResource("stored2.xml", "XMLResource");
    resource.setContent(STORED_DOC2);
    testCollection.storeResource(resource);
    resource = testCollection.createResource("docdtd.xml", "XMLResource");
    resource.setContent(DOC_WITH_DTD);
    testCollection.storeResource(resource);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Resource(org.xmldb.api.base.Resource) BeforeClass(org.junit.BeforeClass)

Example 72 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class RemoveAppendTest method setUp.

@Before
public void setUp() throws Exception {
    rootCol = existXmldbEmbeddedServer.getRoot();
    testCol = rootCol.getChildCollection(XmldbURI.ROOT_COLLECTION + "/test");
    if (testCol != null) {
        CollectionManagementService mgr = DBUtils.getCollectionManagementService(rootCol);
        mgr.removeCollection(XmldbURI.ROOT_COLLECTION + "/test");
    }
    testCol = DBUtils.addCollection(rootCol, "test");
    assertNotNull(testCol);
    DBUtils.addXMLResource(testCol, "test.xml", "<test/>");
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService)

Example 73 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class StressTest method setUp.

@Before
public void setUp() throws XMLDBException {
    final Collection rootCol = existXmldbEmbeddedServer.getRoot();
    testCol = rootCol.getChildCollection(XmldbURI.ROOT_COLLECTION + "/test");
    if (testCol != null) {
        final CollectionManagementService mgr = DBUtils.getCollectionManagementService(rootCol);
        mgr.removeCollection(XmldbURI.ROOT_COLLECTION + "/test");
    }
    testCol = DBUtils.addCollection(rootCol, "test");
    assertNotNull(testCol);
    tags = IntStream.range(0, RUNS).mapToObj(i -> "TAG" + i).toArray(String[]::new);
    DBUtils.addXMLResource(testCol, "test.xml", XML);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Collection(org.xmldb.api.base.Collection) Before(org.junit.Before)

Example 74 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class XmldbBinariesTest method removeCollection.

@Override
protected void removeCollection(final XmldbURI collectionUri) throws Exception {
    Collection colRoot = null;
    try {
        colRoot = DatabaseManager.getCollection(getBaseUri() + "/db", ADMIN_DB_USER, ADMIN_DB_PWD);
        final Collection colTest = colRoot.getChildCollection("test");
        try {
            final CollectionManagementService cms = (CollectionManagementService) colTest.getService("CollectionManagementService", "1.0");
            final String testCollectionName = collectionUri.lastSegment().toString();
            cms.removeCollection(testCollectionName);
        } finally {
            if (colTest != null) {
                colTest.close();
            }
        }
    } finally {
        if (colRoot != null) {
            colRoot.close();
        }
    }
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService)

Example 75 with CollectionManagementService

use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.

the class XmldbBinariesTest method getOrCreateCollection.

private Collection getOrCreateCollection(final Collection parent, final String childName) throws XMLDBException {
    Collection child = parent.getChildCollection(childName);
    if (child == null) {
        final CollectionManagementService cms = (CollectionManagementService) parent.getService("CollectionManagementService", "1.0");
        child = cms.createCollection(childName);
    }
    return child;
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService)

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