summaryrefslogtreecommitdiff
path: root/java/systests/src/main/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2007-01-12 01:03:21 +0000
committerMartin Ritchie <ritchiem@apache.org>2007-01-12 01:03:21 +0000
commit7d02021e1405afa249b3f9c6427b3a6ea7095d15 (patch)
tree1e06e7776c7a4bb2838ad2495579ad24bc4a503f /java/systests/src/main/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
parent9eef1e1f7ddc4c4ace42c3edbc3fa9db1e509666 (diff)
downloadqpid-python-7d02021e1405afa249b3f9c6427b3a6ea7095d15.tar.gz
QPID-146 QPID-112 QPID-278
Summary Reworked a lot of the distribution work done by the build system. This ended up with me creating a reduced client distribution (hope that is ok Steve) Each module now has has a distribution directory (except common it may need a tests build later) This will build the individual components in to a distribution binary only, binary with tests and source. To build the binary with tests in the distribution directory use profile tests so $mvn -Ptests In all cases the dependencies have been reduced and correctly assigned to the correct scope. There were a couple of cases where a runtime dependency of one of our dependencies didn't make it in to the distributions so they were added explicitly. This should be looked at again. Specifics Broker: Three new assembly files are located in the distribution/src directory (broker-bin taking heavily from distribution - bin) these generate the three distributions. SimpleFilterManager.java removed slf4j reference broker/test directory removed as it was left over from the ant system Client: Added intelij files to ignore list. client/dist deleted as it was left over from the ant system client/distribution as for the broker three assemblies matching the three distributions Renamed log4j.properties to client.log4j to prevent issues when it is packaged into the jar. Removed old_test ping and requestreply1 as they have been moved to perftests Moved broker back to a test dependency. This required modifying AMQSession.java to remove reference to ExchangeBoundHandler.java Common: Added more common dependencies from broker and client here. Distribution: Reduced the assemblies to only build the full project binary, binary with tests and source. Perftests: Added building of perftests distribution so this can be bundled separately. Resources: Moved Resources from distribution project to root level this allows them to be easily incorporated in all projects. Systests: as with perftests now builds a separate distribution that can be used on an existing installation. renamed log4j.properties to systests.log4j to prevent logging problems. As systests is a module having the code under the test folder isn't accurate as it is the main code. Test code here should be testing the tests :D !! git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@495455 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/systests/src/main/java/org/apache/qpid/server/queue/DeliveryManagerTest.java')
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/queue/DeliveryManagerTest.java179
1 files changed, 179 insertions, 0 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/server/queue/DeliveryManagerTest.java b/java/systests/src/main/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
new file mode 100644
index 0000000000..d88614298f
--- /dev/null
+++ b/java/systests/src/main/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
@@ -0,0 +1,179 @@
+/*
+ *
+ * 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.queue;
+
+import org.apache.qpid.server.handler.OnCurrentThreadExecutor;
+import org.apache.qpid.server.store.StoreContext;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+
+import junit.framework.TestSuite;
+
+abstract public class DeliveryManagerTest extends MessageTestHelper
+{
+ protected final SubscriptionSet _subscriptions = new SubscriptionSet();
+ protected DeliveryManager _mgr;
+ protected StoreContext _storeContext = new StoreContext();
+ private static final AMQShortString DEFAULT_QUEUE_NAME = new AMQShortString("Me");
+
+ public DeliveryManagerTest() throws Exception
+ {
+ }
+
+ public void testStartInQueueingMode() throws AMQException
+ {
+ AMQMessage[] messages = new AMQMessage[10];
+ for (int i = 0; i < messages.length; i++)
+ {
+ messages[i] = message();
+ }
+ int batch = messages.length / 2;
+
+ for (int i = 0; i < batch; i++)
+ {
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, messages[i]);
+ }
+
+ SubscriptionTestHelper s1 = new SubscriptionTestHelper("1");
+ SubscriptionTestHelper s2 = new SubscriptionTestHelper("2");
+ _subscriptions.addSubscriber(s1);
+ _subscriptions.addSubscriber(s2);
+
+ for (int i = batch; i < messages.length; i++)
+ {
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, messages[i]);
+ }
+
+ assertTrue(s1.getMessages().isEmpty());
+ assertTrue(s2.getMessages().isEmpty());
+
+ _mgr.processAsync(new OnCurrentThreadExecutor());
+
+ assertEquals(messages.length / 2, s1.getMessages().size());
+ assertEquals(messages.length / 2, s2.getMessages().size());
+
+ for (int i = 0; i < messages.length; i++)
+ {
+ if (i % 2 == 0)
+ {
+ assertTrue(s1.getMessages().get(i / 2) == messages[i]);
+ }
+ else
+ {
+ assertTrue(s2.getMessages().get(i / 2) == messages[i]);
+ }
+ }
+ }
+
+ public void testStartInDirectMode() throws AMQException
+ {
+ AMQMessage[] messages = new AMQMessage[10];
+ for (int i = 0; i < messages.length; i++)
+ {
+ messages[i] = message();
+ }
+ int batch = messages.length / 2;
+
+ SubscriptionTestHelper s1 = new SubscriptionTestHelper("1");
+ _subscriptions.addSubscriber(s1);
+
+ for (int i = 0; i < batch; i++)
+ {
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, messages[i]);
+ }
+
+ assertEquals(batch, s1.getMessages().size());
+ for (int i = 0; i < batch; i++)
+ {
+ assertTrue(messages[i] == s1.getMessages().get(i));
+ }
+ s1.getMessages().clear();
+ assertEquals(0, s1.getMessages().size());
+
+ s1.setSuspended(true);
+ for (int i = batch; i < messages.length; i++)
+ {
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, messages[i]);
+ }
+
+ _mgr.processAsync(new OnCurrentThreadExecutor());
+ assertEquals(0, s1.getMessages().size());
+ s1.setSuspended(false);
+
+ _mgr.processAsync(new OnCurrentThreadExecutor());
+ assertEquals(messages.length - batch, s1.getMessages().size());
+
+ for (int i = batch; i < messages.length; i++)
+ {
+ assertTrue(messages[i] == s1.getMessages().get(i - batch));
+ }
+
+ }
+
+ public void testNoConsumers() throws AMQException
+ {
+ try
+ {
+ AMQMessage msg = message(true);
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, msg);
+ msg.checkDeliveredToConsumer();
+ fail("expected exception did not occur");
+ }
+ catch (NoConsumersException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected NoConsumersException, got " + e);
+ }
+ }
+
+ public void testNoActiveConsumers() throws AMQException
+ {
+ try
+ {
+ SubscriptionTestHelper s = new SubscriptionTestHelper("A");
+ _subscriptions.addSubscriber(s);
+ s.setSuspended(true);
+ AMQMessage msg = message(true);
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, msg);
+ msg.checkDeliveredToConsumer();
+ fail("expected exception did not occur");
+ }
+ catch (NoConsumersException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected NoConsumersException, got " + e);
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(ConcurrentDeliveryManagerTest.class);
+ suite.addTestSuite(SynchronizedDeliveryManagerTest.class);
+ return suite;
+ }
+}