summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/derby-store/src/test
diff options
context:
space:
mode:
authorAlex Rudyy <orudyy@apache.org>2015-04-15 09:47:28 +0000
committerAlex Rudyy <orudyy@apache.org>2015-04-15 09:47:28 +0000
commit0a0baee45ebcff44635907d457c4ff6810b09c87 (patch)
tree8bfb0f9eddbc23cff88af69be80ab3ce7d47011c /qpid/java/broker-plugins/derby-store/src/test
parent54aa3d7070da16ce55c28ccad3f7d0871479e461 (diff)
downloadqpid-python-0a0baee45ebcff44635907d457c4ff6810b09c87.tar.gz
QPID-6481: Move java source tree to top level
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1673693 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/derby-store/src/test')
-rw-r--r--qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java49
-rw-r--r--qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java76
-rw-r--r--qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java96
-rw-r--r--qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeTest.java175
4 files changed, 0 insertions, 396 deletions
diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java
deleted file mode 100644
index 4a71fe2faf..0000000000
--- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *
- * 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.derby;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.apache.qpid.server.model.ConfiguredObjectFactory;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.model.VirtualHostNode;
-import org.apache.qpid.server.store.AbstractDurableConfigurationStoreTestCase;
-import org.apache.qpid.server.virtualhostnode.derby.DerbyVirtualHostNode;
-
-public class DerbyMessageStoreConfigurationTest extends AbstractDurableConfigurationStoreTestCase
-{
-
- @Override
- protected VirtualHostNode createVirtualHostNode(String storeLocation, ConfiguredObjectFactory factory)
- {
- final DerbyVirtualHostNode parent = mock(DerbyVirtualHostNode.class);
- when(parent.getStorePath()).thenReturn(storeLocation);
- return parent;
- }
-
- @Override
- protected DerbyConfigurationStore createConfigStore() throws Exception
- {
- return new DerbyConfigurationStore(VirtualHost.class);
- }
-
-}
diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
deleted file mode 100644
index 0aeb6bd0e8..0000000000
--- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * 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.derby;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MessageStoreQuotaEventsTestBase;
-import org.apache.qpid.server.virtualhost.derby.DerbyVirtualHost;
-
-public class DerbyMessageStoreQuotaEventsTest extends MessageStoreQuotaEventsTestBase
-{
- private static final int NUMBER_OF_MESSAGES_TO_OVERFILL_STORE = 10;
-
- /**
- * Estimated using an assumption that a physical disk space occupied by a
- * message is 3 times bigger then a message size
- */
- private static final long OVERFULL_SIZE = (long) (MESSAGE_DATA.length * 3 * NUMBER_OF_MESSAGES_TO_OVERFILL_STORE * 0.8);
-
- private static final long UNDERFULL_SIZE = (long) (OVERFULL_SIZE * 0.8);
-
- @Override
- protected int getNumberOfMessagesToFillStore()
- {
- return NUMBER_OF_MESSAGES_TO_OVERFILL_STORE;
- }
-
- @Override
- protected VirtualHost createVirtualHost(String storeLocation)
- {
- final DerbyVirtualHost parent = mock(DerbyVirtualHost.class);
- when(parent.getContext()).thenReturn(createContextSettings());
- when(parent.getContextKeys(false)).thenReturn(Collections.emptySet());
- when(parent.getStorePath()).thenReturn(storeLocation);
- when(parent.getStoreOverfullSize()).thenReturn(OVERFULL_SIZE);
- when(parent.getStoreUnderfullSize()).thenReturn(UNDERFULL_SIZE);
- return parent;
- }
-
- @Override
- protected MessageStore createStore() throws Exception
- {
- return new DerbyMessageStore();
- }
-
- private Map<String, String> createContextSettings()
- {
- return Collections.emptyMap();
- }
-
-
-}
diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
deleted file mode 100644
index 0b1847bb59..0000000000
--- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *
- * 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.derby;
-
-
-import java.io.File;
-
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MessageStoreTestCase;
-import org.apache.qpid.server.virtualhost.derby.DerbyVirtualHost;
-import org.apache.qpid.util.FileUtils;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class DerbyMessageStoreTest extends MessageStoreTestCase
-{
- private String _storeLocation;
-
- @Override
- public void tearDown() throws Exception
- {
- try
- {
- deleteStoreIfExists();
- }
- finally
- {
- super.tearDown();
- }
- }
-
- public void testOnDelete() throws Exception
- {
- File location = new File(_storeLocation);
- assertTrue("Store does not exist at " + _storeLocation, location.exists());
-
- getStore().closeMessageStore();
- assertTrue("Store does not exist at " + _storeLocation, location.exists());
-
- DerbyVirtualHost mockVH = mock(DerbyVirtualHost.class);
- when(mockVH.getStorePath()).thenReturn(_storeLocation);
-
- getStore().onDelete(mockVH);
- assertFalse("Store exists at " + _storeLocation, location.exists());
- }
-
- @Override
- protected VirtualHost createVirtualHost()
- {
- _storeLocation = TMP_FOLDER + File.separator + getTestName();
- deleteStoreIfExists();
-
- final DerbyVirtualHost parent = mock(DerbyVirtualHost.class);
- when(parent.getStorePath()).thenReturn(_storeLocation);
- return parent;
- }
-
- private void deleteStoreIfExists()
- {
- if (_storeLocation != null)
- {
- File location = new File(_storeLocation);
- if (location.exists())
- {
- FileUtils.delete(location, true);
- }
- }
- }
-
- @Override
- protected MessageStore createMessageStore()
- {
- return new DerbyMessageStore();
- }
-
-}
diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeTest.java
deleted file mode 100644
index 5afbc7aceb..0000000000
--- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- *
- * 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.virtualhostnode.derby;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.attribute.PosixFileAttributeView;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
-import org.apache.qpid.server.configuration.updater.TaskExecutorImpl;
-import org.apache.qpid.server.logging.EventLogger;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.BrokerModel;
-import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
-import org.apache.qpid.server.model.SystemConfig;
-import org.apache.qpid.server.model.VirtualHostNode;
-import org.apache.qpid.server.model.adapter.BrokerAdapter;
-import org.apache.qpid.test.utils.QpidTestCase;
-import org.apache.qpid.test.utils.TestFileUtils;
-
-public class DerbyVirtualHostNodeTest extends QpidTestCase
-{
- private TaskExecutor _taskExecutor;
- private File _workDir;
- private Broker<BrokerAdapter> _broker;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- _taskExecutor = new TaskExecutorImpl();
- _taskExecutor.start();
- _workDir = TestFileUtils.createTestDirectory("qpid.work_dir", true);
- setTestSystemProperty("qpid.work_dir", _workDir.getAbsolutePath());
- _broker = createBroker();
- }
-
- public void tearDown() throws Exception
- {
- try
- {
- _broker.close();
- }
- finally
- {
- _taskExecutor.stop();
- TestFileUtils.delete(_workDir, true);
- super.tearDown();
- }
- }
-
- public void testCreateAndCloseVirtualHostNode() throws Exception
- {
- String nodeName = getTestName();
- Map<String, Object> nodeData = new HashMap<>();
- nodeData.put(VirtualHostNode.NAME, nodeName);
- nodeData.put(VirtualHostNode.TYPE, DerbyVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE);
-
- VirtualHostNode<?> virtualHostNode = (VirtualHostNode<?>)_broker.createChild(VirtualHostNode.class, nodeData);
- virtualHostNode.start();
- virtualHostNode.close();
- }
-
-
- public void testCreateDuplicateVirtualHostNodeAndClose() throws Exception
- {
-
- String nodeName = getTestName();
- Map<String, Object> nodeData = new HashMap<>();
- nodeData.put(VirtualHostNode.NAME, nodeName);
- nodeData.put(VirtualHostNode.TYPE, DerbyVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE);
-
- VirtualHostNode<?> virtualHostNode = (VirtualHostNode<?>)_broker.createChild(VirtualHostNode.class, nodeData);
- virtualHostNode.start();
-
- try
- {
- _broker.createChild(VirtualHostNode.class, nodeData);
- }
- catch(Exception e)
- {
- assertEquals("Unexpected message", "Child of type " + virtualHostNode.getClass().getSimpleName() + " already exists with name of " + getTestName(), e.getMessage());
- }
- virtualHostNode.close();
- }
-
- public void testOnCreateValidationForFileStorePath() throws Exception
- {
- File file = new File(_workDir, getTestName());
- file.createNewFile();
-
- String nodeName = getTestName();
- Map<String, Object> nodeData = new HashMap<>();
- nodeData.put(VirtualHostNode.NAME, nodeName);
- nodeData.put(VirtualHostNode.TYPE, DerbyVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE);
- nodeData.put(DerbyVirtualHostNodeImpl.STORE_PATH, file.getAbsolutePath());
- try
- {
- _broker.createChild(VirtualHostNode.class, nodeData);
- fail("Cannot create store for the file store path");
- }
- catch(IllegalConfigurationException e)
- {
- // pass
- }
-
- }
-
-
- public void testOnCreateValidationForNonWritableStorePath() throws Exception
- {
- if (Files.getFileStore(_workDir.toPath()).supportsFileAttributeView(PosixFileAttributeView.class))
- {
- File file = new File(_workDir, getTestName());
- file.mkdirs();
- if (file.setWritable(false, false))
- {
- String nodeName = getTestName();
- Map<String, Object> nodeData = new HashMap<>();
- nodeData.put(VirtualHostNode.NAME, nodeName);
- nodeData.put(VirtualHostNode.TYPE, DerbyVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE);
- nodeData.put(DerbyVirtualHostNodeImpl.STORE_PATH, file.getAbsolutePath());
- try
- {
- _broker.createChild(VirtualHostNode.class, nodeData);
- fail("Cannot create store for the non writable store path");
- }
- catch (IllegalConfigurationException e)
- {
- // pass
- }
- }
- }
- }
-
- private BrokerAdapter createBroker()
- {
- Map<String, Object> brokerAttributes = Collections.<String, Object>singletonMap(Broker.NAME, "Broker");
- SystemConfig parent = mock(SystemConfig.class);
- when(parent.getEventLogger()).thenReturn(new EventLogger());
- when(parent.getCategoryClass()).thenReturn(SystemConfig.class);
- when(parent.getTaskExecutor()).thenReturn(_taskExecutor);
- when(parent.getChildExecutor()).thenReturn(_taskExecutor);
- when(parent.getModel()).thenReturn(BrokerModel.getInstance());
- when(parent.getObjectFactory()).thenReturn(new ConfiguredObjectFactoryImpl(BrokerModel.getInstance()));
- BrokerAdapter broker = new BrokerAdapter(brokerAttributes, parent);
- broker.start();
- return broker;
- }
-}