use of org.xmldb.api.base.Collection in project exist by eXist-db.
the class DtdEntityTest method bugloadWithEntities.
@Test
@Ignore("Entity resolve bug")
public void bugloadWithEntities() throws XMLDBException {
final String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<!DOCTYPE procedure PUBLIC \"-//AAAA//DTD Procedure 0.4//EN\" \"aaaa.dtd\" >" + "<a>first empty: ∅ then trade: ™ </a>";
Collection col = null;
try {
col = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "entity");
ExistXmldbEmbeddedServer.storeResource(col, "docname.xml", input.getBytes(UTF_8));
// should throw XMLDBException
ExistXmldbEmbeddedServer.getXMLResource(col, "docname.xml");
} catch (final XMLDBException e) {
assertTrue(e.getMessage().contains("The entity \"empty\" was referenced, but not declared"));
return;
} finally {
if (col != null) {
col.close();
}
}
fail("Should have thrown XMLDBException");
}
use of org.xmldb.api.base.Collection in project exist by eXist-db.
the class DtdEntityTest method loadWithEntities.
@Test
public void loadWithEntities() throws XMLDBException {
final String input = "<a>first empty: ∅ then trade: ™ </a>";
Collection col = null;
try {
col = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "entity");
ExistXmldbEmbeddedServer.storeResource(col, "docname.xml", input.getBytes());
// should throw XMLDBException
ExistXmldbEmbeddedServer.getXMLResource(col, "docname.xml");
} catch (final XMLDBException e) {
assertTrue(e.getMessage().contains("The entity \"empty\" was referenced, but not declared"));
return;
} finally {
if (col != null) {
col.close();
}
}
fail("Should have thrown XMLDBException");
}
use of org.xmldb.api.base.Collection in project exist by eXist-db.
the class CreateCollectionsTest method setUp.
@Before
public void setUp() throws XMLDBException {
// create a test collection
final CollectionManagementService cms = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
final Collection test = cms.createCollection(TEST_COLLECTION);
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
// change ownership to guest
Account guest = ums.getAccount(GUEST_DB_USER);
ums.chown(guest, guest.getPrimaryGroup());
ums.chmod("rwxrwxrwx");
}
use of org.xmldb.api.base.Collection in project exist by eXist-db.
the class CreateCollectionsTest method rootCollectionHasNoParent.
@Test
public void rootCollectionHasNoParent() throws XMLDBException {
final Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, ADMIN_DB_USER, ADMIN_DB_PWD);
assertNull("root collection has no parent", root.getParentCollection());
}
use of org.xmldb.api.base.Collection in project exist by eXist-db.
the class CreateCollectionsTest method storeSamplesShakespeare.
@Test
public void storeSamplesShakespeare() throws XMLDBException, IOException, URISyntaxException {
final Collection colTest = DatabaseManager.getCollection(XmldbURI.LOCAL_DB + "/" + TEST_COLLECTION);
final CollectionManagementService service = (CollectionManagementService) colTest.getService("CollectionManagementService", "1.0");
final Collection testCollection = service.createCollection("test");
UserManagementService ums = (UserManagementService) testCollection.getService("UserManagementService", "1.0");
ums.chmod("rwxr-xr-x");
final List<String> storedResourceNames = new ArrayList<>();
final List<String> filenames = new ArrayList<>();
// store the samples
for (final String sampleName : SAMPLES.getShakespeareXmlSampleNames()) {
final Resource res = storeResourceFromFile(SAMPLES.getShakespeareSample(sampleName), testCollection, sampleName);
storedResourceNames.add(res.getId());
filenames.add(sampleName);
}
assertEquals(filenames, storedResourceNames);
// get a list from the database of stored resource names
final List<String> retrievedStoredResourceNames = Arrays.asList(testCollection.listResources());
// order of names from database may not be the order in which the files were loaded!
Collections.sort(filenames);
Collections.sort(retrievedStoredResourceNames);
assertEquals(filenames, retrievedStoredResourceNames);
}
Aggregations