use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class SerializationTest method setUp.
@Before
public void setUp() throws XMLDBException {
final Collection root = DatabaseManager.getCollection(getBaseUri() + "/db", TestUtils.ADMIN_DB_USER, TestUtils.ADMIN_DB_PWD);
final CollectionManagementService service = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
testCollection = service.createCollection(TEST_COLLECTION_NAME);
assertNotNull(testCollection);
final XMLResource res = (XMLResource) testCollection.createResource(XML_DOC_NAME, "XMLResource");
res.setContent(XML);
testCollection.storeResource(res);
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class CollectionConfigurationTest method collectionConfigurationService8.
/**
* Overwrite configuration in a sub collection
*/
@Test
public void collectionConfigurationService8() throws XMLDBException {
Collection testCollection = DatabaseManager.getCollection(XmldbURI.LOCAL_DB + "/" + TEST_COLLECTION);
CollectionManagementService cms = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0");
Collection sub2 = cms.createCollection(COLLECTION_SUB2.toString());
UserManagementService ums = (UserManagementService) sub2.getService("UserManagementService", "1.0");
ums.chmod("rwxr-xr-x");
// Configure collection automatically
IndexQueryService idxConf = (IndexQueryService) testCollection.getService("IndexQueryService", "1.0");
idxConf.configureCollection(CONFIG1);
// Overwrite main configuration with an empty configuration in the subcollection
idxConf = (IndexQueryService) sub2.getService("IndexQueryService", "1.0");
idxConf.configureCollection(EMPTY_CONFIG);
// ... then index document
XMLResource doc = (XMLResource) sub2.createResource(TestConstants.TEST_XML_URI.toString(), "XMLResource");
doc.setContent(DOCUMENT_CONTENT);
sub2.storeResource(doc);
XPathQueryService service = (XPathQueryService) sub2.getService("XPathQueryService", "1.0");
// index should be empty
ResourceSet result = service.query("util:index-key-occurrences(/test/a, 1)");
assertEquals(0, result.getSize());
result = service.query("util:index-key-occurrences(/test/b, \"1\")");
assertEquals(0, result.getSize());
result = service.query("util:qname-index-lookup(xs:QName(\"a\"), 1 ) ");
assertEquals(0, result.getSize());
result = service.query("util:qname-index-lookup(xs:QName(\"b\"), \"1\" ) ");
assertEquals(0, result.getSize());
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class CollectionConfigurationTest method invalidConfiguration1.
@Test
public void invalidConfiguration1() throws XMLDBException {
Collection testCollection = DatabaseManager.getCollection(XmldbURI.LOCAL_DB + "/" + TEST_COLLECTION);
CollectionManagementService cms = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0");
Collection sub2 = cms.createCollection(COLLECTION_SUB2.toString());
UserManagementService ums = (UserManagementService) sub2.getService("UserManagementService", "1.0");
ums.chmod("rwxr-xr-x");
IndexQueryService idxConf = (IndexQueryService) testCollection.getService("IndexQueryService", "1.0");
idxConf.configureCollection(INVALID_CONFIG1);
// ... then index document
XMLResource doc = (XMLResource) sub2.createResource(TestConstants.TEST_XML_URI.toString(), "XMLResource");
doc.setContent(DOCUMENT_CONTENT);
sub2.storeResource(doc);
XPathQueryService service = (XPathQueryService) sub2.getService("XPathQueryService", "1.0");
// index should be empty since configuration was invalid
ResourceSet result = service.query("util:index-key-occurrences(/test/a, 1)");
assertEquals(0, result.getSize());
result = service.query("util:qname-index-lookup(xs:QName(\"a\"), 1 ) ");
assertEquals(0, result.getSize());
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class EvalTest method createCollection.
private Collection createCollection(String collectionName) throws XMLDBException {
Collection collection = existEmbeddedServer.getRoot().getChildCollection(collectionName);
if (collection == null) {
CollectionManagementService cmService = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
cmService.createCollection(collectionName);
}
collection = DatabaseManager.getCollection(XmldbURI.LOCAL_DB + "/" + collectionName, "admin", "");
assertNotNull(collection);
return collection;
}
use of org.xmldb.api.modules.CollectionManagementService in project exist by eXist-db.
the class AbstractTestUpdate method setUp.
@Before
public void setUp() throws Exception {
final CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
testCollection = service.createCollection("test");
final IndexQueryService idx = (IndexQueryService) testCollection.getService("IndexQueryService", "1.0");
idx.configureCollection(XCONF);
}
Aggregations