diff options
| author | Keith Wall <kwall@apache.org> | 2014-08-05 13:33:00 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2014-08-05 13:33:00 +0000 |
| commit | f1de9935453ef75423efe9f04a7d7a2ca8e41837 (patch) | |
| tree | 390882199118673c3fd7d0515970e234ce4e4831 /qpid/java/bdbstore/src/test | |
| parent | 34b9e6385180b17cd6b702a0344239d815c6b7de (diff) | |
| download | qpid-python-f1de9935453ef75423efe9f04a7d7a2ca8e41837.tar.gz | |
QPID-5962: [Java Broker] Prevent two or more BDB virtual host or virtual hosts nodes sharing the same JE environment path
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1615928 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/bdbstore/src/test')
2 files changed, 88 insertions, 0 deletions
diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/EnvHomeRegistryTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/EnvHomeRegistryTest.java new file mode 100644 index 0000000000..5de51df992 --- /dev/null +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/EnvHomeRegistryTest.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.qpid.server.store.berkeleydb; + +import java.io.File; + +import junit.framework.TestCase; + +import org.apache.qpid.test.utils.QpidTestCase; + +public class EnvHomeRegistryTest extends TestCase +{ + + private final EnvHomeRegistry _ehr = new EnvHomeRegistry(); + + public void testDuplicateEnvHomeRejected() throws Exception + { + File home = new File(QpidTestCase.TMP_FOLDER, getName()); + + _ehr.registerHome(home); + try + { + _ehr.registerHome(home); + fail("Exception not thrown"); + } + catch (IllegalArgumentException iae) + { + // PASS + } + } + + public void testUniqueEnvHomesAllowed() throws Exception + { + File home1 = new File(QpidTestCase.TMP_FOLDER, getName() + "1"); + File home2 = new File(QpidTestCase.TMP_FOLDER, getName() + "2"); + + _ehr.registerHome(home1); + _ehr.registerHome(home2); + } + + public void testReuseOfEnvHomesAllowed() throws Exception + { + File home = new File(QpidTestCase.TMP_FOLDER, getName() + "1"); + + _ehr.registerHome(home); + + _ehr.deregisterHome(home); + + _ehr.registerHome(home); + } +}
\ No newline at end of file diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeTest.java index 9521f7d85d..3403ec53dc 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeTest.java @@ -73,6 +73,26 @@ public class StandardEnvironmentFacadeTest extends QpidTestCase assertTrue("Environment is not valid", e.isValid()); } + public void testSecondEnvironmentFacadeUsingSamePathRejected() throws Exception + { + EnvironmentFacade ef = createEnvironmentFacade(); + assertNotNull("Environment should not be null", ef); + try + { + createEnvironmentFacade(); + fail("Exception not thrown"); + } + catch (IllegalArgumentException iae) + { + // PASS + } + + ef.close(); + + EnvironmentFacade ef2 = createEnvironmentFacade(); + assertNotNull("Environment should not be null", ef2); + } + public void testClose() throws Exception { EnvironmentFacade ef = createEnvironmentFacade(); |
