From cf1ecc6326f01ed18eab34c6e7bc2eea613dc358 Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Fri, 10 Oct 2014 15:14:53 +0000 Subject: QPID-6143: Throw ConnectionScopedRuntimeException from ReplicatedEnvironmentFacade.openDatabase if facade is not opened or environment is invalid git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1630922 13f79535-47bb-0310-9956-ffa450edef68 --- .../replication/ReplicatedEnvironmentFacadeTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'qpid/java/bdbstore/src/test') diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeTest.java index 69d44bbe88..bef5a87217 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeTest.java @@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.log4j.Logger; import org.apache.qpid.server.store.berkeleydb.EnvironmentFacade; +import org.apache.qpid.server.util.ConnectionScopedRuntimeException; import org.apache.qpid.test.utils.PortHelper; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.test.utils.TestFileUtils; @@ -146,6 +147,24 @@ public class ReplicatedEnvironmentFacadeTest extends QpidTestCase assertNotSame("Expecting a new handle after database closure", handle1, handle3); } + 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()); + } + } + public void testGetGroupName() throws Exception { assertEquals("Unexpected group name", TEST_GROUP_NAME, createMaster().getGroupName()); -- cgit v1.2.1