use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.
the class OptimizerTest method initDatabase.
@BeforeClass
public static void initDatabase() throws ClassNotFoundException, IllegalAccessException, InstantiationException, XMLDBException, IOException, URISyntaxException {
// 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(XmldbURI.LOCAL_DB, "admin", "");
CollectionManagementService service = (CollectionManagementService) root.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.XMLResource in project exist by eXist-db.
the class QueryPoolTest method read.
@Test
public void read() throws XMLDBException {
XMLResource res = (XMLResource) testCollection.getResource("large_list.xml");
assertNotNull(res);
}
use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.
the class QueryPoolTest method setUp.
@Before
public void setUp() throws ClassNotFoundException, IllegalAccessException, InstantiationException, XMLDBException {
final CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
testCollection = service.createCollection("test-pool");
assertNotNull(testCollection);
final XMLResource doc = (XMLResource) testCollection.createResource("large_list.xml", "XMLResource");
doc.setContent("<test id='t1'/>");
testCollection.storeResource(doc);
}
use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.
the class SeqOpTest method createDocument.
private XMLResource createDocument(String name, String content) throws XMLDBException {
XMLResource res = (XMLResource) c.createResource(name, XMLResource.RESOURCE_TYPE);
res.setContent(content);
c.storeResource(res);
return res;
}
use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.
the class UnionTest method storeXMLStringAndGetQueryService.
private XQueryService storeXMLStringAndGetQueryService(String documentName, String content) throws XMLDBException {
final XMLResource doc = (XMLResource) testCollection.createResource(documentName, "XMLResource");
doc.setContent(content);
testCollection.storeResource(doc);
final XQueryService service = (XQueryService) testCollection.getService("XPathQueryService", "1.0");
return service;
}
Aggregations