diff options
| author | Alex Rudyy <orudyy@apache.org> | 2014-10-10 15:14:53 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2014-10-10 15:14:53 +0000 |
| commit | cf1ecc6326f01ed18eab34c6e7bc2eea613dc358 (patch) | |
| tree | 65ee8021185c5f405269e4cb145b9998c0c49777 | |
| parent | 8ddbcfd4d3bc786b8cd223697ddd815fb73b78f5 (diff) | |
| download | qpid-python-cf1ecc6326f01ed18eab34c6e7bc2eea613dc358.tar.gz | |
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
2 files changed, 21 insertions, 2 deletions
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java index 532cffdac8..7639582373 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java @@ -452,12 +452,12 @@ public class ReplicatedEnvironmentFacade implements EnvironmentFacade, StateChan } if (_state.get() != State.OPEN) { - throw new IllegalStateException("Environment facade is not in opened state"); + throw new ConnectionScopedRuntimeException("Environment facade is not in opened state"); } if (!_environment.isValid()) { - throw new IllegalStateException("Environment is not valid"); + throw new ConnectionScopedRuntimeException("Environment is not valid"); } Database cachedHandle = _cachedDatabases.get(name); 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()); |
