use of org.sirix.api.ResourceManager in project sirix by sirixdb.
the class NodeReadTrxImplTest method testEmptyRtx.
@Test
public void testEmptyRtx() throws SirixException {
assertFalse(Files.exists(PATHS.PATH2.getFile()));
Databases.createDatabase(PATHS.PATH2.getConfig());
try (final Database db = Databases.openDatabase(PATHS.PATH2.getFile())) {
db.createResource(new ResourceConfiguration.Builder(TestHelper.RESOURCE, PATHS.PATH2.getConfig()).build());
try (final ResourceManager resMgr = db.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
final XdmNodeReadTrx rtx = resMgr.beginNodeReadTrx()) {
rtx.getRevisionNumber();
}
}
}
use of org.sirix.api.ResourceManager in project sirix by sirixdb.
the class XMLSerializerTest method testXMLSerializer.
@Test
public void testXMLSerializer() throws Exception {
final Database database = TestHelper.getDatabase(PATHS.PATH1.getFile());
final ResourceManager manager = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
final XdmNodeWriteTrx wtx = manager.beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.close();
// Generate from this session.
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final XMLSerializer serializer = new XMLSerializerBuilder(manager, out).emitXMLDeclaration().build();
serializer.call();
assertEquals(DocumentCreater.XML, out.toString());
manager.close();
}
use of org.sirix.api.ResourceManager in project sirix by sirixdb.
the class XMLSerializerTest method testIDSerializer.
@Test
public void testIDSerializer() throws Exception {
final Database database = TestHelper.getDatabase(PATHS.PATH1.getFile());
final ResourceManager manager = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
final XdmNodeWriteTrx wtx = manager.beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.close();
// Generate from this session.
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final XMLSerializer serializer = new XMLSerializerBuilder(manager, out).emitIDs().emitXMLDeclaration().build();
serializer.call();
assertEquals(DocumentCreater.ID, out.toString());
manager.close();
}
use of org.sirix.api.ResourceManager in project sirix by sirixdb.
the class XMLSerializerTest method testRestSerializer.
@Test
public void testRestSerializer() throws Exception {
final Database database = TestHelper.getDatabase(PATHS.PATH1.getFile());
final ResourceManager manager = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
final XdmNodeWriteTrx wtx = manager.beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.close();
// Generate from this session.
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final XMLSerializer serializer = XMLSerializer.newBuilder(manager, out).emitRESTful().emitIDs().emitXMLDeclaration().build();
serializer.call();
assertEquals(DocumentCreater.REST, out.toString());
manager.close();
}
use of org.sirix.api.ResourceManager in project sirix by sirixdb.
the class XdmResourceManagerTest method testSingleton.
@Test
public void testSingleton() {
final Database database = Holder.openResourceManager().getDatabase();
assertEquals(database, holder.getDatabase());
final ResourceManager manager = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
assertEquals(manager, holder.getResourceManager());
manager.close();
final ResourceManager manager2 = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
assertNotSame(manager2, holder.getResourceManager());
database.close();
}
Aggregations