use of org.sirix.api.Database 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.Database 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.Database 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.Database in project sirix by sirixdb.
the class XdmResourceManagerTest method testNonExisting.
@Test
public void testNonExisting() throws SirixException, InterruptedException {
final Database database = TestHelper.getDatabase(PATHS.PATH1.getFile());
final Database database2 = TestHelper.getDatabase(PATHS.PATH1.getFile());
assertTrue(database == database2);
}
use of org.sirix.api.Database 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