diff options
Diffstat (limited to 'java')
5 files changed, 92 insertions, 2 deletions
diff --git a/java/010ExcludeList b/java/010ExcludeList index 3eab025053..94102ce09c 100644 --- a/java/010ExcludeList +++ b/java/010ExcludeList @@ -60,3 +60,7 @@ org.apache.qpid.server.queue.PriorityTest#* org.apache.qpid.server.queue.TimeToLiveTest#* // QPID-1727 , QPID-1726 :c++ broker does not support flow to disk on transient queues. Also it requries a persistent store impl. for Apache org.apache.qpid.test.client.QueueBrowsingFlowToDiskTest#* + +// This test currently does not pick up the runtime location of the nonVm queueBacking store. +org.apache.qpid.test.unit.client.close.FlowToDiskBackingQueueDeleteTest#* + diff --git a/java/08ExcludeList-nonvm b/java/08ExcludeList-nonvm index 546dc01f5b..a529a2fa87 100644 --- a/java/08ExcludeList-nonvm +++ b/java/08ExcludeList-nonvm @@ -28,3 +28,7 @@ org.apache.qpid.server.security.acl.SimpleACLTest#* // Those tests are written against the 0.10 path org.apache.qpid.test.unit.message.UTF8Test#* org.apache.qpid.client.MessageListenerTest#testSynchronousRecieveNoWait + +// This test currently does not pick up the runtime location of the nonVm queueBacking store. +org.apache.qpid.test.unit.client.close.FlowToDiskBackingQueueDeleteTest#* + diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java b/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java index e98a40fc6c..b9d07d032b 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java @@ -345,7 +345,11 @@ public class FileQueueBackingStore implements QueueBackingStore _log.info("Closing Backing store at:" + _flowToDiskLocation); if (!FileUtils.delete(new File(_flowToDiskLocation), true)) { - _log.error("Unable to fully delete backing store location"); + // Attempting a second time appears to ensure that it is deleted. + if (!FileUtils.delete(new File(_flowToDiskLocation), true)) + { + _log.error("Unable to fully delete backing store location"); + } } } diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java b/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java index b53d5a99ee..8981db0071 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java @@ -33,7 +33,7 @@ public class FileQueueBackingStoreFactory implements QueueBackingStoreFactory private static final Logger _log = Logger.getLogger(FileQueueBackingStoreFactory.class); private String _flowToDiskLocation; - private static final String QUEUE_BACKING_DIR = "queueBacking"; + public static final String QUEUE_BACKING_DIR = "queueBacking"; public void configure(VirtualHost virtualHost, VirtualHostConfiguration config) throws ConfigurationException { diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/close/FlowToDiskBackingQueueDeleteTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/close/FlowToDiskBackingQueueDeleteTest.java new file mode 100644 index 0000000000..3403d95f7a --- /dev/null +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/close/FlowToDiskBackingQueueDeleteTest.java @@ -0,0 +1,78 @@ +/* + * + * 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.test.unit.close; + +import org.apache.qpid.client.AMQSession; +import org.apache.qpid.framing.AMQShortString; +import org.apache.qpid.server.queue.AMQQueueFactory; +import org.apache.qpid.server.queue.FileQueueBackingStoreFactory; +import org.apache.qpid.test.utils.QpidTestCase; + +import javax.jms.Connection; +import javax.jms.Session; +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +public class FlowToDiskBackingQueueDeleteTest extends QpidTestCase +{ + + public void test() throws Exception + { + + //Incresae the number of messages to send + + Map<String, Object> arguments = new HashMap<String, Object>(); + + //Ensure we can call createQueue with a priority int value + arguments.put(AMQQueueFactory.QPID_POLICY_TYPE.toString(), AMQQueueFactory.QPID_FLOW_TO_DISK); + // each message in the AckTest is 98 bytes each so only give space for half + arguments.put(AMQQueueFactory.QPID_MAX_SIZE.toString(), 1); + + Connection connection = getConnection(); + //Create the FlowToDisk Queue + AMQSession session = ((AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE)); + + //Make the queue Autodelete and exclusive so we can check it is gone. + session.createQueue(new AMQShortString(getName()), true, false, true, arguments); + + //Check the backing store exists. + String workDir = System.getProperty("QPID_WORK", System.getProperty("java.io.tmpdir")); + + long binDir = FileQueueBackingStoreFactory.hash(getName()) & 0xFFL; + + //This is a little bit of an ugly method to find the backing store location + File backing = new File(workDir + File.separator + + FileQueueBackingStoreFactory.QUEUE_BACKING_DIR + + File.separator + "test" + File.separator + + binDir + File.separator + getName()); + + System.err.println(backing.toString()); + + assertTrue("QueueBacking Store not created.", backing.exists()); + + connection.close(); + + assertFalse("QueueBacking Store not deleted.", backing.exists()); + + } + +} |
