Search in sources :

Example 1 with ReplicaWriteException

use of com.sleepycat.je.rep.ReplicaWriteException in project qpid-broker-j by apache.

the class ReplicatedEnvironmentFacadeTest method testReplicaWriteExceptionIsConvertedIntoConnectionScopedRuntimeException.

@Test
public void testReplicaWriteExceptionIsConvertedIntoConnectionScopedRuntimeException() throws Exception {
    ReplicatedEnvironmentFacade master = createMaster();
    String nodeName2 = TEST_NODE_NAME + "_2";
    String host = "localhost";
    int port = _portHelper.getNextAvailable();
    String node2NodeHostPort = host + ":" + port;
    final ReplicatedEnvironmentFacade replica = createReplica(nodeName2, node2NodeHostPort, new NoopReplicationGroupListener());
    // close the master
    master.close();
    try {
        replica.openDatabase("test", DatabaseConfig.DEFAULT.setAllowCreate(true));
        fail("Replica write operation should fail");
    } catch (ReplicaWriteException e) {
        RuntimeException handledException = master.handleDatabaseException("test", e);
        final boolean condition = handledException instanceof ConnectionScopedRuntimeException;
        assertTrue("Unexpected exception", condition);
    }
}
Also used : ReplicaWriteException(com.sleepycat.je.rep.ReplicaWriteException) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ReplicatedEnvironmentFacade(org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

ReplicaWriteException (com.sleepycat.je.rep.ReplicaWriteException)1 ReplicatedEnvironmentFacade (org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1