Search in sources :

Example 56 with CollectionManagementService

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

the class ValueIndexTest method tearDown.

@After
public void tearDown() throws Exception {
    final CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
    service.removeCollection("test");
    testCollection = null;
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) After(org.junit.After)

Example 57 with CollectionManagementService

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

the class XPathQueryTest method setUp.

@Before
public void setUp() throws Exception {
    // initialize driver
    Class<?> cl = Class.forName("org.exist.xmldb.DatabaseImpl");
    Database database = (Database) cl.newInstance();
    database.setProperty("create-database", "true");
    DatabaseManager.registerDatabase(database);
    Collection root = DatabaseManager.getCollection(getBaseUri(), "admin", "");
    CollectionManagementService service = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
    testCollection = service.createCollection("test");
    assertNotNull(testCollection);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService)

Example 58 with CollectionManagementService

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

the class XQueryFunctionsTest method collectionAvailable2.

/**
 * create a collection and call collection-available, which should return true,
 * no exception thrown
 */
@Test
public void collectionAvailable2() throws XMLDBException {
    // add the test collection
    String collectionName = "testCollectionAvailable2";
    String collectionPath = XmldbURI.ROOT_COLLECTION + "/" + collectionName;
    String collectionURI = ROOT_COLLECTION_URI + "/" + collectionName;
    Collection testCollection = existEmbeddedServer.getRoot().getChildCollection(collectionName);
    if (testCollection == null) {
        CollectionManagementService cms = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
        cms.createCollection(collectionPath);
    }
    runCollectionAvailableTest(collectionPath, true);
    runCollectionAvailableTest(collectionURI, true);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Collection(org.xmldb.api.base.Collection)

Example 59 with CollectionManagementService

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

the class OptimizerTest method initDatabase.

@BeforeClass
public static void initDatabase() throws XMLDBException, IOException {
    CollectionManagementService service = (CollectionManagementService) server.getRoot().getService("CollectionManagementService", "1.0");
    testCollection = service.createCollection("test");
    Assert.assertNotNull(testCollection);
    IndexQueryService idxConf = (IndexQueryService) testCollection.getService("IndexQueryService", "1.0");
    idxConf.configureCollection(COLLECTION_CONFIG);
    XMLResource resource = (XMLResource) testCollection.createResource("test.xml", "XMLResource");
    resource.setContent(XML);
    testCollection.storeResource(resource);
    for (final String sampleName : SAMPLES.getShakespeareXmlSampleNames()) {
        resource = (XMLResource) testCollection.createResource(sampleName, XMLResource.RESOURCE_TYPE);
        try (final InputStream is = SAMPLES.getShakespeareSample(sampleName)) {
            resource.setContent(InputStreamUtil.readString(is, UTF_8));
        }
        testCollection.storeResource(resource);
    }
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) InputStream(java.io.InputStream) IndexQueryService(org.exist.xmldb.IndexQueryService) XMLResource(org.xmldb.api.modules.XMLResource)

Example 60 with CollectionManagementService

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

the class XmldbApiSecurityTest method createCol.

@Override
protected void createCol(final String collectionName, final String uid, final String pwd) throws ApiException {
    Collection col = null;
    try {
        col = DatabaseManager.getCollection(getBaseUri() + "/db", uid, pwd);
        CollectionManagementService cms = (CollectionManagementService) col.getService("CollectionManagementService", "1.0");
        cms.createCollection(collectionName);
    } catch (final XMLDBException xmldbe) {
        throw new ApiException(xmldbe);
    } finally {
        if (col != null) {
            try {
                col.close();
            } catch (final XMLDBException xmldbe) {
                throw new ApiException(xmldbe);
            }
        }
    }
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Collection(org.xmldb.api.base.Collection) XMLDBException(org.xmldb.api.base.XMLDBException)

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