Search in sources :

Example 76 with XMLResource

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);
    }
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) InputStream(java.io.InputStream) Database(org.xmldb.api.base.Database) IndexQueryService(org.exist.xmldb.IndexQueryService) Collection(org.xmldb.api.base.Collection) XMLResource(org.xmldb.api.modules.XMLResource)

Example 77 with XMLResource

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);
}
Also used : XMLResource(org.xmldb.api.modules.XMLResource) Test(org.junit.Test)

Example 78 with XMLResource

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);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) XMLResource(org.xmldb.api.modules.XMLResource) Before(org.junit.Before)

Example 79 with XMLResource

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;
}
Also used : XMLResource(org.xmldb.api.modules.XMLResource)

Example 80 with XMLResource

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;
}
Also used : XQueryService(org.xmldb.api.modules.XQueryService) XMLResource(org.xmldb.api.modules.XMLResource)

Aggregations

XMLResource (org.xmldb.api.modules.XMLResource)142 Collection (org.xmldb.api.base.Collection)56 ResourceSet (org.xmldb.api.base.ResourceSet)56 XPathQueryService (org.xmldb.api.modules.XPathQueryService)49 Test (org.junit.Test)33 Resource (org.xmldb.api.base.Resource)24 XQueryService (org.xmldb.api.modules.XQueryService)23 Node (org.w3c.dom.Node)22 CollectionManagementService (org.xmldb.api.modules.CollectionManagementService)20 EXistXPathQueryService (org.exist.xmldb.EXistXPathQueryService)18 Document (org.w3c.dom.Document)16 XMLDBException (org.xmldb.api.base.XMLDBException)15 EXistResource (org.exist.xmldb.EXistResource)9 EXistXQueryService (org.exist.xmldb.EXistXQueryService)9 BinaryResource (org.xmldb.api.modules.BinaryResource)9 Path (java.nio.file.Path)8 Before (org.junit.Before)8 Element (org.w3c.dom.Element)8 Source (javax.xml.transform.Source)7 SAXSerializer (org.exist.util.serializer.SAXSerializer)7