use of org.apache.qpid.server.store.berkeleydb.EnvironmentFacade in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacadeTest method testOpenDatabaseReusesCachedHandle.
public void testOpenDatabaseReusesCachedHandle() throws Exception {
DatabaseConfig createIfAbsentDbConfig = DatabaseConfig.DEFAULT.setAllowCreate(true);
EnvironmentFacade ef = createMaster();
Database handle1 = ef.openDatabase("myDatabase", createIfAbsentDbConfig);
assertNotNull(handle1);
Database handle2 = ef.openDatabase("myDatabase", createIfAbsentDbConfig);
assertSame("Database handle should be cached", handle1, handle2);
ef.closeDatabase("myDatabase");
Database handle3 = ef.openDatabase("myDatabase", createIfAbsentDbConfig);
assertNotSame("Expecting a new handle after database closure", handle1, handle3);
}
use of org.apache.qpid.server.store.berkeleydb.EnvironmentFacade in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacadeTest method testOpenDatabaseWhenFacadeIsNotOpened.
public void testOpenDatabaseWhenFacadeIsNotOpened() throws Exception {
DatabaseConfig createIfAbsentDbConfig = DatabaseConfig.DEFAULT.setAllowCreate(true);
EnvironmentFacade ef = createMaster();
ef.close();
try {
ef.openDatabase("myDatabase", createIfAbsentDbConfig);
fail("Database open should fail");
} catch (ConnectionScopedRuntimeException e) {
assertEquals("Unexpected exception", "Environment facade is not in opened state", e.getMessage());
}
}
Aggregations