Search in sources :

Example 1 with EnvironmentFacade

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);
}
Also used : Database(com.sleepycat.je.Database) EnvironmentFacade(org.apache.qpid.server.store.berkeleydb.EnvironmentFacade) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 2 with EnvironmentFacade

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());
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) EnvironmentFacade(org.apache.qpid.server.store.berkeleydb.EnvironmentFacade) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Aggregations

DatabaseConfig (com.sleepycat.je.DatabaseConfig)2 EnvironmentFacade (org.apache.qpid.server.store.berkeleydb.EnvironmentFacade)2 Database (com.sleepycat.je.Database)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1