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;
}
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);
}
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);
}
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);
}
}
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);
}
}
}
}
Aggregations