summaryrefslogtreecommitdiff
path: root/java/systests
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2012-05-04 15:39:19 +0000
committerKim van der Riet <kpvdr@apache.org>2012-05-04 15:39:19 +0000
commit633c33f224f3196f3f9bd80bd2e418d8143fea06 (patch)
tree1391da89470593209466df68c0b40b89c14963b1 /java/systests
parentc73f9286ebff93a6c8dbc29cf05e258c4b55c976 (diff)
downloadqpid-python-633c33f224f3196f3f9bd80bd2e418d8143fea06.tar.gz
QPID-3858: Updated branch - merged from trunk r.1333987
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1334037 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/systests')
-rw-r--r--java/systests/build.xml6
-rwxr-xr-xjava/systests/etc/bin/testclients.sh23
-rw-r--r--java/systests/etc/virtualhosts-systests-bdb-settings.xml6
-rw-r--r--java/systests/etc/virtualhosts-systests-derby-settings.xml8
-rw-r--r--java/systests/etc/virtualhosts-systests-firewall-2.xml4
-rw-r--r--java/systests/etc/virtualhosts-systests-firewall-3.xml4
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/AsynchMessageListenerTest.java362
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java233
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerImmediatePrefetch.java44
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java252
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/MessageListenerTest.java258
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/ResetMessageListenerTest.java228
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java7
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/SynchReceiveTest.java133
-rw-r--r--java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java20
-rw-r--r--java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java17
-rw-r--r--java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java256
-rw-r--r--java/systests/src/main/java/org/apache/qpid/ra/QpidRAConnectionTest.java89
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java3
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java300
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java2
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java573
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java186
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java5
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java78
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java100
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java36
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java70
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStoreFactory.java (renamed from java/systests/src/main/java/org/apache/qpid/test/framework/Assertion.java)32
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/client/CancelTest.java101
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java98
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java28
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java2
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/AMQPPublisher.java54
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/AssertionBase.java66
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/BrokerLifecycleAware.java70
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailure.java42
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailureUserPrompt.java63
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/Circuit.java109
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEnd.java95
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEndBase.java156
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/DropInTest.java51
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java204
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java299
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java48
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/LocalAMQPCircuitFactory.java173
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java320
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java167
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java104
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/MessagingTestConfigProperties.java684
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/NotApplicableAssertion.java112
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/Publisher.java74
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/Receiver.java92
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java88
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/TestClientDetails.java86
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java200
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchFailureException.java45
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchThread.java124
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchronizer.java69
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/LocalClockSynchronizer.java73
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockReference.java169
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockSynchronizer.java468
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedCircuitImpl.java472
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedPublisherImpl.java94
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedReceiverImpl.java94
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/TestClientCircuitEnd.java333
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/Coordinator.java546
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/DistributedTestDecorator.java164
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/FanOutTestDecorator.java241
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropTestDecorator.java210
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/OptOutTestCase.java69
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java510
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClientControlledTest.java107
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/listeners/XMLTestListener.java414
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalAMQPPublisherImpl.java137
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java313
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalPublisherImpl.java176
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalReceiverImpl.java149
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/package.html43
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/BaseCircuitFactory.java136
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java101
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java200
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java154
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java18
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java43
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/basic/ReceiveTest.java82
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java17
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/close/CloseBeforeAckTest.java140
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java77
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java19
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java2
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java35
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java2
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java6
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java72
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java10
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java52
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java2
98 files changed, 1534 insertions, 11575 deletions
diff --git a/java/systests/build.xml b/java/systests/build.xml
index fb2bae1d47..6adce705cd 100644
--- a/java/systests/build.xml
+++ b/java/systests/build.xml
@@ -7,9 +7,9 @@ nn - or more contributor license agreements. See the NOTICE 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
@@ -27,7 +27,7 @@ nn - or more contributor license agreements. See the NOTICE file
</and>
</condition>
- <property name="module.depends" value="client management/common broker broker/test common common/test junit-toolkit ${systests.optional.depends}"/>
+ <property name="module.depends" value="client management/common broker broker/test common amqp-1-0-common common/test jca ${systests.optional.depends}"/>
<property name="module.test.src" location="src/main/java"/>
<property name="module.test.excludes"
value="**/DropInTest.java,**/TestClientControlledTest.java"/>
diff --git a/java/systests/etc/bin/testclients.sh b/java/systests/etc/bin/testclients.sh
deleted file mode 100755
index 002f3d98bb..0000000000
--- a/java/systests/etc/bin/testclients.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-for x in `seq 1 $1`;
-do
- java -cp qpid-integrationtests-1.0-incubating-M2-SNAPSHOT-all-test-deps.jar -Dlog4j.configuration=file:/home/rupert/qpid/trunk/qpid/java/etc/mylog4j.xml org.apache.qpid.test.framework.distributedtesting.TestClient -n java$x &
-done
diff --git a/java/systests/etc/virtualhosts-systests-bdb-settings.xml b/java/systests/etc/virtualhosts-systests-bdb-settings.xml
index ce16523f13..216046b40b 100644
--- a/java/systests/etc/virtualhosts-systests-bdb-settings.xml
+++ b/java/systests/etc/virtualhosts-systests-bdb-settings.xml
@@ -26,7 +26,7 @@
<name>localhost</name>
<localhost>
<store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.berkeleydb.BDBMessageStoreFactory</factoryclass>
<environment-path>${work}/bdbstore/localhost-store</environment-path>
</store>
</localhost>
@@ -36,7 +36,7 @@
<name>development</name>
<development>
<store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.berkeleydb.BDBMessageStoreFactory</factoryclass>
<environment-path>${work}/bdbstore/development-store</environment-path>
</store>
</development>
@@ -46,7 +46,7 @@
<name>test</name>
<test>
<store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.berkeleydb.BDBMessageStoreFactory</factoryclass>
<environment-path>${work}/bdbstore/test-store</environment-path>
</store>
</test>
diff --git a/java/systests/etc/virtualhosts-systests-derby-settings.xml b/java/systests/etc/virtualhosts-systests-derby-settings.xml
index ed5ffbb1fd..d494768e91 100644
--- a/java/systests/etc/virtualhosts-systests-derby-settings.xml
+++ b/java/systests/etc/virtualhosts-systests-derby-settings.xml
@@ -26,7 +26,7 @@
<virtualhost>
<localhost>
<store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.derby.DerbyMessageStoreFactory</factoryclass>
<environment-path>${QPID_WORK}/derbyDB/localhost-store</environment-path>
</store>
</localhost>
@@ -35,8 +35,8 @@
<virtualhost>
<development>
<store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
- <environment-path>${QPID_WORK}/derbyDB/development-store</environment-path>
+ <factoryclass>org.apache.qpid.server.store.derby.DerbyMessageStoreFactory</factoryclass>
+ <environment-path>${QPID_WORK}/derbyDB/development-store</environment-path>
</store>
</development>
</virtualhost>
@@ -44,7 +44,7 @@
<virtualhost>
<test>
<store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.derby.DerbyMessageStoreFactory</factoryclass>
<environment-path>${QPID_WORK}/derbyDB/test-store</environment-path>
</store>
</test>
diff --git a/java/systests/etc/virtualhosts-systests-firewall-2.xml b/java/systests/etc/virtualhosts-systests-firewall-2.xml
index 20908e6eb4..f8e9fde8ca 100644
--- a/java/systests/etc/virtualhosts-systests-firewall-2.xml
+++ b/java/systests/etc/virtualhosts-systests-firewall-2.xml
@@ -26,7 +26,7 @@
<name>test</name>
<test>
<store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.MemoryMessageStoreFactory</factoryclass>
</store>
</test>
</virtualhost>
@@ -35,7 +35,7 @@
<name>test2</name>
<test2>
<store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.MemoryMessageStoreFactory</factoryclass>
</store>
<security>
<firewall default-action="deny">
diff --git a/java/systests/etc/virtualhosts-systests-firewall-3.xml b/java/systests/etc/virtualhosts-systests-firewall-3.xml
index 90377f345f..95db02672a 100644
--- a/java/systests/etc/virtualhosts-systests-firewall-3.xml
+++ b/java/systests/etc/virtualhosts-systests-firewall-3.xml
@@ -26,7 +26,7 @@
<name>test</name>
<test>
<store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.MemoryMessageStoreFactory</factoryclass>
</store>
</test>
</virtualhost>
@@ -35,7 +35,7 @@
<name>test2</name>
<test2>
<store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ <factoryclass>org.apache.qpid.server.store.MemoryMessageStoreFactory</factoryclass>
</store>
<security>
<firewall default-action="deny"/>
diff --git a/java/systests/src/main/java/org/apache/qpid/client/AsynchMessageListenerTest.java b/java/systests/src/main/java/org/apache/qpid/client/AsynchMessageListenerTest.java
new file mode 100644
index 0000000000..09402c140d
--- /dev/null
+++ b/java/systests/src/main/java/org/apache/qpid/client/AsynchMessageListenerTest.java
@@ -0,0 +1,362 @@
+/*
+ * 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.client;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jms.Connection;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.util.LogMonitor;
+
+/**
+ * Tests the behaviour of JMS asynchronous message listeners as provided by
+ * {@link MessageListener#onMessage(Message)}.
+ *
+ */
+public class AsynchMessageListenerTest extends QpidBrokerTestCase
+{
+ private static final int MSG_COUNT = 10;
+ private static final long AWAIT_MESSAGE_TIMEOUT = 2000;
+ private static final long AWAIT_MESSAGE_TIMEOUT_NEGATIVE = 250;
+ private final String _testQueueName = getTestQueueName();
+ private Connection _consumerConnection;
+ private Session _consumerSession;
+ private MessageConsumer _consumer;
+ private Queue _queue;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ _consumerConnection = getConnection();
+ _consumerConnection.start();
+ _consumerSession = _consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _queue = _consumerSession.createQueue(_testQueueName);
+ _consumer = _consumerSession.createConsumer(_queue);
+
+ // Populate queue
+ Connection producerConnection = getConnection();
+ Session producerSession = producerConnection.createSession(true, Session.SESSION_TRANSACTED);
+ sendMessage(producerSession, _queue, MSG_COUNT);
+ producerConnection.close();
+
+ }
+
+ public void testMessageListener() throws Exception
+ {
+ CountingMessageListener countingMessageListener = new CountingMessageListener(MSG_COUNT);
+ _consumer.setMessageListener(countingMessageListener);
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ assertEquals("Unexpected number of outstanding messages", 0, countingMessageListener.getOutstandingCount());
+ }
+
+ public void testSynchronousReceiveFollowedByMessageListener() throws Exception
+ {
+ // Receive initial message synchronously
+ assertNotNull("Could not receive first message synchronously", _consumer.receive(AWAIT_MESSAGE_TIMEOUT) != null);
+ final int numberOfMessagesToReceiveByMessageListener = MSG_COUNT - 1;
+
+ // Consume remainder asynchronously
+ CountingMessageListener countingMessageListener = new CountingMessageListener(numberOfMessagesToReceiveByMessageListener);
+ _consumer.setMessageListener(countingMessageListener);
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ assertEquals("Unexpected number of outstanding messages", 0, countingMessageListener.getOutstandingCount());
+ }
+
+ public void testMessageListenerSetDisallowsSynchronousReceive() throws Exception
+ {
+ CountingMessageListener countingMessageListener = new CountingMessageListener(MSG_COUNT);
+ _consumer.setMessageListener(countingMessageListener);
+
+ try
+ {
+ _consumer.receive();
+ fail("Exception not thrown");
+ }
+ catch (JMSException e)
+ {
+ // PASS
+ assertEquals("A listener has already been set.", e.getMessage());
+ }
+ }
+
+
+ public void testConnectionStopThenStart() throws Exception
+ {
+ int messageToReceivedBeforeConnectionStop = 2;
+ CountingMessageListener countingMessageListener = new CountingMessageListener(MSG_COUNT, messageToReceivedBeforeConnectionStop);
+
+ // Consume at least two messages
+ _consumer.setMessageListener(countingMessageListener);
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ _consumerConnection.stop();
+
+ assertTrue("Too few messages received afer Connection#stop()", countingMessageListener.getReceivedCount() >= messageToReceivedBeforeConnectionStop);
+ countingMessageListener.resetLatch();
+
+ // Restart connection
+ _consumerConnection.start();
+
+ // Consume the remainder
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ assertEquals("Unexpected number of outstanding messages", 0, countingMessageListener.getOutstandingCount());
+ }
+
+ public void testConnectionStopAndMessageListenerChange() throws Exception
+ {
+ int messageToReceivedBeforeConnectionStop = 2;
+ CountingMessageListener countingMessageListener1 = new CountingMessageListener(MSG_COUNT, messageToReceivedBeforeConnectionStop);
+
+ // Consume remainder asynchronously
+ _consumer.setMessageListener(countingMessageListener1);
+ countingMessageListener1.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ _consumerConnection.stop();
+ assertTrue("Too few messages received afer Connection#stop()", countingMessageListener1.getReceivedCount() >= messageToReceivedBeforeConnectionStop);
+
+ CountingMessageListener countingMessageListener2 = new CountingMessageListener(countingMessageListener1.getOutstandingCount());
+
+ // Reset Message Listener
+ _consumer.setMessageListener(countingMessageListener2);
+
+ _consumerConnection.start();
+
+ // Consume the remainder
+ countingMessageListener2.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ assertEquals("Unexpected number of outstanding messages", 0, countingMessageListener2.getOutstandingCount());
+
+ }
+
+ public void testConnectionStopHaltsDeliveryToListener() throws Exception
+ {
+ int messageToReceivedBeforeConnectionStop = 2;
+ CountingMessageListener countingMessageListener = new CountingMessageListener(MSG_COUNT, messageToReceivedBeforeConnectionStop);
+
+ // Consume at least two messages
+ _consumer.setMessageListener(countingMessageListener);
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ _consumerConnection.stop();
+
+ // Connection should now be stopped and listener should receive no more
+ final int outstandingCountAtStop = countingMessageListener.getOutstandingCount();
+ countingMessageListener.resetLatch();
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT_NEGATIVE);
+
+ assertEquals("Unexpected number of outstanding messages", outstandingCountAtStop, countingMessageListener.getOutstandingCount());
+ }
+
+ public void testSessionCloseHaltsDelivery() throws Exception
+ {
+ int messageToReceivedBeforeConnectionStop = 2;
+ CountingMessageListener countingMessageListener = new CountingMessageListener(MSG_COUNT, messageToReceivedBeforeConnectionStop);
+
+ // Consume at least two messages
+ _consumer.setMessageListener(countingMessageListener);
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ _consumerSession.close();
+
+ // Once a session is closed, the listener should receive no more
+ final int outstandingCountAtClose = countingMessageListener.getOutstandingCount();
+ countingMessageListener.resetLatch();
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT_NEGATIVE);
+
+ assertEquals("Unexpected number of outstanding messages", outstandingCountAtClose, countingMessageListener.getOutstandingCount());
+ }
+
+ public void testImmediatePrefetchWithMessageListener() throws Exception
+ {
+ // Close connection provided by setup so we can set IMMEDIATE_PREFETCH
+ _consumerConnection.close();
+ setTestClientSystemProperty(AMQSession.IMMEDIATE_PREFETCH, "true");
+
+ _consumerConnection = getConnection();
+ _consumerConnection.start();
+ _consumerSession = _consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _consumer = _consumerSession.createConsumer(_queue);
+ CountingMessageListener countingMessageListener = new CountingMessageListener(MSG_COUNT);
+ _consumer.setMessageListener(countingMessageListener);
+
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+
+ assertEquals("Unexpected number of messages received", MSG_COUNT, countingMessageListener.getReceivedCount());
+ }
+
+ public void testReceiveTwoConsumers() throws Exception
+ {
+ Session consumerSession2 = _consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer _consumer2 = consumerSession2.createConsumer(_queue);
+
+ CountingMessageListener countingMessageListener = new CountingMessageListener(MSG_COUNT);
+ _consumer.setMessageListener(countingMessageListener);
+ _consumer2.setMessageListener(countingMessageListener);
+
+ countingMessageListener.awaitMessages(AWAIT_MESSAGE_TIMEOUT);
+ assertEquals("Unexpected number of messages received", MSG_COUNT, countingMessageListener.getReceivedCount());
+ }
+
+ /**
+ * Tests the case where the message listener throws an java.lang.Error.
+ * TODO - a useful test?.
+ */
+ public void testMessageListenerThrowsError() throws Exception
+ {
+ int expectedMessages = 1; // The error will kill the dispatcher so only one message will be delivered.
+ final CountDownLatch awaitMessages = new CountDownLatch(expectedMessages);
+ final AtomicInteger receivedCount = new AtomicInteger(0);
+ final String javaLangErrorMessageText = "MessageListener failed with java.lang.Error";
+ CountingExceptionListener countingExceptionListener = new CountingExceptionListener();
+ _consumerConnection.setExceptionListener(countingExceptionListener);
+
+ _consumer.setMessageListener(new MessageListener()
+ {
+ @Override
+ public void onMessage(Message message)
+ {
+ try
+ {
+ throw new Error(javaLangErrorMessageText);
+ }
+ finally
+ {
+ receivedCount.incrementAndGet();
+ awaitMessages.countDown();
+ }
+ }
+ });
+
+ awaitMessages.await(AWAIT_MESSAGE_TIMEOUT, TimeUnit.MILLISECONDS);
+
+ assertEquals("Unexpected number of messages received", expectedMessages, receivedCount.get());
+ assertEquals("onException should NOT have been called", 0, countingExceptionListener.getErrorCount());
+
+ // Check that Error has been written to the application log.
+
+ LogMonitor _monitor = new LogMonitor(_outputFile);
+ assertTrue("The expected message not written to log file.",
+ _monitor.waitForMessage(javaLangErrorMessageText, LOGMONITOR_TIMEOUT));
+
+ if (_consumerConnection != null)
+ {
+ try
+ {
+ _consumerConnection.close();
+ }
+ catch (JMSException e)
+ {
+ // Ignore connection close errors for this test.
+ }
+ finally
+ {
+ _consumerConnection = null;
+ }
+ }
+ }
+
+ private final class CountingExceptionListener implements ExceptionListener
+ {
+ private final AtomicInteger _errorCount = new AtomicInteger();
+
+ @Override
+ public void onException(JMSException arg0)
+ {
+ _errorCount.incrementAndGet();
+ }
+
+ public int getErrorCount()
+ {
+ return _errorCount.intValue();
+ }
+ }
+
+ private final class CountingMessageListener implements MessageListener
+ {
+ private volatile CountDownLatch _awaitMessages;
+ private final AtomicInteger _receivedCount;
+ private final AtomicInteger _outstandingMessageCount;
+
+ public CountingMessageListener(final int totalExpectedMessageCount)
+ {
+ this(totalExpectedMessageCount, totalExpectedMessageCount);
+ }
+
+
+ public CountingMessageListener(int totalExpectedMessageCount, int numberOfMessagesToAwait)
+ {
+ _receivedCount = new AtomicInteger(0);
+ _outstandingMessageCount = new AtomicInteger(totalExpectedMessageCount);
+ _awaitMessages = new CountDownLatch(numberOfMessagesToAwait);
+ }
+
+ public int getOutstandingCount()
+ {
+ return _outstandingMessageCount.get();
+ }
+
+ public int getReceivedCount()
+ {
+ return _receivedCount.get();
+ }
+
+ public void resetLatch()
+ {
+ _awaitMessages = new CountDownLatch(_outstandingMessageCount.get());
+ }
+
+ @Override
+ public void onMessage(Message message)
+ {
+ _receivedCount.incrementAndGet();
+ _outstandingMessageCount.decrementAndGet();
+ _awaitMessages.countDown();
+ }
+
+ public boolean awaitMessages(long timeout)
+ {
+ try
+ {
+ return _awaitMessages.await(timeout, TimeUnit.MILLISECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ }
+ }
+
+}
diff --git a/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java b/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
deleted file mode 100644
index 3537dd0533..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
+++ /dev/null
@@ -1,233 +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.client;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.Context;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery queue
- * <p/>
- * The message delivery process:
- * Mina puts a message on _queue in AMQSession and the dispatcher thread take()s
- * from here and dispatches to the _consumers. If the _consumer doesn't have a message listener set at connection start
- * then messages are stored on _synchronousQueue (which needs to be > 1 to pass JMS TCK as multiple consumers on a
- * session can run in any order and a synchronous put/poll will block the dispatcher).
- * <p/>
- * When setting the message listener later the _synchronousQueue is just poll()'ed and the first message delivered
- * the remaining messages will be left on the queue and lost, subsequent messages on the session will arrive first.
- */
-public class DispatcherTest extends QpidBrokerTestCase
-{
- private static final Logger _logger = LoggerFactory.getLogger(DispatcherTest.class);
-
- private Context _context;
-
- private static final int MSG_COUNT = 6;
- private int _receivedCount = 0;
- private int _receivedCountWhileStopped = 0;
- private Connection _clientConnection, _producerConnection;
- private MessageConsumer _consumer;
- private MessageProducer _producer;
- private Session _clientSession, _producerSession;
-
- private final CountDownLatch _allFirstMessagesSent = new CountDownLatch(1); // all messages Sent Lock
- private final CountDownLatch _allSecondMessagesSent = new CountDownLatch(1); // all messages Sent Lock
-
- private volatile boolean _connectionStopped = false;
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // Create Client 1
- _clientConnection = getConnection();
-
- _clientSession = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue queue = _clientSession.createQueue(this.getClass().getName());
- _consumer = _clientSession.createConsumer(queue);
-
- // Create Producer
- _producerConnection = getConnection();
-
- _producerConnection.start();
-
- _producerSession = _producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- _producer = _producerSession.createProducer(queue);
-
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- _producer.send(_producerSession.createTextMessage("Message " + msg));
- }
- }
-
- protected void tearDown() throws Exception
- {
-
- _clientConnection.close();
-
- _producerConnection.close();
- super.tearDown();
- }
-
- public void testAsynchronousRecieve()
- {
- _logger.info("Test Start");
-
- assertTrue(!((AMQConnection) _clientConnection).started());
-
- // Set default Message Listener
- try
- {
- _consumer.setMessageListener(new MessageListener()
- {
- public void onMessage(Message message)
- {
- _logger.info("Client 1 ML 1 Received Message(" + _receivedCount + "):" + message);
-
- _receivedCount++;
-
- if (_receivedCount == MSG_COUNT)
- {
- _allFirstMessagesSent.countDown();
- }
-
- if (_connectionStopped)
- {
- _logger.info("Running with Message:" + _receivedCount);
- }
-
- if (_connectionStopped && (_allFirstMessagesSent.getCount() == 0))
- {
- _receivedCountWhileStopped++;
- }
-
- if (_allFirstMessagesSent.getCount() == 0)
- {
- if (_receivedCount == (MSG_COUNT * 2))
- {
- _allSecondMessagesSent.countDown();
- }
- }
- }
- });
-
- assertTrue("Connecion should not be started", !((AMQConnection) _clientConnection).started());
- _clientConnection.start();
- }
- catch (JMSException e)
- {
- _logger.error("Error Setting Default ML on consumer1");
- }
-
- try
- {
- _allFirstMessagesSent.await(1000, TimeUnit.MILLISECONDS);
- }
- catch (InterruptedException e)
- {
- // do nothing
- }
-
- try
- {
- assertTrue("Connecion should be started", ((AMQConnection) _clientConnection).started());
- _clientConnection.stop();
- _connectionStopped = true;
- }
- catch (JMSException e)
- {
- _logger.error("Error stopping connection");
- }
-
- try
- {
- _logger.error("Send additional messages");
-
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- _producer.send(_producerSession.createTextMessage("Message " + msg));
- }
- }
- catch (JMSException e)
- {
- _logger.error("Unable to send additional messages", e);
- }
-
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException e)
- {
- // ignore
- }
-
- try
- {
- _logger.info("Restarting connection");
-
- _connectionStopped = false;
- _clientConnection.start();
- }
- catch (JMSException e)
- {
- _logger.error("Error Setting Better ML on consumer1", e);
- }
-
- _logger.info("Waiting upto 2 seconds for messages");
-
- try
- {
- _allSecondMessagesSent.await(1000, TimeUnit.MILLISECONDS);
- }
- catch (InterruptedException e)
- {
- // do nothing
- }
-
- assertEquals("Messages not received correctly", 0, _allFirstMessagesSent.getCount());
- assertEquals("Messages not received correctly", 0, _allSecondMessagesSent.getCount());
- assertEquals("Client didn't get all messages", MSG_COUNT * 2, _receivedCount);
- assertEquals("Messages received while stopped is not 0", 0, _receivedCountWhileStopped);
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(DispatcherTest.class);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerImmediatePrefetch.java b/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerImmediatePrefetch.java
deleted file mode 100644
index 7461f6c200..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerImmediatePrefetch.java
+++ /dev/null
@@ -1,44 +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.client;
-
-/**
- * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
- * queue <p/> The message delivery process: Mina puts a message on _queue in AMQSession and the dispatcher thread
- * take()s from here and dispatches to the _consumers. If the _consumer1 doesn't have a message listener set at
- * connection start then messages are stored on _synchronousQueue (which needs to be > 1 to pass JMS TCK as multiple
- * consumers on a session can run in any order and a synchronous put/poll will block the dispatcher). <p/> When setting
- * the message listener later the _synchronousQueue is just poll()'ed and the first message delivered the remaining
- * messages will be left on the queue and lost, subsequent messages on the session will arrive first.
- */
-public class MessageListenerMultiConsumerImmediatePrefetch extends MessageListenerMultiConsumerTest
-{
- protected void setUp() throws Exception
- {
- System.setProperty(AMQSession.IMMEDIATE_PREFETCH, "true");
- super.setUp();
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(MessageListenerMultiConsumerImmediatePrefetch.class);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java b/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java
deleted file mode 100644
index 4fd10a0134..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java
+++ /dev/null
@@ -1,252 +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.client;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.Context;
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
- * queue <p/> The message delivery process: Mina puts a message on _queue in AMQSession and the dispatcher thread
- * take()s from here and dispatches to the _consumers. If the _consumer1 doesn't have a message listener set at
- * connection start then messages are stored on _synchronousQueue (which needs to be > 1 to pass JMS TCK as multiple
- * consumers on a session can run in any order and a synchronous put/poll will block the dispatcher). <p/> When setting
- * the message listener later the _synchronousQueue is just poll()'ed and the first message delivered the remaining
- * messages will be left on the queue and lost, subsequent messages on the session will arrive first.
- */
-public class MessageListenerMultiConsumerTest extends QpidBrokerTestCase
-{
- private static final Logger _logger = LoggerFactory.getLogger(MessageListenerMultiConsumerTest.class);
-
- private Context _context;
-
- private static final int MSG_COUNT = 6;
- private int receivedCount1 = 0;
- private int receivedCount2 = 0;
- private Connection _clientConnection;
- private MessageConsumer _consumer1;
- private MessageConsumer _consumer2;
- private Session _clientSession1;
- private Queue _queue;
- private final CountDownLatch _allMessagesSent = new CountDownLatch(2); // all messages Sent Lock
- private static final String QUEUE_NAME = "queue" + UUID.randomUUID().toString();
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // Create Client 1
- _clientConnection = getConnection("guest", "guest");
-
- _clientConnection.start();
-
- _clientSession1 = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- _queue =_clientSession1.createQueue(QUEUE_NAME);
-
- _consumer1 = _clientSession1.createConsumer(_queue);
-
- // Create Client 2
- Session clientSession2 = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- _consumer2 = clientSession2.createConsumer(_queue);
-
- // Create Producer
- Connection producerConnection = getConnection("guest", "guest");
-
- producerConnection.start();
-
- Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer producer = producerSession.createProducer(_queue);
-
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- producer.send(producerSession.createTextMessage("Message " + msg));
- }
-
- producerConnection.close();
-
- }
-
- protected void tearDown() throws Exception
- {
- _clientConnection.close();
- super.tearDown();
- }
-
- public void testRecieveInterleaved() throws Exception
- {
- int msg = 0;
- int MAX_LOOPS = MSG_COUNT * 2;
- for (int loops = 0; (msg < MSG_COUNT) || (loops < MAX_LOOPS); loops++)
- {
-
- if (_consumer1.receive(1000) != null)
- {
- msg++;
- }
-
- if (_consumer2.receive(1000) != null)
- {
- msg++;
- }
- }
-
- assertEquals("Not all messages received.", MSG_COUNT, msg);
- }
-
- public void testAsynchronousRecieve() throws Exception
- {
- _consumer1.setMessageListener(new MessageListener()
- {
- public void onMessage(Message message)
- {
- _logger.info("Client 1 Received Message(" + receivedCount1 + "):" + message);
-
- receivedCount1++;
-
- if (receivedCount1 == (MSG_COUNT / 2))
- {
- _allMessagesSent.countDown();
- }
-
- }
- });
-
- _consumer2.setMessageListener(new MessageListener()
- {
- public void onMessage(Message message)
- {
- _logger.info("Client 2 Received Message(" + receivedCount2 + "):" + message);
-
- receivedCount2++;
- if (receivedCount2 == (MSG_COUNT / 2))
- {
- _allMessagesSent.countDown();
- }
- }
- });
-
- _logger.info("Waiting upto 2 seconds for messages");
-
- try
- {
- _allMessagesSent.await(4000, TimeUnit.MILLISECONDS);
- }
- catch (InterruptedException e)
- {
- // do nothing
- }
-
- assertEquals(MSG_COUNT, receivedCount1 + receivedCount2);
- }
-
- public void testRecieveC2Only() throws Exception
- {
- if (
- !Boolean.parseBoolean(
- System.getProperties().getProperty(AMQSession.IMMEDIATE_PREFETCH,
- AMQSession.IMMEDIATE_PREFETCH_DEFAULT)))
- {
- _logger.info("Performing Receive only on C2");
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- assertTrue(MSG_COUNT + " msg should be received. Only received:" + msg, _consumer2.receive(1000) != null);
- }
- }
- }
-
- public void testRecieveBoth() throws Exception
- {
- if (
- !Boolean.parseBoolean(
- System.getProperties().getProperty(AMQSession.IMMEDIATE_PREFETCH,
- AMQSession.IMMEDIATE_PREFETCH_DEFAULT)))
- {
- _logger.info("Performing Receive only with two consumers on one session ");
-
- //Create a new consumer on session one that we don't use
- _clientSession1.createConsumer(_queue);
-
- int msg;
- for (msg = 0; msg < (MSG_COUNT / 2); msg++)
- {
-
- // Attempt to receive up to half the messages
- // The other half may have gone to the consumer above
- final Message message = _consumer1.receive(1000);
- if(message == null)
- {
- break;
- }
-
- }
-
- _consumer1.close();
- // This will close the unused consumer above.
- _clientSession1.close();
-
-
- // msg will now have recorded the number received on session 1
- // attempt to retrieve the rest on session 2
- for (; msg < MSG_COUNT ; msg++)
- {
- assertTrue("Failed at msg id" + msg, _consumer2.receive(1000) != null);
- }
-
- }
- else
- {
- _logger.info("Performing Receive only on both C1 and C2");
-
- for (int msg = 0; msg < (MSG_COUNT / 2); msg++)
- {
-
- assertTrue(_consumer1.receive(3000) != null);
- }
-
- for (int msg = 0; msg < (MSG_COUNT / 2); msg++)
- {
- assertTrue(_consumer2.receive(3000) != null);
- }
- }
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(MessageListenerMultiConsumerTest.class);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/client/MessageListenerTest.java b/java/systests/src/main/java/org/apache/qpid/client/MessageListenerTest.java
deleted file mode 100644
index 142f301bd0..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/client/MessageListenerTest.java
+++ /dev/null
@@ -1,258 +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.client;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.util.LogMonitor;
-
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.Context;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
- * queue <p/> The message delivery process: Mina puts a message on _queue in AMQSession and the dispatcher thread
- * take()s from here and dispatches to the _consumers. If the _consumer doesn't have a message listener set at
- * connection start then messages are stored on _synchronousQueue (which needs to be > 1 to pass JMS TCK as multiple
- * consumers on a session can run in any order and a synchronous put/poll will block the dispatcher). <p/> When setting
- * the message listener later the _synchronousQueue is just poll()'ed and the first message delivered the remaining
- * messages will be left on the queue and lost, subsequent messages on the session will arrive first.
- */
-public class MessageListenerTest extends QpidBrokerTestCase implements MessageListener, ExceptionListener
-{
- private static final Logger _logger = LoggerFactory.getLogger(MessageListenerTest.class);
-
- private Context _context;
-
- private static final int MSG_COUNT = 5;
- private int _receivedCount = 0;
- private int _errorCount = 0;
- private MessageConsumer _consumer;
- private Connection _clientConnection;
- private CountDownLatch _awaitMessages = new CountDownLatch(MSG_COUNT);
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // Create Client
- _clientConnection = getConnection("guest", "guest");
-
- _clientConnection.start();
-
- Session clientSession = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue queue =clientSession.createQueue("message-listener-test-queue");
-
- _consumer = clientSession.createConsumer(queue);
-
- // Create Producer
-
- Connection producerConnection = getConnection("guest", "guest");
-
- producerConnection.start();
-
- Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer producer = producerSession.createProducer(queue);
-
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- producer.send(producerSession.createTextMessage("Message " + msg));
- }
-
- producerConnection.close();
-
- }
-
- protected void tearDown() throws Exception
- {
- if (_clientConnection != null)
- {
- _clientConnection.close();
- }
- super.tearDown();
- }
-
- public void testSynchronousReceive() throws Exception
- {
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- assertTrue(_consumer.receive(2000) != null);
- }
- }
-
- public void testSynchronousReceiveNoWait() throws Exception
- {
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- assertTrue("Failed to receive message " + msg, _consumer.receiveNoWait() != null);
- }
- }
-
- public void testAsynchronousReceive() throws Exception
- {
- _consumer.setMessageListener(this);
-
- _logger.info("Waiting 3 seconds for messages");
-
- try
- {
- _awaitMessages.await(3000, TimeUnit.MILLISECONDS);
- }
- catch (InterruptedException e)
- {
- // do nothing
- }
- // Should have received all async messages
- assertEquals(MSG_COUNT, _receivedCount);
-
- }
-
- public void testReceiveThenUseMessageListener() throws Exception
- {
- _logger.error("Test disabled as initial receive is not called first");
- // Perform initial receive to start connection
- assertTrue(_consumer.receive(2000) != null);
- _receivedCount++;
-
- // Sleep to ensure remaining 4 msgs end up on _synchronousQueue
- Thread.sleep(1000);
-
- // Set the message listener and wait for the messages to come in.
- _consumer.setMessageListener(this);
-
- _logger.info("Waiting 3 seconds for messages");
-
- try
- {
- _awaitMessages.await(3000, TimeUnit.MILLISECONDS);
- }
- catch (InterruptedException e)
- {
- // do nothing
- }
- // Should have received all async messages
- assertEquals(MSG_COUNT, _receivedCount);
-
- _clientConnection.close();
-
- Connection conn = getConnection("guest", "guest");
- Session clientSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = clientSession.createQueue("message-listener-test-queue");
- MessageConsumer cons = clientSession.createConsumer(queue);
- conn.start();
-
- // check that the messages were actually dequeued
- assertTrue(cons.receive(2000) == null);
- }
-
- /**
- * Tests the case where the message listener throws an java.lang.Error.
- *
- */
- public void testMessageListenerThrowsError() throws Exception
- {
- final String javaLangErrorMessageText = "MessageListener failed with java.lang.Error";
- _clientConnection.setExceptionListener(this);
-
- _awaitMessages = new CountDownLatch(1);
-
- _consumer.setMessageListener(new MessageListener()
- {
- public void onMessage(Message message)
- {
- try
- {
- _logger.debug("onMessage called");
- _receivedCount++;
-
-
- throw new Error(javaLangErrorMessageText);
- }
- finally
- {
- _awaitMessages.countDown();
- }
- }
- });
-
-
- _logger.info("Waiting 3 seconds for message");
- _awaitMessages.await(3000, TimeUnit.MILLISECONDS);
-
- assertEquals("onMessage should have been called", 1, _receivedCount);
- assertEquals("onException should NOT have been called", 0, _errorCount);
-
- // Check that Error has been written to the application log.
-
- LogMonitor _monitor = new LogMonitor(_outputFile);
- assertTrue("The expected message not written to log file.",
- _monitor.waitForMessage(javaLangErrorMessageText, LOGMONITOR_TIMEOUT));
-
- if (_clientConnection != null)
- {
- try
- {
- _clientConnection.close();
- }
- catch (JMSException e)
- {
- // Ignore connection close errors for this test.
- }
- finally
- {
- _clientConnection = null;
- }
- }
- }
-
- public void onMessage(Message message)
- {
- _logger.info("Received Message(" + _receivedCount + "):" + message);
-
- _receivedCount++;
- _awaitMessages.countDown();
- }
-
- public void onException(JMSException e)
- {
- _logger.info("Exception received", e);
- _errorCount++;
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(MessageListenerTest.class);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/client/ResetMessageListenerTest.java b/java/systests/src/main/java/org/apache/qpid/client/ResetMessageListenerTest.java
deleted file mode 100644
index 6ff6681c47..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/client/ResetMessageListenerTest.java
+++ /dev/null
@@ -1,228 +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.client;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
- * queue <p/> The message delivery process: Mina puts a message on _queue in AMQSession and the dispatcher thread
- * take()s from here and dispatches to the _consumers. If the _consumer1 doesn't have a message listener set at
- * connection start then messages are stored on _synchronousQueue (which needs to be > 1 to pass JMS TCK as multiple
- * consumers on a session can run in any order and a synchronous put/poll will block the dispatcher). <p/> When setting
- * the message listener later the _synchronousQueue is just poll()'ed and the first message delivered the remaining
- * messages will be left on the queue and lost, subsequent messages on the session will arrive first.
- */
-public class ResetMessageListenerTest extends QpidBrokerTestCase
-{
- private static final Logger _logger = LoggerFactory.getLogger(ResetMessageListenerTest.class);
-
- private Context _context;
-
- private static final int MSG_COUNT = 6;
- private Connection _clientConnection, _producerConnection;
- private MessageConsumer _consumer1;
- private MessageProducer _producer;
- private Session _clientSession, _producerSession;
-
- private final CountDownLatch _allFirstMessagesSent = new CountDownLatch(MSG_COUNT); // all messages Sent Lock
- private final CountDownLatch _allSecondMessagesSent = new CountDownLatch(MSG_COUNT); // all messages Sent Lock
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- _clientConnection = getConnection("guest", "guest");
- _clientConnection.start();
- // Create Client 1
-
- _clientSession = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue queue = _clientSession.createQueue("reset-message-listener-test-queue");
-
- _consumer1 = _clientSession.createConsumer(queue);
-
- // Create Producer
- _producerConnection = getConnection("guest", "guest");
-
- _producerConnection.start();
-
- _producerSession = _producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- _producer = _producerSession.createProducer(queue);
-
- TextMessage m = _producerSession.createTextMessage();
- m.setStringProperty("rank", "first");
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- m.setText("Message " + msg);
- _producer.send(m);
- }
- }
-
- protected void tearDown() throws Exception
- {
- _clientConnection.close();
-
- super.tearDown();
- }
-
- public void testAsynchronousRecieve()
- {
-
- _logger.info("Test Start");
-
- try
- {
- _consumer1.setMessageListener(new MessageListener()
- {
- public void onMessage(Message message)
- {
- try
- {
- if (message.getStringProperty("rank").equals("first"))
- {
- _allFirstMessagesSent.countDown();
- }
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- fail("error receiving message");
- }
- }
- });
- }
- catch (JMSException e)
- {
- _logger.error("Error Setting Default ML on consumer1");
- }
- try
- {
- assertTrue("Did not receive all first batch of messages",
- _allFirstMessagesSent.await(MSG_COUNT, TimeUnit.SECONDS));
- _logger.info("Received first batch of messages");
- }
- catch (InterruptedException e)
- {
- // do nothing
- }
-
- try
- {
- _clientConnection.stop();
- }
- catch (JMSException e)
- {
- _logger.error("Error stopping connection");
- }
-
- _logger.info("Reset Message Listener ");
- try
- {
- _consumer1.setMessageListener(new MessageListener()
- {
- public void onMessage(Message message)
- {
- try
- {
- if (message.getStringProperty("rank").equals("first"))
- {
- // Something ugly will happen, it'll probably kill the dispatcher
- fail("All first set of messages should have been received");
- }
- else
- {
- _allSecondMessagesSent.countDown();
- }
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- // Something ugly will happen, it'll probably kill the dispatcher
- fail("error receiving message");
- }
- }
- });
-
- _clientConnection.start();
- }
- catch (javax.jms.IllegalStateException e)
- {
- _logger.error("Connection not stopped while setting ML", e);
- fail("Unable to change message listener:" + e.getCause());
- }
- catch (JMSException e)
- {
- _logger.error("Error Setting Better ML on consumer1", e);
- }
-
- try
- {
- _logger.info("Send additional messages");
- TextMessage m = _producerSession.createTextMessage();
- m.setStringProperty("rank", "second");
- for (int msg = 0; msg < MSG_COUNT; msg++)
- {
- m.setText("Message " + msg);
- _producer.send(m);
- }
- }
- catch (JMSException e)
- {
- _logger.error("Unable to send additional messages", e);
- }
-
- _logger.info("Waiting for messages");
-
- try
- {
- assertTrue(_allSecondMessagesSent.await(MSG_COUNT, TimeUnit.SECONDS));
- }
- catch (InterruptedException e)
- {
- // do nothing
- }
- assertEquals("First batch of messages not received correctly", 0, _allFirstMessagesSent.getCount());
- assertEquals("Second batch of messages not received correctly", 0, _allSecondMessagesSent.getCount());
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(ResetMessageListenerTest.class);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java b/java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java
index d7295b298e..08ed2258b2 100644
--- a/java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java
@@ -27,7 +27,6 @@ import org.apache.qpid.test.utils.QpidBrokerTestCase;
import javax.jms.Connection;
import javax.jms.Session;
-import javax.naming.Context;
/**
@@ -35,9 +34,7 @@ import javax.naming.Context;
*/
public class SessionCreateTest extends QpidBrokerTestCase
{
- private static final Logger _logger = LoggerFactory.getLogger(MessageListenerTest.class);
-
- private Context _context;
+ private static final Logger LOGGER = LoggerFactory.getLogger(SessionCreateTest.class);
private Connection _clientConnection;
protected int maxSessions = 65555;
@@ -54,7 +51,7 @@ public class SessionCreateTest extends QpidBrokerTestCase
Session sess = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
assertNotNull(sess);
sess.close();
- System.out.println("created session: " + i);
+ LOGGER.debug("created session: " + i);
}
_clientConnection.close();
diff --git a/java/systests/src/main/java/org/apache/qpid/client/SynchReceiveTest.java b/java/systests/src/main/java/org/apache/qpid/client/SynchReceiveTest.java
new file mode 100644
index 0000000000..bf147197e4
--- /dev/null
+++ b/java/systests/src/main/java/org/apache/qpid/client/SynchReceiveTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.client;
+
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+public class SynchReceiveTest extends QpidBrokerTestCase
+{
+ private static final long AWAIT_MESSAGE_TIMEOUT = 2000;
+ private static final long AWAIT_MESSAGE_TIMEOUT_NEGATIVE = 250;
+ private static final int MSG_COUNT = 10;
+ private final String _testQueueName = getTestQueueName();
+ private Connection _consumerConnection;
+ private Session _consumerSession;
+ private MessageConsumer _consumer;
+ private Queue _queue;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ _consumerConnection = getConnection();
+ _consumerConnection.start();
+ _consumerSession = _consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _queue = _consumerSession.createQueue(_testQueueName);
+ _consumer = _consumerSession.createConsumer(_queue);
+
+ // Populate queue
+ Connection producerConnection = getConnection();
+ Session producerSession = producerConnection.createSession(true, Session.SESSION_TRANSACTED);
+ sendMessage(producerSession, _queue, MSG_COUNT);
+ producerConnection.close();
+ }
+
+ public void testReceiveWithTimeout() throws Exception
+ {
+ for (int msg = 0; msg < MSG_COUNT; msg++)
+ {
+ assertNotNull("Expected message number " + msg, _consumer.receive(AWAIT_MESSAGE_TIMEOUT));
+ }
+
+ assertNull("Received too many messages", _consumer.receive(500));
+ }
+
+ public void testReceiveNoWait() throws Exception
+ {
+ for (int msg = 0; msg < MSG_COUNT; msg++)
+ {
+ assertNotNull("Expected message number " + msg, _consumer.receiveNoWait());
+ }
+
+ assertNull("Received too many messages", _consumer.receive(500));
+ }
+
+ public void testTwoConsumersInterleaved() throws Exception
+ {
+ //create a new connection with prefetch set to 1
+ _consumerConnection.close();
+ setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, new Integer(1).toString());
+
+ _consumerConnection = getConnection();
+ _consumerConnection.start();
+ Session consumerSession1 = _consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer1 = consumerSession1.createConsumer(_queue);
+
+ Session consumerSession2 = _consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer2 = consumerSession2.createConsumer(_queue);
+
+ final int maxLoops = MSG_COUNT * 2;
+ int msg = 0;
+ int loops = 0;
+ while(msg < MSG_COUNT && loops < maxLoops)
+ {
+ if (consumer1.receive(AWAIT_MESSAGE_TIMEOUT) != null)
+ {
+ msg++;
+ }
+
+ if (consumer2.receive(AWAIT_MESSAGE_TIMEOUT) != null)
+ {
+ msg++;
+ }
+
+ loops++;
+ }
+
+ assertEquals("Not all messages received.", MSG_COUNT, msg);
+ assertNull("Received too many messages", consumer1.receive(AWAIT_MESSAGE_TIMEOUT_NEGATIVE));
+ assertNull("Received too many messages", consumer2.receive(AWAIT_MESSAGE_TIMEOUT_NEGATIVE));
+ }
+
+ public void testIdleSecondConsumer() throws Exception
+ {
+ Session idleSession = _consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ @SuppressWarnings("unused")
+ MessageConsumer idleConsumerOnSameQueue = idleSession.createConsumer(_queue);
+
+ // Since we don't call receive on the idle consumer, all messages will flow to other
+
+ for (int msg = 0; msg < MSG_COUNT; msg++)
+ {
+ assertNotNull("Expected message number " + msg, _consumer.receive(AWAIT_MESSAGE_TIMEOUT));
+ }
+
+ assertNull("Received too many messages", _consumer.receive(AWAIT_MESSAGE_TIMEOUT_NEGATIVE));
+ }
+
+
+}
diff --git a/java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java b/java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java
index cd74691035..0f12c8c7e6 100644
--- a/java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java
@@ -1,3 +1,23 @@
+/*
+ *
+ * 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.client.redelivered;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
diff --git a/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java b/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java
index f337908134..ac29b72620 100644
--- a/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java
@@ -43,7 +43,7 @@ public class XAResourceTest extends QpidBrokerTestCase
public void testIsSameRMSingleCF() throws Exception
{
XAConnectionFactory factory = getConnectionFactory(FACTORY_NAME);
- XAConnection conn = factory.createXAConnection();
+ XAConnection conn = factory.createXAConnection("guest","guest");
XASession session = conn.createXASession();
XAResource xaResource1 = session.getXAResource();
XAResource xaResource2 = session.getXAResource();
@@ -68,9 +68,9 @@ public class XAResourceTest extends QpidBrokerTestCase
XAConnectionFactory factory2 = new AMQConnectionFactory(url);
XAConnectionFactory factory3 = getConnectionFactory(ALT_FACTORY_NAME);
- XAConnection conn = factory.createXAConnection();
- XAConnection conn2 = factory2.createXAConnection();
- XAConnection conn3 = factory3.createXAConnection();
+ XAConnection conn = factory.createXAConnection("guest","guest");
+ XAConnection conn2 = factory2.createXAConnection("guest","guest");
+ XAConnection conn3 = factory3.createXAConnection("guest","guest");
XASession session = conn.createXASession();
XASession session2 = conn2.createXASession();
@@ -90,15 +90,6 @@ public class XAResourceTest extends QpidBrokerTestCase
}
@Override
- public void stopBroker(int port) throws Exception
- {
- if (isBrokerPresent(port))
- {
- super.stopBroker(port);
- }
- }
-
- @Override
public void tearDown() throws Exception
{
try
diff --git a/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java b/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java
index 0604955290..244e547e02 100644
--- a/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java
@@ -20,6 +20,9 @@ package org.apache.qpid.management.jmx;
import org.apache.commons.lang.time.FastDateFormat;
+import org.apache.log4j.Logger;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.configuration.ClientProperties;
import org.apache.qpid.management.common.mbeans.ManagedQueue;
import org.apache.qpid.server.queue.AMQQueueMBean;
import org.apache.qpid.test.utils.JMXTestUtils;
@@ -27,15 +30,25 @@ import org.apache.qpid.test.utils.QpidBrokerTestCase;
import javax.jms.Connection;
import javax.jms.Destination;
+import javax.jms.JMSException;
import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
import javax.jms.Session;
-import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
+
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests the JMX API for the Managed Queue.
@@ -43,17 +56,41 @@ import java.util.Map;
*/
public class ManagedQueueMBeanTest extends QpidBrokerTestCase
{
- /**
- * JMX helper.
- */
+ protected static final Logger LOGGER = Logger.getLogger(ManagedQueueMBeanTest.class);
+
private JMXTestUtils _jmxUtils;
+ private Connection _connection;
+ private Session _session;
+
+ private String _sourceQueueName;
+ private String _destinationQueueName;
+ private Destination _sourceQueue;
+ private Destination _destinationQueue;
+ private ManagedQueue _managedSourceQueue;
+ private ManagedQueue _managedDestinationQueue;
public void setUp() throws Exception
{
_jmxUtils = new JMXTestUtils(this);
_jmxUtils.setUp();
+
super.setUp();
+ _sourceQueueName = getTestQueueName() + "_src";
+ _destinationQueueName = getTestQueueName() + "_dest";
+
+ _connection = getConnection();
+ _connection.start();
+
+ _session = _connection.createSession(true, Session.SESSION_TRANSACTED);
+ _sourceQueue = _session.createQueue(_sourceQueueName);
+ _destinationQueue = _session.createQueue(_destinationQueueName);
+ createQueueOnBroker(_sourceQueue);
+ createQueueOnBroker(_destinationQueue);
+
_jmxUtils.open();
+
+ _managedSourceQueue = _jmxUtils.getManagedQueue(_sourceQueueName);
+ _managedDestinationQueue = _jmxUtils.getManagedQueue(_destinationQueueName);
}
public void tearDown() throws Exception
@@ -70,28 +107,18 @@ public class ManagedQueueMBeanTest extends QpidBrokerTestCase
*/
public void testViewSingleMessage() throws Exception
{
- final String queueName = getTestQueueName();
-
- // Create queue and send numMessages messages to it.
- final Connection con = getConnection();
- final Session session = con.createSession(true, Session.SESSION_TRANSACTED);
- final Destination dest = session.createQueue(queueName);
- session.createConsumer(dest).close(); // Create a consumer only to cause queue creation
-
- final List<Message> sentMessages = sendMessage(session, dest, 1);
+ final List<Message> sentMessages = sendMessage(_session, _sourceQueue, 1);
+ syncSession(_session);
final Message sentMessage = sentMessages.get(0);
- // Obtain the management interface.
- final ManagedQueue managedQueue = _jmxUtils.getManagedQueue(queueName);
- assertNotNull("ManagedQueue expected to be available", managedQueue);
- assertEquals("Unexpected queue depth", 1, managedQueue.getMessageCount().intValue());
+ assertEquals("Unexpected queue depth", 1, _managedSourceQueue.getMessageCount().intValue());
// Check the contents of the message
- final TabularData tab = managedQueue.viewMessages(1l, 1l);
+ final TabularData tab = _managedSourceQueue.viewMessages(1l, 1l);
assertEquals("Unexpected number of rows in table", 1, tab.size());
- final Iterator<CompositeDataSupport> rowItr = (Iterator<CompositeDataSupport>) tab.values().iterator();
+ final Iterator<CompositeData> rowItr = (Iterator<CompositeData>) tab.values().iterator();
- final CompositeDataSupport row1 = rowItr.next();
+ final CompositeData row1 = rowItr.next();
assertNotNull("Message should have AMQ message id", row1.get(ManagedQueue.MSG_AMQ_ID));
assertEquals("Unexpected queue position", 1l, row1.get(ManagedQueue.MSG_QUEUE_POS));
assertEquals("Unexpected redelivered flag", Boolean.FALSE, row1.get(ManagedQueue.MSG_REDELIVERED));
@@ -109,6 +136,184 @@ public class ManagedQueueMBeanTest extends QpidBrokerTestCase
}
/**
+ * Tests {@link ManagedQueue#moveMessages(long, long, String)} interface.
+ */
+ public void testMoveMessagesBetweenQueues() throws Exception
+ {
+ final int numberOfMessagesToSend = 10;
+
+ sendMessage(_session, _sourceQueue, numberOfMessagesToSend);
+ syncSession(_session);
+ assertEquals("Unexpected queue depth after send", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+ List<Long> amqMessagesIds = getAMQMessageIdsOn(_managedSourceQueue, 1, numberOfMessagesToSend);
+
+ // Move first three messages to destination
+ long fromMessageId = amqMessagesIds.get(0);
+ long toMessageId = amqMessagesIds.get(2);
+ _managedSourceQueue.moveMessages(fromMessageId, toMessageId, _destinationQueueName);
+
+ assertEquals("Unexpected queue depth on destination queue after first move", 3, _managedDestinationQueue.getMessageCount().intValue());
+ assertEquals("Unexpected queue depth on source queue after first move", 7, _managedSourceQueue.getMessageCount().intValue());
+
+ // Now move a further two messages to destination
+ fromMessageId = amqMessagesIds.get(7);
+ toMessageId = amqMessagesIds.get(8);
+ _managedSourceQueue.moveMessages(fromMessageId, toMessageId, _destinationQueueName);
+ assertEquals("Unexpected queue depth on destination queue after second move", 5, _managedDestinationQueue.getMessageCount().intValue());
+ assertEquals("Unexpected queue depth on source queue after second move", 5, _managedSourceQueue.getMessageCount().intValue());
+
+ assertMessageIndicesOn(_destinationQueue, 0, 1, 2, 7, 8);
+ }
+
+ /**
+ * Tests {@link ManagedQueue#copyMessages(long, long, String)} interface.
+ */
+ public void testCopyMessagesBetweenQueues() throws Exception
+ {
+ final int numberOfMessagesToSend = 10;
+ sendMessage(_session, _sourceQueue, numberOfMessagesToSend);
+ syncSession(_session);
+ assertEquals("Unexpected queue depth after send", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+ List<Long> amqMessagesIds = getAMQMessageIdsOn(_managedSourceQueue, 1, numberOfMessagesToSend);
+
+ // Copy first three messages to destination
+ long fromMessageId = amqMessagesIds.get(0);
+ long toMessageId = amqMessagesIds.get(2);
+ _managedSourceQueue.copyMessages(fromMessageId, toMessageId, _destinationQueueName);
+
+ assertEquals("Unexpected queue depth on destination queue after first copy", 3, _managedDestinationQueue.getMessageCount().intValue());
+ assertEquals("Unexpected queue depth on source queue after first copy", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+ // Now copy a further two messages to destination
+ fromMessageId = amqMessagesIds.get(7);
+ toMessageId = amqMessagesIds.get(8);
+ _managedSourceQueue.copyMessages(fromMessageId, toMessageId, _destinationQueueName);
+ assertEquals("Unexpected queue depth on destination queue after second copy", 5, _managedDestinationQueue.getMessageCount().intValue());
+ assertEquals("Unexpected queue depth on source queue after second copy", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+ assertMessageIndicesOn(_destinationQueue, 0, 1, 2, 7, 8);
+ }
+
+ public void testMoveMessagesBetweenQueuesWithActiveConsumerOnSourceQueue() throws Exception
+ {
+ setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, new Integer(1).toString());
+ Connection asyncConnection = getConnection();
+ asyncConnection.start();
+
+ final int numberOfMessagesToSend = 50;
+ sendMessage(_session, _sourceQueue, numberOfMessagesToSend);
+ syncSession(_session);
+ assertEquals("Unexpected queue depth after send", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+ List<Long> amqMessagesIds = getAMQMessageIdsOn(_managedSourceQueue, 1, numberOfMessagesToSend);
+
+ long fromMessageId = amqMessagesIds.get(0);
+ long toMessageId = amqMessagesIds.get(numberOfMessagesToSend - 1);
+
+ CountDownLatch consumerReadToHalfwayLatch = new CountDownLatch(numberOfMessagesToSend / 2);
+ AtomicInteger totalConsumed = new AtomicInteger(0);
+ startAsyncConsumerOn(_sourceQueue, asyncConnection, consumerReadToHalfwayLatch, totalConsumed);
+
+ boolean halfwayPointReached = consumerReadToHalfwayLatch.await(5000, TimeUnit.MILLISECONDS);
+ assertTrue("Did not read half of messages within time allowed", halfwayPointReached);
+
+ _managedSourceQueue.moveMessages(fromMessageId, toMessageId, _destinationQueueName);
+
+ asyncConnection.stop();
+
+ // The exact number of messages moved will be non deterministic, as the number of messages processed
+ // by the consumer cannot be predicited. There is also the possibility that a message can remain
+ // on the source queue. This situation will arise if a message has been acquired by the consumer, but not
+ // yet delivered to the client application (i.e. MessageListener#onMessage()) when the Connection#stop() occurs.
+ //
+ // The number of messages moved + the number consumed + any messages remaining on source should
+ // *always* be equal to the number we originally sent.
+
+ int numberOfMessagesReadByConsumer = totalConsumed.intValue();
+ int numberOfMessagesOnDestinationQueue = _managedDestinationQueue.getMessageCount().intValue();
+ int numberOfMessagesRemainingOnSourceQueue = _managedSourceQueue.getMessageCount().intValue();
+
+ LOGGER.debug("Async consumer read : " + numberOfMessagesReadByConsumer
+ + " Number of messages moved to destination : " + numberOfMessagesOnDestinationQueue
+ + " Number of messages remaining on source : " + numberOfMessagesRemainingOnSourceQueue);
+ assertEquals("Unexpected number of messages after move", numberOfMessagesToSend, numberOfMessagesReadByConsumer + numberOfMessagesOnDestinationQueue + numberOfMessagesRemainingOnSourceQueue);
+ }
+
+ public void testMoveMessagesBetweenQueuesWithActiveConsumerOnDestinationQueue() throws Exception
+ {
+ setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, new Integer(1).toString());
+ Connection asyncConnection = getConnection();
+ asyncConnection.start();
+
+ final int numberOfMessagesToSend = 50;
+ sendMessage(_session, _sourceQueue, numberOfMessagesToSend);
+ syncSession(_session);
+ assertEquals("Unexpected queue depth after send", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+ List<Long> amqMessagesIds = getAMQMessageIdsOn(_managedSourceQueue, 1, numberOfMessagesToSend);
+ long fromMessageId = amqMessagesIds.get(0);
+ long toMessageId = amqMessagesIds.get(numberOfMessagesToSend - 1);
+
+ AtomicInteger totalConsumed = new AtomicInteger(0);
+ CountDownLatch allMessagesConsumedLatch = new CountDownLatch(numberOfMessagesToSend);
+ startAsyncConsumerOn(_destinationQueue, asyncConnection, allMessagesConsumedLatch, totalConsumed);
+
+ _managedSourceQueue.moveMessages(fromMessageId, toMessageId, _destinationQueueName);
+
+ allMessagesConsumedLatch.await(5000, TimeUnit.MILLISECONDS);
+ assertEquals("Did not consume all messages from destination queue", numberOfMessagesToSend, totalConsumed.intValue());
+ }
+
+ private void startAsyncConsumerOn(Destination queue, Connection asyncConnection,
+ final CountDownLatch requiredNumberOfMessagesRead, final AtomicInteger totalConsumed) throws Exception
+ {
+ Session session = asyncConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer = session.createConsumer(queue);
+ consumer.setMessageListener(new MessageListener()
+ {
+
+ @Override
+ public void onMessage(Message arg0)
+ {
+ totalConsumed.incrementAndGet();
+ requiredNumberOfMessagesRead.countDown();
+ }
+ });
+ }
+
+ private void assertMessageIndicesOn(Destination queue, int... expectedIndices) throws Exception
+ {
+ MessageConsumer consumer = _session.createConsumer(queue);
+
+ for (int i : expectedIndices)
+ {
+ Message message = consumer.receive(1000);
+ assertNotNull("Expected message with index " + i, message);
+ assertEquals("Expected message with index " + i, i, message.getIntProperty(INDEX));
+ }
+
+ assertNull("Unexpected message encountered", consumer.receive(1000));
+ }
+
+ private List<Long> getAMQMessageIdsOn(ManagedQueue managedQueue, long startIndex, long endIndex) throws Exception
+ {
+ final SortedSet<Long> messageIds = new TreeSet<Long>();
+
+ final TabularData tab = managedQueue.viewMessages(startIndex, endIndex);
+ final Iterator<CompositeData> rowItr = (Iterator<CompositeData>) tab.values().iterator();
+ while(rowItr.hasNext())
+ {
+ final CompositeData row = rowItr.next();
+ long amqMessageId = (Long)row.get(ManagedQueue.MSG_AMQ_ID);
+ messageIds.add(amqMessageId);
+ }
+
+ return new ArrayList<Long>(messageIds);
+ }
+
+ /**
*
* Utility method to convert array of Strings in the form x = y into a
* map with key/value x =&gt; y.
@@ -126,4 +331,15 @@ public class ManagedQueueMBeanTest extends QpidBrokerTestCase
}
return headerMap;
}
+
+ private void createQueueOnBroker(Destination destination) throws JMSException
+ {
+ _session.createConsumer(destination).close(); // Create a consumer only to cause queue creation
+ }
+
+ private void syncSession(Session session) throws Exception
+ {
+ ((AMQSession<?,?>)session).sync();
+ }
+
}
diff --git a/java/systests/src/main/java/org/apache/qpid/ra/QpidRAConnectionTest.java b/java/systests/src/main/java/org/apache/qpid/ra/QpidRAConnectionTest.java
new file mode 100644
index 0000000000..0ca90ac2ea
--- /dev/null
+++ b/java/systests/src/main/java/org/apache/qpid/ra/QpidRAConnectionTest.java
@@ -0,0 +1,89 @@
+/*
+ *
+ * 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.ra;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.Session;
+
+import org.apache.qpid.ra.QpidRAConnectionFactoryImpl;
+import org.apache.qpid.ra.QpidRAManagedConnectionFactory;
+import org.apache.qpid.ra.QpidResourceAdapter;
+
+public class QpidRAConnectionTest extends QpidBrokerTestCase
+{
+ private static final String BROKER_PORT = "15672";
+
+ private static final String URL = "amqp://guest:guest@client/test?brokerlist='tcp://localhost:" + BROKER_PORT + "?sasl_mechs='PLAIN''";
+
+ public void testSessionCommitOnClosedConnectionThrowsException() throws Exception
+ {
+ QpidResourceAdapter ra = new QpidResourceAdapter();
+ QpidRAManagedConnectionFactory mcf = new QpidRAManagedConnectionFactory();
+ mcf.setConnectionURL(URL);
+ mcf.setResourceAdapter(ra);
+ ConnectionFactory cf = new QpidRAConnectionFactoryImpl(mcf, null);
+ Connection c = cf.createConnection();
+ Session s = c.createSession(true, Session.SESSION_TRANSACTED);
+ c.close();
+
+ try
+ {
+ s.commit();
+ fail("Exception should be thrown");
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ assertTrue(e instanceof javax.jms.IllegalStateException);
+ }
+
+ }
+
+ public void testMessageAck() throws Exception
+ {
+ QpidResourceAdapter ra = new QpidResourceAdapter();
+ QpidRAManagedConnectionFactory mcf = new QpidRAManagedConnectionFactory();
+ mcf.setConnectionURL(URL);
+ mcf.setResourceAdapter(ra);
+ ConnectionFactory cf = new QpidRAConnectionFactoryImpl(mcf, null);
+ Connection c = cf.createConnection();
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Message m = s.createTextMessage();
+
+ try
+ {
+ m.acknowledge();
+ }
+ catch(Exception e)
+ {
+ fail("Acknowledge should not throw an exception");
+ }
+ finally
+ {
+ s.close();
+ c.close();
+ }
+ }
+}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java b/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java
index c42bb3b1fa..0e3a658e32 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java
@@ -77,6 +77,7 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase
public void testDisabling010() throws Exception
{
//disable 0-10 support
+ setConfigurationProperty("connector.amqp10enabled", "false");
setConfigurationProperty("connector.amqp010enabled", "false");
super.setUp();
@@ -92,6 +93,7 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase
public void testDisabling091and010() throws Exception
{
//disable 0-91 and 0-10 support
+ setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP10ENABLED, "false");
setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false");
setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP091ENABLED, "false");
@@ -111,6 +113,7 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase
setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP09ENABLED, "false");
setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP091ENABLED, "false");
setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false");
+ setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP10ENABLED, "false");
super.setUp();
diff --git a/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java b/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java
deleted file mode 100644
index 4a92f04b30..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java
+++ /dev/null
@@ -1,300 +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.exchange;
-
-import org.apache.qpid.jms.Session;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-/**
- * MessagingTestConfigProperties defines a set of property names and default values for specifying a messaging topology,
- * and test parameters for running a messaging test over that topology. A Properties object holding some of these
- * properties, superimposed onto the defaults, is used to establish test topologies and control test behaviour.
- *
- * <p/>A complete list of the parameters, default values and comments on their usage is provided here:
- *
- * <p/><table><caption>Parameters</caption>
- * <tr><th> Parameter <th> Default <th> Comments
- * <tr><td> messageSize <td> 0 <td> Message size in bytes. Not including any headers.
- * <tr><td> destinationName <td> ping <td> The root name to use to generate destination names to ping.
- * <tr><td> persistent <td> false <td> Determines whether peristent delivery is used.
- * <tr><td> transacted <td> false <td> Determines whether messages are sent/received in transactions.
- * <tr><td> broker <td> tcp://localhost:5672 <td> Determines the broker to connect to.
- * <tr><td> virtualHost <td> test <td> Determines the virtual host to send all ping over.
- * <tr><td> rate <td> 0 <td> The maximum rate (in hertz) to send messages at. 0 means no limit.
- * <tr><td> verbose <td> false <td> The verbose flag for debugging. Prints to console on every message.
- * <tr><td> pubsub <td> false <td> Whether to ping topics or queues. Uses p2p by default.
- * <tr><td> username <td> guest <td> The username to access the broker with.
- * <tr><td> password <td> guest <td> The password to access the broker with.
- * <tr><td> selector <td> null <td> Not used. Defines a message selector to filter pings with.
- * <tr><td> destinationCount <td> 1 <td> The number of receivers listening to the pings.
- * <tr><td> timeout <td> 30000 <td> In milliseconds. The timeout to stop waiting for replies.
- * <tr><td> commitBatchSize <td> 1 <td> The number of messages per transaction in transactional mode.
- * <tr><td> uniqueDests <td> true <td> Whether each receiver only listens to one ping destination or all.
- * <tr><td> durableDests <td> false <td> Whether or not durable destinations are used.
- * <tr><td> ackMode <td> AUTO_ACK <td> The message acknowledgement mode. Possible values are:
- * 0 - SESSION_TRANSACTED
- * 1 - AUTO_ACKNOWLEDGE
- * 2 - CLIENT_ACKNOWLEDGE
- * 3 - DUPS_OK_ACKNOWLEDGE
- * 257 - NO_ACKNOWLEDGE
- * 258 - PRE_ACKNOWLEDGE
- * <tr><td> maxPending <td> 0 <td> The maximum size in bytes, of messages sent but not yet received.
- * Limits the volume of messages currently buffered on the client
- * or broker. Can help scale test clients by limiting amount of buffered
- * data to avoid out of memory errors.
- * </table>
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide the names and defaults of all test parameters.
- * </table>
- */
-public class MessagingTestConfigProperties
-{
- // ====================== Connection Properties ==================================
-
- /** Holds the name of the default connection configuration. */
- public static final String CONNECTION_NAME = "broker";
-
- /** Holds the name of the property to get the initial context factory name from. */
- public static final String INITIAL_CONTEXT_FACTORY_PROPNAME = "java.naming.factory.initial";
-
- /** Defines the class to use as the initial context factory by default. */
- public static final String INITIAL_CONTEXT_FACTORY_DEFAULT = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
-
- /** Holds the name of the default connection factory configuration property. */
- public static final String CONNECTION_PROPNAME = "connectionfactory.broker";
-
- /** Holds the name of the property to get the test broker url from. */
- public static final String BROKER_PROPNAME = "qpid.test.broker";
-
- /** Holds the name of the property to get the test broker virtual path. */
- public static final String VIRTUAL_HOST_PROPNAME = "virtualHost";
-
- /** Holds the default virtual path for the test. */
- public static final String VIRTUAL_HOST_DEFAULT = "";
-
- /** Holds the name of the property to get the broker access username from. */
- public static final String USERNAME_PROPNAME = "username";
-
- /** Holds the default broker log on username. */
- public static final String USERNAME_DEFAULT = "guest";
-
- /** Holds the name of the property to get the broker access password from. */
- public static final String PASSWORD_PROPNAME = "password";
-
- /** Holds the default broker log on password. */
- public static final String PASSWORD_DEFAULT = "guest";
-
- // ====================== Messaging Topology Properties ==========================
-
- /** Holds the name of the property to get the bind publisher procuder flag from. */
- public static final String PUBLISHER_PRODUCER_BIND_PROPNAME = "publisherProducerBind";
-
- /** Holds the default value of the publisher producer flag. */
- public static final boolean PUBLISHER_PRODUCER_BIND_DEFAULT = true;
-
- /** Holds the name of the property to get the bind publisher procuder flag from. */
- public static final String PUBLISHER_CONSUMER_BIND_PROPNAME = "publisherConsumerBind";
-
- /** Holds the default value of the publisher consumer flag. */
- public static final boolean PUBLISHER_CONSUMER_BIND_DEFAULT = false;
-
- /** Holds the name of the property to get the bind receiver procuder flag from. */
- public static final String RECEIVER_PRODUCER_BIND_PROPNAME = "receiverProducerBind";
-
- /** Holds the default value of the receiver producer flag. */
- public static final boolean RECEIVER_PRODUCER_BIND_DEFAULT = false;
-
- /** Holds the name of the property to get the bind receiver procuder flag from. */
- public static final String RECEIVER_CONSUMER_BIND_PROPNAME = "receiverConsumerBind";
-
- /** Holds the default value of the receiver consumer flag. */
- public static final boolean RECEIVER_CONSUMER_BIND_DEFAULT = true;
-
- /** Holds the name of the property to get the destination name root from. */
- public static final String SEND_DESTINATION_NAME_ROOT_PROPNAME = "sendDestinationRoot";
-
- /** Holds the root of the name of the default destination to send to. */
- public static final String SEND_DESTINATION_NAME_ROOT_DEFAULT = "sendTo";
-
- /** Holds the name of the property to get the destination name root from. */
- public static final String RECEIVE_DESTINATION_NAME_ROOT_PROPNAME = "receiveDestinationRoot";
-
- /** Holds the root of the name of the default destination to send to. */
- public static final String RECEIVE_DESTINATION_NAME_ROOT_DEFAULT = "receiveFrom";
-
- /** Holds the name of the proeprty to get the destination count from. */
- public static final String DESTINATION_COUNT_PROPNAME = "destinationCount";
-
- /** Defines the default number of destinations to ping. */
- public static final int DESTINATION_COUNT_DEFAULT = 1;
-
- /** Holds the name of the property to get the p2p or pub/sub messaging mode from. */
- public static final String PUBSUB_PROPNAME = "pubsub";
-
- /** Holds the pub/sub mode default, true means ping a topic, false means ping a queue. */
- public static final boolean PUBSUB_DEFAULT = false;
-
- // ====================== JMS Options and Flags =================================
-
- /** Holds the name of the property to get the test delivery mode from. */
- public static final String PERSISTENT_MODE_PROPNAME = "persistent";
-
- /** Holds the message delivery mode to use for the test. */
- public static final boolean PERSISTENT_MODE_DEFAULT = false;
-
- /** Holds the name of the property to get the test transactional mode from. */
- public static final String TRANSACTED_PROPNAME = "transacted";
-
- /** Holds the transactional mode to use for the test. */
- public static final boolean TRANSACTED_DEFAULT = false;
-
- /** Holds the name of the property to set the no local flag from. */
- public static final String NO_LOCAL_PROPNAME = "noLocal";
-
- /** Defines the default value of the no local flag to use when consuming messages. */
- public static final boolean NO_LOCAL_DEFAULT = false;
-
- /** Holds the name of the property to get the message acknowledgement mode from. */
- public static final String ACK_MODE_PROPNAME = "ackMode";
-
- /** Defines the default message acknowledgement mode. */
- public static final int ACK_MODE_DEFAULT = Session.AUTO_ACKNOWLEDGE;
-
- /** Holds the name of the property to get the durable subscriptions flag from, when doing pub/sub messaging. */
- public static final String DURABLE_SUBSCRIPTION_PROPNAME = "durableSubscription";
-
- /** Defines the default value of the durable subscriptions flag. */
- public static final boolean DURABLE_SUBSCRIPTION_DEFAULT = false;
-
- // ====================== Qpid Options and Flags ================================
-
- /** Holds the name of the property to set the exclusive flag from. */
- public static final String EXCLUSIVE_PROPNAME = "exclusive";
-
- /** Defines the default value of the exclusive flag to use when consuming messages. */
- public static final boolean EXCLUSIVE_DEFAULT = false;
-
- /** Holds the name of the property to set the immediate flag from. */
- public static final String IMMEDIATE_PROPNAME = "immediate";
-
- /** Defines the default value of the immediate flag to use when sending messages. */
- public static final boolean IMMEDIATE_DEFAULT = false;
-
- /** Holds the name of the property to set the mandatory flag from. */
- public static final String MANDATORY_PROPNAME = "mandatory";
-
- /** Defines the default value of the mandatory flag to use when sending messages. */
- public static final boolean MANDATORY_DEFAULT = false;
-
- /** Holds the name of the property to get the durable destinations flag from. */
- public static final String DURABLE_DESTS_PROPNAME = "durableDests";
-
- /** Default value for the durable destinations flag. */
- public static final boolean DURABLE_DESTS_DEFAULT = false;
-
- /** Holds the name of the proeprty to set the prefetch size from. */
- public static final String PREFECTH_PROPNAME = "prefetch";
-
- /** Defines the default prefetch size to use when consuming messages. */
- public static final int PREFETCH_DEFAULT = 100;
-
- // ====================== Common Test Parameters ================================
-
- /** Holds the name of the property to get the test message size from. */
- public static final String MESSAGE_SIZE_PROPNAME = "messageSize";
-
- /** Used to set up a default message size. */
- public static final int MESSAGE_SIZE_DEAFULT = 0;
-
- /** Holds the name of the property to get the message rate from. */
- public static final String RATE_PROPNAME = "rate";
-
- /** Defines the default rate (in pings per second) to send pings at. 0 means as fast as possible, no restriction. */
- public static final int RATE_DEFAULT = 0;
-
- /** Holds the name of the proeprty to get the. */
- public static final String SELECTOR_PROPNAME = "selector";
-
- /** Holds the default message selector. */
- public static final String SELECTOR_DEFAULT = "";
-
- /** Holds the name of the property to get the waiting timeout for response messages. */
- public static final String TIMEOUT_PROPNAME = "timeout";
-
- /** Default time to wait before assuming that a ping has timed out. */
- public static final long TIMEOUT_DEFAULT = 30000;
-
- /** Holds the name of the property to get the commit batch size from. */
- public static final String TX_BATCH_SIZE_PROPNAME = "commitBatchSize";
-
- /** Defines the default number of pings to send in each transaction when running transactionally. */
- public static final int TX_BATCH_SIZE_DEFAULT = 1;
-
- /** Holds the name of the property to set the maximum amount of pending message data for a producer to hold. */
- public static final String MAX_PENDING_PROPNAME = "maxPending";
-
- /** Defines the default maximum quantity of pending message data to allow producers to hold. */
- public static final int MAX_PENDING_DEFAULT = 0;
-
- /** Holds the name of the property to get the verbose mode proeprty from. */
- public static final String VERBOSE_PROPNAME = "verbose";
-
- /** Holds the default verbose mode. */
- public static final boolean VERBOSE_DEFAULT = false;
-
- /** Holds the default configuration properties. */
- public static ParsedProperties defaults = new ParsedProperties();
-
- static
- {
- defaults.setPropertyIfNull(INITIAL_CONTEXT_FACTORY_PROPNAME, INITIAL_CONTEXT_FACTORY_DEFAULT);
- defaults.setPropertyIfNull(MESSAGE_SIZE_PROPNAME, MESSAGE_SIZE_DEAFULT);
- defaults.setPropertyIfNull(PUBLISHER_PRODUCER_BIND_PROPNAME, PUBLISHER_PRODUCER_BIND_DEFAULT);
- defaults.setPropertyIfNull(PUBLISHER_CONSUMER_BIND_PROPNAME, PUBLISHER_CONSUMER_BIND_DEFAULT);
- defaults.setPropertyIfNull(RECEIVER_PRODUCER_BIND_PROPNAME, RECEIVER_PRODUCER_BIND_DEFAULT);
- defaults.setPropertyIfNull(RECEIVER_CONSUMER_BIND_PROPNAME, RECEIVER_CONSUMER_BIND_DEFAULT);
- defaults.setPropertyIfNull(SEND_DESTINATION_NAME_ROOT_PROPNAME, SEND_DESTINATION_NAME_ROOT_DEFAULT);
- defaults.setPropertyIfNull(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME, RECEIVE_DESTINATION_NAME_ROOT_DEFAULT);
- defaults.setPropertyIfNull(PERSISTENT_MODE_PROPNAME, PERSISTENT_MODE_DEFAULT);
- defaults.setPropertyIfNull(TRANSACTED_PROPNAME, TRANSACTED_DEFAULT);
- defaults.setPropertyIfNull(VIRTUAL_HOST_PROPNAME, VIRTUAL_HOST_DEFAULT);
- defaults.setPropertyIfNull(RATE_PROPNAME, RATE_DEFAULT);
- defaults.setPropertyIfNull(VERBOSE_PROPNAME, VERBOSE_DEFAULT);
- defaults.setPropertyIfNull(PUBSUB_PROPNAME, PUBSUB_DEFAULT);
- defaults.setPropertyIfNull(USERNAME_PROPNAME, USERNAME_DEFAULT);
- defaults.setPropertyIfNull(PASSWORD_PROPNAME, PASSWORD_DEFAULT);
- defaults.setPropertyIfNull(SELECTOR_PROPNAME, SELECTOR_DEFAULT);
- defaults.setPropertyIfNull(DESTINATION_COUNT_PROPNAME, DESTINATION_COUNT_DEFAULT);
- defaults.setPropertyIfNull(TIMEOUT_PROPNAME, TIMEOUT_DEFAULT);
- defaults.setPropertyIfNull(TX_BATCH_SIZE_PROPNAME, TX_BATCH_SIZE_DEFAULT);
- defaults.setPropertyIfNull(DURABLE_DESTS_PROPNAME, DURABLE_DESTS_DEFAULT);
- defaults.setPropertyIfNull(ACK_MODE_PROPNAME, ACK_MODE_DEFAULT);
- defaults.setPropertyIfNull(DURABLE_SUBSCRIPTION_PROPNAME, DURABLE_SUBSCRIPTION_DEFAULT);
- defaults.setPropertyIfNull(MAX_PENDING_PROPNAME, MAX_PENDING_DEFAULT);
- defaults.setPropertyIfNull(PREFECTH_PROPNAME, PREFETCH_DEFAULT);
- defaults.setPropertyIfNull(NO_LOCAL_PROPNAME, NO_LOCAL_DEFAULT);
- defaults.setPropertyIfNull(EXCLUSIVE_PROPNAME, EXCLUSIVE_DEFAULT);
- defaults.setPropertyIfNull(IMMEDIATE_PROPNAME, IMMEDIATE_DEFAULT);
- defaults.setPropertyIfNull(MANDATORY_PROPNAME, MANDATORY_DEFAULT);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java b/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
index 2a1895d6c8..3d116f1b1b 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
@@ -241,7 +241,7 @@ public class ReturnUnroutableMandatoryMessageTest extends QpidBrokerTestCase imp
con2.start();
MessageProducer nonMandatoryProducer = producerSession.createProducer(valid_topic, false, false);
- MessageProducer mandatoryProducer = producerSession.createProducer(invalid_topic);
+ MessageProducer mandatoryProducer = producerSession.createProducer(invalid_topic, false, true);
// First test - should be routed
_logger.info("Sending non-mandatory message");
diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
deleted file mode 100644
index e32edff692..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
+++ /dev/null
@@ -1,573 +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.logging;
-
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
-
-import javax.jms.Connection;
-import javax.jms.Queue;
-import javax.jms.Session;
-import java.io.File;
-import java.util.List;
-
-/**
- * The MessageStore test suite validates that the follow log messages as
- * specified in the Functional Specification.
- *
- * This suite of tests validate that the MessageStore messages occur correctly
- * and according to the following format:
- *
- * MST-1001 : Created : <name>
- * MST-1003 : Closed
- *
- * NOTE: Only for Persistent Stores
- * MST-1002 : Store location : <path>
- * MST-1004 : Recovery Start [: <queue.name>]
- * MST-1005 : Recovered <count> messages for queue <queue.name>
- * MST-1006 : Recovery Complete [: <queue.name>]
- */
-public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
-{
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- // MemoryMessageStoreLoggingTest setUp itself does not call super.setUp
- //We call super.setUp but this will not start the broker as that is
- //part of the test case.
-
- // Load the default configuration file to get the list of defined vhosts
- ServerConfiguration configuration = new ServerConfiguration(new File(_configFile.getParent() + "/config.xml"));
- configuration.initialise();
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- // Make them all persistent i.e. Use DerbyMessageStore and
- // test that it logs correctly.
- for (String vhost : vhosts)
- {
- makeVirtualHostPersistent(vhost);
- }
- }
-
- /**
- * Description:
- * Persistent MessageStores will require space on disk to persist the data.
- * This value will be logged on startup after the MessageStore has been
- * created.
- * Input:
- * Default configuration
- * Output:
- *
- * <date> MST-1002 : Store location : <path>
- *
- * Validation Steps:
- *
- * 1. The MST ID is correct
- * 2. This must occur after MST-1001
- */
- public void testMessageStoreStoreLocation() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- startBroker();
-
- List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
-
- // Validation
-
- assertTrue("MST messages not logged", results.size() > 0);
-
- // Load VirtualHost list from file.
- ServerConfiguration configuration = new ServerConfiguration(_configFile);
- configuration.initialise();
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = waitAndFindMatches("MST-1002");
-
- assertEquals("Each vhost did not close its store.", vhosts.size(), results.size());
-
- for (int index = 0; index < results.size(); index++)
- {
- String result = getLogMessage(results, index);;
-
- // getSlize will return extract the vhost from vh(/test) -> '/test'
- // so remove the '/' to get the name
- String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
-
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
-
- // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
- String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
-
- assertTrue("MST-1002 does not contain a store path" + getMessageString(result),
- getMessageString(result).length() > 0);
-
- assertEquals("The store name does not match expected value",
- storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
- }
- }
-
- /**
- * Description:
- * Persistent message stores may have state on disk that they must recover
- * during startup. As the MessageStore starts up it will report that it is
- * about to start the recovery process by logging MST-1004. This message
- * will always be logged for persistent MessageStores. If there is no data
- * to recover then there will be no subsequent recovery messages.
- * Input:
- * Default persistent configuration
- * Output:
- * <date> MST-1004 : Recovery Start
- *
- * Validation Steps:
- *
- * 1. The MST ID is correct
- * 2. The MessageStore must have first logged a creation event.
- */
- public void testMessageStoreRecoveryStart() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- startBroker();
-
- List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
-
- // Validation
-
- assertTrue("MST messages not logged", results.size() > 0);
-
- // Load VirtualHost list from file.
- ServerConfiguration configuration = new ServerConfiguration(_configFile);
- configuration.initialise();
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = waitAndFindMatches("MST-1004");
-
- assertTrue("Each vhost did not close its store.", vhosts.size() <= results.size());
-
- for (int index = 0; index < results.size(); index++)
- {
- String result = getLogMessage(results, index);;
-
- if (getMessageString(result).contains("Recovery Start :"))
- {
- //Don't test queue start recoveries
- continue;
- }
-
- // getSlize will return extract the vhost from vh(/test) -> '/test'
- // so remove the '/' to get the name
- String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
-
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
-
- // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
- String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
-
- assertEquals("MST-1004 does have expected message", "Recovery Start",
- getMessageString(result));
-
- assertEquals("The store name does not match expected value",
- storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
- }
- }
-
- /**
- * Description:
- * Once all persistent queues have been recovered and the MessageStore has completed all recovery it must logged that the recovery process has completed.
- * Input:
- * Default persistent configuration
- * Output:
- *
- * <date> MST-1006 : Recovery Complete
- *
- * Validation Steps:
- *
- * 1. The MST ID is correct
- * 2. This is the last message from the MessageStore during startup.
- * 3. This must be proceeded by a MST-1006 Recovery Start.
- */
- public void testMessageStoreRecoveryComplete() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- startBroker();
-
- List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
-
- // Validation
-
- assertTrue("MST messages not logged", results.size() > 0);
-
- // Load VirtualHost list from file.
- ServerConfiguration configuration = new ServerConfiguration(_configFile);
- configuration.initialise();
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = waitAndFindMatches("MST-1006");
-
- assertTrue("Each vhost did not close its store.", vhosts.size() <= results.size());
-
- for (int index = 0; index < results.size(); index++)
- {
- String result = getLogMessage(results, index);
-
- if (getMessageString(result).contains("Recovery Complete :"))
- {
- //Don't test queue start recoveries
- continue;
- }
-
- // getSlize will return extract the vhost from vh(/test) -> '/test'
- // so remove the '/' to get the name
- String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
-
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
-
- // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
- String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
-
- assertEquals("MST-1006 does have expected message", "Recovery Complete",
- getMessageString(result));
-
- assertEquals("The store name does not match expected value",
- storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
- }
- }
-
- /**
- * Description:
- * A persistent MessageStore may have data to recover from disk. The message store will use MST-1004 to report the start of recovery for a specific queue that it has previously persisted.
- * Input:
- * Default persistent configuration
- * Output:
- *
- * <date> MST-1004 : Recovery Start : <queue.name>
- *
- * Validation Steps:
- *
- * 1. The MST ID is correct
- * 2. This must occur after the recovery start MST-1004 has been logged.
- */
- public void testMessageStoreQueueRecoveryStart() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- startBroker();
-
- List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
-
- // Validation
-
- assertTrue("MST messages not logged", results.size() > 0);
-
- // Load VirtualHost list from file.
- ServerConfiguration configuration = new ServerConfiguration(_configFile);
- configuration.initialise();
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = waitAndFindMatches("MST-1004 : Recovery Start :");
-
- // We are only looking for the default queue defined in local host being
- // recovered. If other tests have made queues in test then we want to
- // exclude them here.
- results = filterResultsByVirtualHost(results, "/localhost");
-
- assertEquals("Recovered test queue not found.", 1, results.size());
-
- String result = getLogMessage(results, 0);
-
- // getSlize will return extract the vhost from vh(/test) -> '/test'
- // so remove the '/' to get the name
- String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
-
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
-
- // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
- String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
-
- assertTrue("MST-1006 does end with queue 'test-queue':" + getMessageString(result),
- getMessageString(result).endsWith("test-queue"));
-
- assertEquals("The store name does not match expected value",
- storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
-
- }
-
- /**
- * Description:
- * After the queue has been recovered the store will log that recovery has been completed. The MessageStore must not report further status about the recovery of this queue after this message. In addition every MST-1004 queue recovery start message must be matched with a MST-1006 recovery complete.
- * Input:
- * Default persistent configuration
- * Output:
- *
- * <date> MST-1006 : Recovery Complete : <queue.name>
- *
- * Validation Steps:
- *
- * 1. The MST ID is correct
- * 2. This must occur after the queue recovery start MST-1004 has been logged.
- * 3. The queue.name is non-empty
- * 4. The queue.name correlates with a previous recovery start
- */
- public void testMessageStoreQueueRecoveryComplete() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- startBroker();
-
- List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
-
- // Validation
-
- assertTrue("MST messages not logged", results.size() > 0);
-
- // Load VirtualHost list from file.
- ServerConfiguration configuration = new ServerConfiguration(_configFile);
- configuration.initialise();
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = waitAndFindMatches("MST-1006 : Recovery Complete :");
-
- // We are only looking for the default queue defined in local host being
- // recovered. If other tests have made queues in test then we want to
- // exclude them here.
- results = filterResultsByVirtualHost(results, "/localhost");
-
- assertEquals("Recovered test queue not found.", 1, results.size());
-
- String result = getLogMessage(results, 0);
-
- // getSlize will return extract the vhost from vh(/test) -> '/test'
- // so remove the '/' to get the name
- String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
-
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
-
- // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
- String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
-
- assertTrue("MST-1006 does end with queue 'test-queue':" + getMessageString(result),
- getMessageString(result).endsWith("test-queue"));
-
- assertEquals("The store name does not match expected value",
- storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
-
- results = findMatches("MST-1004 : Recovery Start : test-queue");
-
- assertEquals("MST-1004 for test-queue not found", 1, results.size());
- }
-
- /**
- * Description:
- * A persistent queue must be persisted so that on recovery it can be restored independently of any messages that may be stored on it. This test verifies that the MessageStore will log that it has recovered 0 messages for persistent queues that do not have any messages.
- * Input:
- *
- * 1. Default persistent configuration
- * 2. Persistent queue with no messages enqueued
- * Output:
- *
- * <date> MST-1005 : Recovered 0 messages for queue <queue.name>
- *
- * Validation Steps:
- * 3. The MST ID is correct
- * 4. This must occur after the queue recovery start MST-1004 has been logged.
- * 5. The count is 0
- * 6. 'messages' is correctly printed
- * 7. The queue.name is non-empty
- */
- public void testMessageStoreQueueRecoveryCountEmpty() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- String queueName = getTestQueueName();
-
- startBroker();
- Connection connetion = getConnection();
- Session session = connetion.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("direct://amq.direct/" + queueName + "/" + queueName + "?durable='true'");
-
- session.createConsumer(queue).close();
-
- // Stop the broker so that we can test recovery
- stopBroker();
-
- int COUNT = 0;
- testDurableRecoveryCount(COUNT, queueName);
- }
-
- /**
- * Description:
- * On recovery all the persistent messages that are stored on disk must be returned to the queue. MST-1005 will report the number of messages that have been recovered from disk.
- * Input:
- *
- * 1. Default persistent configuration
- * 2. Persistent queue with multiple messages enqueued
- * Output:
- *
- * <date> MST-1005 : Recovered <count> messages for queue <queue.name>
- *
- * Validation Steps:
- * 3. The MST ID is correct
- * 4. This must occur after the queue recovery start MST-1004 has been logged.
- * 5. The count is > 1
- * 6. 'messages' is correctly printed
- * 7. The queue.name is non-empty
- */
- public void testMessageStoreQueueRecoveryCountPlural() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- String queueName = getTestQueueName();
-
- int COUNT = 10;
-
- testDurableRecoveryCount(COUNT, queueName);
- }
-
- /**
- * Send a set number of messages to a new durable queue, as specified. Then
- * restart the broker and validate that they are restored.
- *
- * @param COUNT - the count to send
- * @param queueName - the new queue name
- * @throws Exception - if a problem occured.
- */
- private void testDurableRecoveryCount(int COUNT, String queueName) throws Exception
- {
- startBroker();
- Connection connetion = getConnection();
- Session session = connetion.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("direct://amq.direct/" + queueName + "/" + queueName + "?durable='true'");
-
- session.createConsumer(queue).close();
-
- sendMessage(session, queue, COUNT);
- try
- {
- connetion.close();
-
- stopBroker();
-
- // Clear our monitor
- _monitor.markDiscardPoint();
-
- startBroker();
-
- List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
-
- // Validation
-
- assertTrue("MST messages not logged", results.size() > 0);
-
- // Load VirtualHost list from file.
- ServerConfiguration configuration = new ServerConfiguration(_configFile);
- configuration.initialise();
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = waitAndFindMatches("MST-1004 : Recovery Start : " + queueName);
-
- assertEquals("Recovered test queue not found.", 1, results.size());
-
- String result = getLogMessage(results, 0);
-
- validateMessageID("MST-1004", result);
-
- assertTrue("MST-1004 does end with queue '" + queueName + "':" + getMessageString(result),
- getMessageString(result).endsWith(queueName));
-
- results = waitAndFindMatches("MST-1005");
-
- assertTrue("Insufficient MST-1005 logged.", results.size()>0);
-
- result = null;
-
- // If the first message is not our queue the second one will be
- for(String resultEntry : results)
- {
- // Look for first match and set that to result
- if (resultEntry.contains(queueName))
- {
- result = getLog(resultEntry);
- break;
- }
- }
-
- assertNotNull("MST-1005 entry for queue:" + queueName + ". Not found", result);
-
- // getSlize will return extract the vhost from vh(/test) -> '/test'
- // so remove the '/' to get the name
- String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
-
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
-
- // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
- String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
-
- assertTrue("MST-1005 does end with queue 'test-queue':" + getMessageString(result),
- getMessageString(result).endsWith(queueName));
-
- assertTrue("MST-1005 does end show correct count:" + getMessageString(result),
- getMessageString(result).contains("Recovered " + COUNT + " messages"));
-
- assertEquals("The store name does not match expected value",
- storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
- }
- finally
- {
- //Ensure we attempt to drain the queue.
- assertEquals("Unable to drain queue", COUNT, drainQueue(queue));
- }
- }
-
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
deleted file mode 100644
index e6e1196cc6..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
+++ /dev/null
@@ -1,186 +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.logging;
-
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
-import org.apache.qpid.util.LogMonitor;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * The MessageStore test suite validates that the follow log messages as
- * specified in the Functional Specification.
- *
- * This suite of tests validate that the MessageStore messages occur correctly
- * and according to the following format:
- *
- * MST-1001 : Created : <name>
- * MST-1003 : Closed
- *
- * NOTE: Only for Persistent Stores
- * MST-1002 : Store location : <path>
- * MST-1004 : Recovery Start [: <queue.name>]
- * MST-1005 : Recovered <count> messages for queue <queue.name>
- * MST-1006 : Recovery Complete [: <queue.name>]
- */
-public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
-{
- protected static final String MESSAGES_STORE_PREFIX = "MST-";
-
- public void setUp() throws Exception
- {
- //We explicitly do not call super.setUp as starting up the broker is
- //part of the test case.
- // So we have to make the new Log Monitor here
-
- _monitor = new LogMonitor(_outputFile);
- }
-
- /**
- * Description:
- * During Virtualhost startup a MessageStore will be created. The first MST
- * message that must be logged is the MST-1001 MessageStore creation.
- * Input:
- * Default configuration
- * Output:
- * <date> MST-1001 : Created : <name>
- *
- * Validation Steps:
- *
- * 1. The MST ID is correct
- * 2. The <name> is the correct MessageStore type as specified in the Default configuration
- *
- * @throws Exception caused by broker startup
- */
- public void testMessageStoreCreation() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- super.setUp();
-
- List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
-
- // Validation
-
- assertTrue("MST messages not logged", results.size() > 0);
-
- String log = getLogMessage(results, 0);
- //1
- assertEquals("MST-1001 is not the first MST message", "MST-1001", getMessageID(fromMessage(log)));
-
- //Validate each vhost logs a creation
- results = waitAndFindMatches("MST-1001");
-
- // Load VirtualHost list from file.
- List<String> vhosts = Arrays.asList(getServerConfig().getVirtualHosts());
-
- assertEquals("Each vhost did not create a store.", vhosts.size(), results.size());
-
- for (int index = 0; index < results.size(); index++)
- {
- String result = getLogMessage(results, index);
-
- // getSlice will return extract the vhost from vh(/test) -> '/test'
- // so remove the '/' to get the name
- String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
-
- // Get the store class used in the configuration for the virtualhost.
- String fullStoreName = getServerConfig().getVirtualHostConfig(vhostName).getMessageStoreClass();
-
- // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
- String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
-
- assertTrue("MST-1001 does not contains correct store name:"
- + storeName + ":" + result, getMessageString(result).endsWith(storeName));
-
- assertEquals("The store name does not match expected value",
- storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
- }
- }
-
- /**
- * Description:
- * During shutdown the MessageStore will also cleanly close. When this has
- * completed a MST-1003 closed message will be logged. No further messages
- * from this MessageStore will be logged after this message.
- *
- * Input:
- * Default configuration
- * Output:
- * <date> MST-1003 : Closed
- *
- * Validation Steps:
- *
- * 1. The MST ID is correct
- * 2. This is teh last log message from this MessageStore
- *
- * @throws Exception caused by broker startup
- */
- public void testMessageStoreClose() throws Exception
- {
- assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
-
- super.setUp();
-
- //Stop the broker so we get the close messages.
- stopBroker();
-
- List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
-
- // Validation
-
- assertTrue("MST messages not logged", results.size() > 0);
-
- // Load VirtualHost list from file.
- ServerConfiguration configuration = new ServerConfiguration(_configFile);
- configuration.initialise();
- List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
-
- //Validate each vhost logs a creation
- results = waitAndFindMatches("MST-1003");
-
- assertEquals("Each vhost did not close its store.", vhosts.size(), results.size());
-
- for (int index = 0; index < results.size(); index++)
- {
- String result = getLogMessage(results, index);
-
- // getSlice will return extract the vhost from vh(/test) -> '/test'
- // so remove the '/' to get the name
- String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
-
- // Get the store class used in the configuration for the virtualhost.
- String fullStoreName = configuration.getVirtualHostConfig(vhostName).getMessageStoreClass();
-
- // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
- String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
-
- assertEquals("MST-1003 does not close:",
- "Closed", getMessageString(result));
-
- assertEquals("The store name does not match expected value",
- storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
- }
- }
-
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
index ddcb96b4db..236202f323 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.server.logging;
+import javax.jms.QueueBrowser;
import junit.framework.AssertionFailedError;
import org.apache.qpid.client.AMQConnection;
@@ -166,8 +167,10 @@ public class SubscriptionLoggingTest extends AbstractTestLogging
*/
public void testSubscriptionCreateQueueBrowser() throws JMSException, IOException
{
- _session.createBrowser(_queue);
+ _connection.start();
+ QueueBrowser browser = _session.createBrowser(_queue);
+ browser.getEnumeration();
//Validate
//Ensure that we wait for the SUB log message
waitAndFindMatches("SUB-1001");
diff --git a/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java b/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
index 2e259191aa..bcad59a1fa 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
@@ -42,7 +42,7 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase
protected final String MY_TOPIC_SUBSCRIPTION_NAME = this.getName();
protected static final int SEND_COUNT = 10;
- public void test() throws Exception
+ public void testNoLocalNotQueued() throws Exception
{
if(!isBrokerStorePersistent())
{
@@ -66,6 +66,8 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase
// Check messages can be received as expected.
connection.start();
+ //As the no-local subscriber was on the same connection the messages were
+ //published on, tit will receive no messages as they will be discarded on the broker
List<Message> received = receiveMessage(noLocalSubscriber, SEND_COUNT);
assertEquals("No Local Subscriber Received messages", 0, received.size());
@@ -73,10 +75,12 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase
assertEquals("Normal Subscriber Received no messages",
SEND_COUNT, received.size());
session.commit();
+
+ normalSubscriber.close();
connection.close();
- //We didn't receive the messages on the durable queue for the no-local subscriber
- //so they are still on the broker. Restart the broker, prompting their recovery.
+ //Ensure the no-local subscribers messages were discarded by restarting the broker
+ //and reconnecting to the subscription to ensure they were not recovered.
restartBroker();
Connection connection2 = getConnection();
@@ -89,12 +93,72 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase
createDurableSubscriber(topic2, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal",
null, true);
- // The NO-local subscriber should now get ALL the messages
- // as they are being consumed on a different connection to
- // the one that they were published on.
+ // The NO-local subscriber should not get any messages
+ received = receiveMessage(noLocalSubscriber2, SEND_COUNT);
+ session2.commit();
+ assertEquals("No Local Subscriber Received messages", 0, received.size());
+
+ noLocalSubscriber2.close();
+
+
+ }
+
+
+ public void testNonNoLocalQueued() throws Exception
+ {
+ if(!isBrokerStorePersistent())
+ {
+ fail("This test requires a broker with a persistent store");
+ }
+
+ Connection connection = getConnection();
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Topic topic = session.createTopic(MY_TOPIC_SUBSCRIPTION_NAME);
+
+ TopicSubscriber noLocalSubscriber =
+ session.createDurableSubscriber(topic, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal", null, true);
+
+
+ sendMessage(session, topic, SEND_COUNT);
+
+ // Check messages can be received as expected.
+ connection.start();
+
+ List<Message> received = receiveMessage(noLocalSubscriber, SEND_COUNT);
+ assertEquals("No Local Subscriber Received messages", 0, received.size());
+
+
+
+ session.commit();
+
+ Connection connection3 = getConnection();
+ Session session3 = connection3.createSession(true, Session.SESSION_TRANSACTED);
+ sendMessage(session3, topic, SEND_COUNT);
+
+
+ connection.close();
+
+ //We didn't receive the messages on the durable queue for the no-local subscriber
+ //so they are still on the broker. Restart the broker, prompting their recovery.
+ restartBroker();
+
+ Connection connection2 = getConnection();
+ connection2.start();
+
+ Session session2 = connection2.createSession(true, Session.SESSION_TRANSACTED);
+ Topic topic2 = session2.createTopic(MY_TOPIC_SUBSCRIPTION_NAME);
+
+ TopicSubscriber noLocalSubscriber2 =
+ session2.createDurableSubscriber(topic2, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal",null, true);
+
+ // The NO-local subscriber should receive messages sent from connection3
received = receiveMessage(noLocalSubscriber2, SEND_COUNT);
session2.commit();
- assertEquals("No Local Subscriber Received messages", SEND_COUNT, received.size());
+ assertEquals("No Local Subscriber did not receive expected messages", SEND_COUNT, received.size());
+
+ noLocalSubscriber2.close();
+
+
}
protected List<Message> receiveMessage(MessageConsumer messageConsumer,
diff --git a/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java b/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java
index 7cb58ff1ed..a6c9885568 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java
@@ -21,8 +21,10 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.configuration.ClientProperties;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
@@ -30,12 +32,15 @@ import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.naming.NamingException;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
public class PriorityQueueTest extends QpidBrokerTestCase
{
@@ -197,4 +202,99 @@ public class PriorityQueueTest extends QpidBrokerTestCase
return send;
}
+
+ /**
+ * Test that after sending an initial message with priority 0, it is able to be repeatedly reflected back to the queue using
+ * default priority and then consumed again, with separate transacted sessions with prefetch 1 for producer and consumer.
+ *
+ * Highlighted defect with PriorityQueues resolved in QPID-3927.
+ */
+ public void testMessageReflectionWithPriorityIncreaseOnTransactedSessionsWithPrefetch1() throws Exception
+ {
+ setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, "1");
+ Connection conn = getConnection();
+ conn.start();
+ assertEquals("Prefetch not reset", 1, ((AMQConnection) conn).getMaxPrefetch());
+
+ final Session producerSess = conn.createSession(true, Session.SESSION_TRANSACTED);
+ final Session consumerSess = conn.createSession(true, Session.SESSION_TRANSACTED);
+
+ //declare a priority queue with 10 priorities
+ final Map<String,Object> arguments = new HashMap<String, Object>();
+ arguments.put("x-qpid-priorities",10);
+ ((AMQSession<?,?>) producerSess).createQueue(new AMQShortString(getTestQueueName()), false, true, false, arguments);
+
+ Queue queue = producerSess.createQueue(getTestQueueName());
+
+ //create the consumer, producer, add message listener
+ CountDownLatch latch = new CountDownLatch(5);
+ MessageConsumer cons = producerSess.createConsumer(queue);
+ MessageProducer producer = producerSess.createProducer(queue);
+
+ ReflectingMessageListener listener = new ReflectingMessageListener(producerSess,producer,consumerSess,latch);
+ cons.setMessageListener(listener);
+
+ //Send low priority 0 message to kick start the asynchronous reflection process
+ producer.setPriority(0);
+ producer.send(nextMessage(1, true, producerSess, producer));
+ producerSess.commit();
+
+ //wait for the reflection process to complete
+ assertTrue("Test process failed to complete in allowed time", latch.await(10, TimeUnit.SECONDS));
+ assertNull("Unexpected throwable encountered", listener.getThrown());
+ }
+
+ private static class ReflectingMessageListener implements MessageListener
+ {
+ private Session _prodSess;
+ private Session _consSess;
+ private CountDownLatch _latch;
+ private MessageProducer _prod;
+ private long _origCount;
+ private Throwable _lastThrown;
+
+ public ReflectingMessageListener(final Session prodSess, final MessageProducer prod,
+ final Session consSess, final CountDownLatch latch)
+ {
+ _latch = latch;
+ _origCount = _latch.getCount();
+ _prodSess = prodSess;
+ _consSess = consSess;
+ _prod = prod;
+ }
+
+ @Override
+ public void onMessage(final Message message)
+ {
+ try
+ {
+ _latch.countDown();
+ long msgNum = _origCount - _latch.getCount();
+ System.out.println("Received message " + msgNum + " with ID: " + message.getIntProperty("msg"));
+
+ if(_latch.getCount() > 0)
+ {
+ //reflect the message, updating its ID and using default priority
+ message.clearProperties();
+ message.setIntProperty("msg", (int) msgNum + 1);
+ _prod.setPriority(Message.DEFAULT_PRIORITY);
+ _prod.send(message);
+ _prodSess.commit();
+ }
+
+ //commit the consumer session to consume the message
+ _consSess.commit();
+ }
+ catch(Throwable t)
+ {
+ t.printStackTrace();
+ _lastThrown = t;
+ }
+ }
+
+ public Throwable getThrown()
+ {
+ return _lastThrown;
+ }
+ }
}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java b/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java
index ad8c856a74..13053d02df 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java
@@ -357,13 +357,45 @@ public class ProducerFlowControlTest extends AbstractTestLogging
consumer.receive();
}
+ public void testQueueDeleteWithBlockedFlow() throws Exception
+ {
+ String queueName = getTestQueueName();
+ createAndBindQueueWithFlowControlEnabled(producerSession, queueName, 1000, 800, true, false);
+
+ producer = producerSession.createProducer(queue);
+
+ // try to send 5 messages (should block after 4)
+ sendMessagesAsync(producer, producerSession, 5, 50L);
+
+ Thread.sleep(5000);
+
+ assertEquals("Incorrect number of message sent before blocking", 4, _sentMessages.get());
+
+ // close blocked producer session and connection
+ producerConnection.close();
+
+ // delete queue with a consumer session
+ ((AMQSession<?,?>) consumerSession).sendQueueDelete(new AMQShortString(queueName));
+
+ consumer = consumerSession.createConsumer(queue);
+ consumerConnection.start();
+
+ Message message = consumer.receive(1000l);
+ assertNull("Unexpected message", message);
+ }
+
private void createAndBindQueueWithFlowControlEnabled(Session session, String queueName, int capacity, int resumeCapacity) throws Exception
{
+ createAndBindQueueWithFlowControlEnabled(session, queueName, capacity, resumeCapacity, false, true);
+ }
+
+ private void createAndBindQueueWithFlowControlEnabled(Session session, String queueName, int capacity, int resumeCapacity, boolean durable, boolean autoDelete) throws Exception
+ {
final Map<String,Object> arguments = new HashMap<String, Object>();
arguments.put("x-qpid-capacity",capacity);
arguments.put("x-qpid-flow-resume-capacity",resumeCapacity);
- ((AMQSession<?,?>) session).createQueue(new AMQShortString(queueName), true, false, false, arguments);
- queue = session.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='true'");
+ ((AMQSession<?,?>) session).createQueue(new AMQShortString(queueName), autoDelete, durable, false, arguments);
+ queue = session.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='" + durable + "'&autodelete='" + autoDelete + "'");
((AMQSession<?,?>) session).declareAndBind((AMQDestination)queue);
}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java b/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
index 54abb76b6d..f2d4a513be 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
@@ -26,10 +26,10 @@ import org.apache.log4j.Logger;
import org.apache.qpid.AMQStoreException;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.federation.Bridge;
import org.apache.qpid.server.federation.BrokerLink;
-import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.message.EnqueableMessage;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.queue.AMQQueue;
@@ -38,7 +38,7 @@ import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Iterator;
-public class SlowMessageStore implements MessageStore, DurableConfigurationStore
+public class SlowMessageStore implements MessageStore
{
private static final Logger _logger = Logger.getLogger(SlowMessageStore.class);
private static final String DELAYS = "delays";
@@ -55,11 +55,8 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
public void configureConfigStore(String name,
ConfigurationRecoveryHandler recoveryHandler,
- Configuration config,
- LogSubject logSubject) throws Exception
+ Configuration config) throws Exception
{
- //To change body of implemented methods use File | Settings | File Templates.
-
_logger.info("Starting SlowMessageStore on Virtualhost:" + name);
Configuration delays = config.subset(DELAYS);
@@ -74,7 +71,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
if (messageStoreClass != null)
{
- Class clazz = Class.forName(messageStoreClass);
+ Class<?> clazz = Class.forName(messageStoreClass);
Object o = clazz.newInstance();
@@ -89,13 +86,14 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
_durableConfigurationStore = (DurableConfigurationStore)o;
}
}
- _durableConfigurationStore.configureConfigStore(name, recoveryHandler, config, logSubject);
+ _durableConfigurationStore.configureConfigStore(name, recoveryHandler, config);
}
private void configureDelays(Configuration config)
{
- Iterator delays = config.getKeys();
+ @SuppressWarnings("unchecked")
+ Iterator<String> delays = config.getKeys();
while (delays.hasNext())
{
@@ -160,11 +158,11 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
public void configureMessageStore(String name,
- MessageStoreRecoveryHandler recoveryHandler,
- Configuration config,
- LogSubject logSubject) throws Exception
+ MessageStoreRecoveryHandler messageRecoveryHandler,
+ TransactionLogRecoveryHandler tlogRecoveryHandler,
+ Configuration config) throws Exception
{
- _realStore.configureMessageStore(name, recoveryHandler, config, logSubject);
+ _realStore.configureMessageStore(name, messageRecoveryHandler, tlogRecoveryHandler, config);
}
public void close() throws Exception
@@ -194,17 +192,17 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
doPostDelay("removeExchange");
}
- public void bindQueue(Exchange exchange, AMQShortString routingKey, AMQQueue queue, FieldTable args) throws AMQStoreException
+ public void bindQueue(Binding binding) throws AMQStoreException
{
doPreDelay("bindQueue");
- _durableConfigurationStore.bindQueue(exchange, routingKey, queue, args);
+ _durableConfigurationStore.bindQueue(binding);
doPostDelay("bindQueue");
}
- public void unbindQueue(Exchange exchange, AMQShortString routingKey, AMQQueue queue, FieldTable args) throws AMQStoreException
+ public void unbindQueue(Binding binding) throws AMQStoreException
{
doPreDelay("unbindQueue");
- _durableConfigurationStore.unbindQueue(exchange, routingKey, queue, args);
+ _durableConfigurationStore.unbindQueue(binding);
doPostDelay("unbindQueue");
}
@@ -227,14 +225,6 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
doPostDelay("removeQueue");
}
- public void configureTransactionLog(String name,
- TransactionLogRecoveryHandler recoveryHandler,
- Configuration storeConfiguration, LogSubject logSubject)
- throws Exception
- {
- _realStore.configureTransactionLog(name, recoveryHandler, storeConfiguration, logSubject);
- }
-
public Transaction newTransaction()
{
doPreDelay("beginTran");
@@ -313,6 +303,17 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
_underlying.abortTran();
doPostDelay("abortTran");
}
+
+ public void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException
+ {
+ _underlying.removeXid(format, globalId, branchId);
+ }
+
+ public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
+ throws AMQStoreException
+ {
+ _underlying.recordXid(format, globalId, branchId, enqueues, dequeues);
+ }
}
public void updateQueue(AMQQueue queue) throws AMQStoreException
@@ -350,4 +351,23 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
_durableConfigurationStore.deleteBridge(bridge);
doPostDelay("deleteBridge");
}
+
+ @Override
+ public void activate() throws Exception
+ {
+ _realStore.activate();
+ }
+
+ @Override
+ public void addEventListener(EventListener eventListener, Event... events)
+ {
+ _realStore.addEventListener(eventListener, events);
+ }
+
+ @Override
+ public String getStoreLocation()
+ {
+ return _realStore.getStoreLocation();
+ }
+
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/Assertion.java b/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStoreFactory.java
index 60d54f1f6f..6497a640d2 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/Assertion.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStoreFactory.java
@@ -1,5 +1,4 @@
/*
- *
* 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
@@ -18,22 +17,21 @@
* under the License.
*
*/
-package org.apache.qpid.test.framework;
+package org.apache.qpid.server.store;
-/**
- * Assertion models an assertion on a test {@link Circuit}.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Indicate whether or not the assertion passes when applied.
- * </table>
- */
-public interface Assertion
+public class SlowMessageStoreFactory implements MessageStoreFactory
{
- /**
- * Applies the assertion.
- *
- * @return <tt>true</tt> if the assertion passes, <tt>false</tt> if it fails.
- */
- public boolean apply();
+
+ @Override
+ public MessageStore createMessageStore()
+ {
+ return new SlowMessageStore();
+ }
+
+ @Override
+ public String getStoreClassName()
+ {
+ return SlowMessageStore.class.getSimpleName();
+ }
+
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/client/CancelTest.java b/java/systests/src/main/java/org/apache/qpid/test/client/CancelTest.java
deleted file mode 100644
index d95ad51e05..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/client/CancelTest.java
+++ /dev/null
@@ -1,101 +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.test.client;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-import java.util.Enumeration;
-
-public class CancelTest extends QpidBrokerTestCase
-{
- private static final Logger _logger = Logger.getLogger(CancelTest.class);
-
- private Connection _clientConnection;
- private Session _clientSession;
- private Queue _queue;
-
- public void setUp() throws Exception
- {
-
- super.setUp();
-
- _queue = (Queue) getInitialContext().lookup("queue");
-
- //Create Client
- _clientConnection = getConnection();
-
- _clientConnection.start();
-
- _clientSession = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- //Ensure _queue is created
- _clientSession.createConsumer(_queue).close();
- }
-
- /**
- * Simply
- * This test originally did not assert anything but was just checking
- * that a message could be browsed and consumed without throwing an exception.
- * It now checks that at least a message is browsed and that a message is received.
- */
- public void test() throws Exception
- {
- Connection producerConnection = getConnection();
-
- producerConnection.start();
-
- Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = producerSession.createProducer(_queue);
- producer.send(producerSession.createTextMessage());
- producerConnection.close();
-
-
- QueueBrowser browser = _clientSession.createBrowser(_queue);
- Enumeration e = browser.getEnumeration();
-
- assertTrue(e.hasMoreElements());
-
- int i = 0;
- while (e.hasMoreElements())
- {
- e.nextElement();
- if(++i > 1)
- {
- fail("Two many elemnts to browse!");
- }
- }
-
- browser.close();
-
- MessageConsumer consumer = _clientSession.createConsumer(_queue);
- assertNotNull( consumer.receive(2000l) );
- consumer.close();
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java b/java/systests/src/main/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java
index 484146b690..b746a5b09e 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java
@@ -18,11 +18,9 @@
*/
package org.apache.qpid.test.client;
-import org.apache.qpid.client.AMQNoConsumersException;
-import org.apache.qpid.client.AMQNoRouteException;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.ExceptionListener;
@@ -32,9 +30,10 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.Topic;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
+import org.apache.qpid.client.AMQNoConsumersException;
+import org.apache.qpid.client.AMQNoRouteException;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
public class ImmediateAndMandatoryPublishingTest extends QpidBrokerTestCase implements ExceptionListener
{
@@ -202,7 +201,88 @@ public class ImmediateAndMandatoryPublishingTest extends QpidBrokerTestCase impl
return message;
}
- @Override
+ public void testMandatoryAndImmediateDefaults() throws JMSException, InterruptedException
+ {
+ Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // publish to non-existent queue - should get mandatory failure
+ MessageProducer producer = session.createProducer(session.createQueue(getTestQueueName()));
+ Message message = session.createMessage();
+ producer.send(message);
+
+ JMSException exception = _exceptions.poll(10, TimeUnit.SECONDS);
+ assertNotNull("JMSException is expected", exception);
+ AMQNoRouteException noRouteException = (AMQNoRouteException) exception.getLinkedException();
+ assertNotNull("AMQNoRouteException should be linked to JMSEXception", noRouteException);
+ Message bounceMessage = (Message) noRouteException.getUndeliveredMessage();
+ assertNotNull("Bounced Message is expected", bounceMessage);
+ assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+
+ producer = session.createProducer(null);
+ message = session.createMessage();
+ producer.send(session.createQueue(getTestQueueName()), message);
+
+ exception = _exceptions.poll(10, TimeUnit.SECONDS);
+ assertNotNull("JMSException is expected", exception);
+ noRouteException = (AMQNoRouteException) exception.getLinkedException();
+ assertNotNull("AMQNoRouteException should be linked to JMSEXception", noRouteException);
+ bounceMessage = (Message) noRouteException.getUndeliveredMessage();
+ assertNotNull("Bounced Message is expected", bounceMessage);
+ assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+
+
+ // publish to non-existent topic - should get no failure
+ producer = session.createProducer(session.createTopic(getTestQueueName()));
+ message = session.createMessage();
+ producer.send(message);
+
+ exception = _exceptions.poll(1, TimeUnit.SECONDS);
+ assertNull("Unexpected JMSException", exception);
+
+ producer = session.createProducer(null);
+ message = session.createMessage();
+ producer.send(session.createTopic(getTestQueueName()), message);
+
+ exception = _exceptions.poll(1, TimeUnit.SECONDS);
+ assertNull("Unexpected JMSException", exception);
+
+ session.close();
+ }
+
+ public void testMandatoryAndImmediateSystemProperties() throws JMSException, InterruptedException
+ {
+ setTestClientSystemProperty("qpid.default_mandatory","true");
+ Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // publish to non-existent topic - should get mandatory failure
+
+ MessageProducer producer = session.createProducer(session.createTopic(getTestQueueName()));
+ Message message = session.createMessage();
+ producer.send(message);
+
+ JMSException exception = _exceptions.poll(10, TimeUnit.SECONDS);
+ assertNotNull("JMSException is expected", exception);
+ AMQNoRouteException noRouteException = (AMQNoRouteException) exception.getLinkedException();
+ assertNotNull("AMQNoRouteException should be linked to JMSEXception", noRouteException);
+ Message bounceMessage = (Message) noRouteException.getUndeliveredMessage();
+ assertNotNull("Bounced Message is expected", bounceMessage);
+ assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+
+ // now set topic specific system property to false - should no longer get mandatory failure on new producer
+ setTestClientSystemProperty("qpid.default_mandatory_topic","false");
+ producer = session.createProducer(null);
+ message = session.createMessage();
+ producer.send(session.createTopic(getTestQueueName()), message);
+
+ exception = _exceptions.poll(1, TimeUnit.SECONDS);
+ if(exception != null)
+ {
+ exception.printStackTrace();
+ }
+ assertNull("Unexpected JMSException", exception);
+
+ }
+
public void onException(JMSException exception)
{
_exceptions.add(exception);
diff --git a/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java b/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
index 7a4a45a2c8..6b6b4a7b3c 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
@@ -20,11 +20,7 @@
*/
package org.apache.qpid.test.client;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
+import java.util.Enumeration;
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -35,7 +31,10 @@ import javax.jms.QueueBrowser;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.NamingException;
-import java.util.Enumeration;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
public class QueueBrowserAutoAckTest extends QpidBrokerTestCase
{
@@ -421,4 +420,21 @@ public class QueueBrowserAutoAckTest extends QpidBrokerTestCase
validate(messages);
}
+ public void testBrowsingWhileStopped() throws JMSException
+ {
+ _clientConnection.stop();
+
+ try
+ {
+ QueueBrowser browser = _clientSession.createBrowser(getTestQueue());
+ Enumeration messages = browser.getEnumeration();
+ fail("Expected exception when attempting to browse on a stopped connection did not occur");
+ }
+ catch(javax.jms.IllegalStateException e)
+ {
+ // pass
+ }
+
+ }
+
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java b/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
index ee81e7c372..91f5cb7770 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
@@ -54,7 +54,7 @@ public class SyncWaitDelayTest extends QpidBrokerTestCase
public void setUp() throws Exception
{
- setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.class", "org.apache.qpid.server.store.SlowMessageStore");
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.factoryclass", "org.apache.qpid.server.store.SlowMessageStoreFactory");
setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.delays.commitTran.post", String.valueOf(POST_COMMIT_DELAY));
setConfigurationProperty("management.enabled", "false");
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/AMQPPublisher.java b/java/systests/src/main/java/org/apache/qpid/test/framework/AMQPPublisher.java
deleted file mode 100644
index 13465741bd..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/AMQPPublisher.java
+++ /dev/null
@@ -1,54 +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.test.framework;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-/**
- * An AMQPPublisher represents the status of the publishing side of a test circuit that exposes AMQP specific features.
- * Its provides additional assertions not available through the plain JMS {@link Publisher} interface.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Provide assertion that the publishers received a no consumers error code on every message.
- * <tr><td> Provide assertion that the publishers received a no route error code on every message.
- * </table>
- */
-public interface AMQPPublisher extends Publisher
-{
- /**
- * Provides an assertion that the publisher got a no consumers exception on every message.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the publisher got a no consumers exception on every message.
- */
- Assertion noConsumersAssertion(ParsedProperties testProps);
-
- /**
- * Provides an assertion that the publisher got a no rout exception on every message.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the publisher got a no rout exception on every message.
- */
- Assertion noRouteAssertion(ParsedProperties testProps);
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/AssertionBase.java b/java/systests/src/main/java/org/apache/qpid/test/framework/AssertionBase.java
deleted file mode 100644
index 0bb4911d4c..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/AssertionBase.java
+++ /dev/null
@@ -1,66 +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.test.framework;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * AssertionBase is a base class for implenmenting assertions. It provides a mechanism to store error messages, and
- * report all error messages when its {@link #toString()} method is called.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Collect error messages.
- * </table>
- */
-public abstract class AssertionBase implements Assertion
-{
- /** Holds the error messages. */
- List<String> errors = new LinkedList<String>();
-
- /**
- * Adds an error message to the assertion.
- *
- * @param error An error message to add to the assertion.
- */
- public void addError(String error)
- {
- errors.add(error);
- }
-
- /**
- * Prints all of the error messages in the assertion into a string.
- *
- * @return All of the error messages in the assertion as a string.
- */
- public String toString()
- {
- String result = "";
-
- for (String error : errors)
- {
- result += error;
- }
-
- return result;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/BrokerLifecycleAware.java b/java/systests/src/main/java/org/apache/qpid/test/framework/BrokerLifecycleAware.java
deleted file mode 100644
index 41614f92fc..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/BrokerLifecycleAware.java
+++ /dev/null
@@ -1,70 +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.test.framework;
-
-/**
- * BrokerLifecycleAware is an awareness interface implemented by test cases that can run control the life-cycle of
- * the brokers on which they run. Its purpose is to expose additional instrumentation of brokers during testing, that
- * enables tests to use an automated failure mechanism to simulate broker failures, and to re-start failed brokers.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Indicate whether or not a test case is using an in-vm broker.
- * <tr><td> Track which in-vm broker is currently in use.
- * <tr><td> Accept setting of a failure mechanism. <td> {@link CauseFailure}.
- * </table>
- *
- * @todo Need to think about how to present the brokers through this interface. Thinking numbering the available
- * brokers from 1 will do. Then can kill 1 and assume failing onto 2. Restart 1 and kill 2 and fail back onto
- * 1 again?
- */
-public interface BrokerLifecycleAware
-{
- public void setInVmBrokers();
-
- /**
- * Indicates whether or not a test case is using in-vm brokers.
- *
- * @return <tt>true</tt> if the test is using in-vm brokers, <tt>false</tt> otherwise.
- */
- public boolean usingInVmBroker();
-
- /**
- * Sets the currently live in-vm broker.
- *
- * @param i The currently live in-vm broker.
- */
- public void setLiveBroker(int i);
-
- /**
- * Reports the currently live in-vm broker.
- *
- * @return The currently live in-vm broker.
- */
- public int getLiveBroker();
-
- /**
- * Accepts a failure mechanism.
- *
- * @param failureMechanism The failure mechanism.
- */
- public void setFailureMechanism(CauseFailure failureMechanism);
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailure.java b/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailure.java
deleted file mode 100644
index 9bdd5a72c5..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailure.java
+++ /dev/null
@@ -1,42 +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.test.framework;
-
-/**
- * CauseFailure provides a method to cause a failure in a messaging broker, usually used in conjunction with fail-over
- * or other failure mode testing. In some cases failures may be automated, for example by shutting down an in-vm broker,
- * or by sending a special control signal to a broker over a network connection. In other cases, it may be preferable
- * to ask a user interactively to cause a failure scenario, in which case an implementation may display a prompt or
- * dialog box asking for notification once the failure has been caused. The purpose of this interface is to abstract
- * the exact cause and nature of a failure out of failure test cases.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Cause messaging broker failure.
- * </table>
- */
-public interface CauseFailure
-{
- /**
- * Causes the active message broker to fail.
- */
- void causeFailure();
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailureUserPrompt.java b/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailureUserPrompt.java
deleted file mode 100644
index 118ddff48b..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailureUserPrompt.java
+++ /dev/null
@@ -1,63 +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.test.framework;
-
-import java.io.IOException;
-
-/**
- * Causes a message broker failure by interactively prompting the user to cause it.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Cause messaging broker failure.
- * </table>
- */
-public class CauseFailureUserPrompt implements CauseFailure
-{
- /**
- * Causes the active message broker to fail.
- */
- public void causeFailure()
- {
- waitForUser("Cause a broker failure now, then press Return.");
- }
-
- /**
- * Outputs a prompt to the console and waits for the user to press return.
- *
- * @param prompt The prompt to display on the console.
- */
- private void waitForUser(String prompt)
- {
- System.out.println(prompt);
-
- try
- {
- System.in.read();
- }
- catch (IOException e)
- {
- // Ignored.
- }
-
- System.out.println("Continuing.");
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/Circuit.java b/java/systests/src/main/java/org/apache/qpid/test/framework/Circuit.java
deleted file mode 100644
index 4f9ab1a273..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/Circuit.java
+++ /dev/null
@@ -1,109 +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.test.framework;
-
-import java.util.List;
-
-/**
- * A Circuit is the basic test unit against which test cases are to be written. A circuit consists of two 'ends', an
- * instigating 'publisher' end and a more passive 'receivers' end.
- *
- * <p/>Once created, the life-cycle of a circuit may be controlled by {@link #start()}ing it, or {@link #close()}ing it.
- * Once started, the circuit is ready to send messages over. Once closed the circuit can no longer be used.
- *
- * <p/>The state of the circuit may be taken with the {@link #check()} method, and asserted against by the
- * {@link #applyAssertions(java.util.List)} method.
- *
- * <p/>There is a default test procedure which may be performed against the circuit. The outline of this procedure is:
- *
- * <p/><pre>
- * Start the circuit.
- * Send test messages.
- * Request a status report.
- * Assert conditions on the publishing end of the circuit.
- * Assert conditions on the receiving end of the circuit.
- * Close the circuit.
- * Pass with no failed assertions or fail with a list of failed assertions.
- * </pre>
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Supply the publishing and receiving ends of a test messaging circuit.
- * <tr><td> Start the circuit running.
- * <tr><td> Close the circuit down.
- * <tr><td> Take a reading of the circuits state.
- * <tr><td> Apply assertions against the circuits state.
- * <tr><td> Send test messages over the circuit.
- * <tr><td> Perform the default test procedue on the circuit.
- * </table>
- */
-public interface Circuit
-{
- /**
- * Gets the interface on the publishing end of the circuit.
- *
- * @return The publishing end of the circuit.
- */
- public Publisher getPublisher();
-
- /**
- * Gets the interface on the receiving end of the circuit.
- *
- * @return The receiving end of the circuit.
- */
- public Receiver getReceiver();
-
- /**
- * Connects and starts the circuit. After this method is called the circuit is ready to send messages.
- */
- public void start();
-
- /**
- * Checks the test circuit. The effect of this is to gather the circuits state, for both ends of the circuit,
- * into a report, against which assertions may be checked.
- */
- public void check();
-
- /**
- * Closes the circuit. All associated resources are closed.
- */
- public void close();
-
- /**
- * Applied a list of assertions against the test circuit. The {@link #check()} method should be called before doing
- * this, to ensure that the circuit has gathered its state into a report to assert against.
- *
- * @param assertions The list of assertions to apply to the circuit.
- *
- * @return Any assertions that failed.
- */
- public List<Assertion> applyAssertions(List<Assertion> assertions);
-
- /**
- * Runs the default test procedure against the circuit, and checks that all of the specified assertions hold.
- *
- * @param numMessages The number of messages to send using the default test procedure.
- * @param assertions The list of assertions to apply.
- *
- * @return Any assertions that failed.
- */
- public List<Assertion> test(int numMessages, List<Assertion> assertions);
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEnd.java b/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEnd.java
deleted file mode 100644
index ffde385cfc..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEnd.java
+++ /dev/null
@@ -1,95 +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.test.framework;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * A CircuitEnd is a pair consisting of one message producer and one message consumer, that represents one end of a
- * test circuit. It is a standard unit of connectivity allowing a full-duplex conversation to be held, provided both
- * the consumer and producer are instantiated and configured.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Provide a message producer for sending messages.
- * <tr><td> Provide a message consumer for receiving messages.
- * </table>
- *
- * @todo Update the {@link org.apache.qpid.test.utils.ConversationFactory} so that it accepts these as the basic conversation
- * connection units.
- */
-public interface CircuitEnd
-{
- /**
- * Gets the message producer at this circuit end point.
- *
- * @return The message producer at with this circuit end point.
- */
- public MessageProducer getProducer();
-
- /**
- * Gets the message consumer at this circuit end point.
- *
- * @return The message consumer at this circuit end point.
- */
- public MessageConsumer getConsumer();
-
- /**
- * Send the specified message over the producer at this end point.
- *
- * @param message The message to send.
- *
- * @throws JMSException Any JMS exception occuring during the send is allowed to fall through.
- */
- public void send(Message message) throws JMSException;
-
- /**
- * Gets the JMS Session associated with this circuit end point.
- *
- * @return The JMS Session associated with this circuit end point.
- */
- public Session getSession();
-
- /**
- * Closes the message producers and consumers and the sessions, associated with this circuit end point.
- *
- * @throws JMSException Any JMSExceptions occurring during the close are allowed to fall through.
- */
- public void close() throws JMSException;
-
- /**
- * Returns the message monitor for reporting on received messages on this circuit end.
- *
- * @return The message monitor for this circuit end.
- */
- public MessageMonitor getMessageMonitor();
-
- /**
- * Returns the exception monitor for reporting on exceptions received on this circuit end.
- *
- * @return The exception monitor for this circuit end.
- */
- public ExceptionMonitor getExceptionMonitor();
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEndBase.java b/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEndBase.java
deleted file mode 100644
index 5730752eae..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEndBase.java
+++ /dev/null
@@ -1,156 +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.test.framework;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * A CircuitEndBase is a pair consisting of one message producer and one message consumer, that represents one end of a
- * test circuit. It is a standard unit of connectivity allowing a full-duplex conversation to be held, provided both
- * the consumer and producer are instantiated and configured.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Provide a message producer for sending messages.
- * <tr><td> Provide a message consumer for receiving messages.
- * </table>
- */
-public class CircuitEndBase implements CircuitEnd
-{
- /** Holds the single message producer. */
- MessageProducer producer;
-
- /** Holds the single message consumer. */
- MessageConsumer consumer;
-
- /** Holds the controlSession for the circuit end. */
- Session session;
-
- /** Holds the message monitor for the circuit end. */
- MessageMonitor messageMonitor;
-
- /** Holds the exception monitor for the circuit end. */
- ExceptionMonitor exceptionMonitor;
-
- /**
- * Creates a circuit end point on the specified producer, consumer and controlSession. Monitors are also configured
- * for messages and exceptions received by the circuit end.
- *
- * @param producer The message producer for the circuit end point.
- * @param consumer The message consumer for the circuit end point.
- * @param session The controlSession for the circuit end point.
- * @param messageMonitor The monitor to notify of all messages received by the circuit end.
- * @param exceptionMonitor The monitor to notify of all exceptions received by the circuit end.
- */
- public CircuitEndBase(MessageProducer producer, MessageConsumer consumer, Session session, MessageMonitor messageMonitor,
- ExceptionMonitor exceptionMonitor)
- {
- this.producer = producer;
- this.consumer = consumer;
- this.session = session;
-
- this.messageMonitor = messageMonitor;
- this.exceptionMonitor = exceptionMonitor;
- }
-
- /**
- * Gets the message producer at this circuit end point.
- *
- * @return The message producer at with this circuit end point.
- */
- public MessageProducer getProducer()
- {
- return producer;
- }
-
- /**
- * Gets the message consumer at this circuit end point.
- *
- * @return The message consumer at this circuit end point.
- */
- public MessageConsumer getConsumer()
- {
- return consumer;
- }
-
- /**
- * Send the specified message over the producer at this end point.
- *
- * @param message The message to send.
- * @throws javax.jms.JMSException Any JMS exception occuring during the send is allowed to fall through.
- */
- public void send(Message message) throws JMSException
- {
- producer.send(message);
- }
-
- /**
- * Gets the JMS Session associated with this circuit end point.
- *
- * @return The JMS Session associated with this circuit end point.
- */
- public Session getSession()
- {
- return session;
- }
-
- /**
- * Closes the message producers and consumers and the sessions, associated with this circuit end point.
- *
- * @throws javax.jms.JMSException Any JMSExceptions occurring during the close are allowed to fall through.
- */
- public void close() throws JMSException
- {
- if (producer != null)
- {
- producer.close();
- }
-
- if (consumer != null)
- {
- consumer.close();
- }
- }
-
- /**
- * Returns the message monitor for reporting on received messages on this circuit end.
- *
- * @return The message monitor for this circuit end.
- */
- public MessageMonitor getMessageMonitor()
- {
- return messageMonitor;
- }
-
- /**
- * Returns the exception monitor for reporting on exceptions received on this circuit end.
- *
- * @return The exception monitor for this circuit end.
- */
- public ExceptionMonitor getExceptionMonitor()
- {
- return exceptionMonitor;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/DropInTest.java b/java/systests/src/main/java/org/apache/qpid/test/framework/DropInTest.java
deleted file mode 100644
index 78b5a72c1f..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/DropInTest.java
+++ /dev/null
@@ -1,51 +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.test.framework;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-/**
- * A DropIn test is a test case that can accept late joining test clients into a running test. This can be usefull,
- * for interactive experimentation.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Accept late joining test clients.
- * </table>
- */
-public interface DropInTest
-{
- /**
- * Should accept a late joining client into a running test case. The client will be enlisted with a control message
- * with the 'CONTROL_TYPE' field set to the value 'LATEJOIN'. It should also provide values for the fields:
- *
- * <p/><table>
- * <tr><td> CLIENT_NAME <td> A unique name for the new client.
- * <tr><td> CLIENT_PRIVATE_CONTROL_KEY <td> The key for the route on which the client receives its control messages.
- * </table>
- *
- * @param message The late joiners join message.
- *
- * @throws JMSException Any JMS Exception are allowed to fall through, indicating that the join failed.
- */
- public void lateJoin(Message message) throws JMSException;
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java b/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java
deleted file mode 100644
index afb7b5bc5b..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java
+++ /dev/null
@@ -1,204 +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
-/*
- *
- * 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.framework;
-
-import org.apache.log4j.Logger;
-
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An exception monitor, listens for JMS exception on a connection or consumer. It record all exceptions that it receives
- * and provides methods to test the number and type of exceptions received.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Record all exceptions received.
- * </table>
- */
-public class ExceptionMonitor implements ExceptionListener
-{
- /** Used for debugging. */
- private final Logger log = Logger.getLogger(ExceptionMonitor.class);
-
- /** Holds the received exceptions. */
- private List<Exception> exceptions = new ArrayList<Exception>();
-
- /**
- * Receives incoming exceptions.
- *
- * @param e The exception to record.
- */
- public synchronized void onException(JMSException e)
- {
- log.debug("public void onException(JMSException e): called", e);
-
- exceptions.add(e);
- }
-
- /**
- * Checks that no exceptions have been received.
- *
- * @return <tt>true</tt> if no exceptions have been received, <tt>false</tt> otherwise.
- */
- public synchronized boolean assertNoExceptions()
- {
- return exceptions.isEmpty();
- }
-
- /**
- * Checks that exactly one exception has been received.
- *
- * @return <tt>true</tt> if exactly one exception been received, <tt>false</tt> otherwise.
- */
- public synchronized boolean assertOneJMSException()
- {
- return exceptions.size() == 1;
- }
-
- /**
- * Checks that exactly one exception, with a linked cause of the specified type, has been received.
- *
- * @param aClass The type of the linked cause.
- *
- * @return <tt>true</tt> if exactly one exception, with a linked cause of the specified type, been received,
- * <tt>false</tt> otherwise.
- */
- public synchronized boolean assertOneJMSExceptionWithLinkedCause(Class aClass)
- {
- if (exceptions.size() == 1)
- {
- Exception e = exceptions.get(0);
-
- if (e instanceof JMSException)
- {
- JMSException jmse = (JMSException) e;
-
- Exception linkedCause = jmse.getLinkedException();
-
- if ((linkedCause != null) && aClass.isInstance(linkedCause))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Checks that at least one exception of the the specified type, has been received.
- *
- * @param exceptionClass The type of the exception.
- *
- * @return <tt>true</tt> if at least one exception of the specified type has been received, <tt>false</tt> otherwise.
- */
- public synchronized boolean assertExceptionOfType(Class exceptionClass)
- {
- // Start by assuming that the exception has no been received.
- boolean passed = false;
-
- // Scan all the exceptions for a match.
- for (Exception e : exceptions)
- {
- if (exceptionClass.isInstance(e))
- {
- passed = true;
-
- break;
- }
- }
-
- return passed;
- }
-
- /**
- * Reports the number of exceptions held by this monitor.
- *
- * @return The number of exceptions held by this monitor.
- */
- public synchronized int size()
- {
- return exceptions.size();
- }
-
- /**
- * Clears the record of received exceptions.
- */
- public synchronized void reset()
- {
- exceptions = new ArrayList<Exception>();
- }
-
- /**
- * Provides a dump of the stack traces of all exceptions that this exception monitor was notified of. Mainly
- * use for debugging/test failure reporting purposes.
- *
- * @return A string containing a dump of the stack traces of all exceptions.
- */
- public synchronized String toString()
- {
- String result = "ExceptionMonitor: holds " + exceptions.size() + " exceptions.\n\n";
-
- for (Exception ex : exceptions)
- {
- result += getStackTrace(ex) + "\n";
- }
-
- return result;
- }
-
- /**
- * Prints an exception stack trace into a string.
- *
- * @param t The throwable to get the stack trace from.
- *
- * @return A string containing the throwables stack trace.
- */
- public static String getStackTrace(Throwable t)
- {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw, true);
- t.printStackTrace(pw);
- pw.flush();
- sw.flush();
-
- return sw.toString();
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java b/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
deleted file mode 100644
index ecbb710a6b..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
+++ /dev/null
@@ -1,299 +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.test.framework;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.NDC;
-
-import org.apache.qpid.junit.extensions.SetupTaskAware;
-import org.apache.qpid.junit.extensions.SetupTaskHandler;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.junit.extensions.util.TestContextProperties;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * FrameworkBaseCase provides a starting point for writing test cases against the test framework. Its main purpose is
- * to provide some convenience methods for testing.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Create and clean up in-vm brokers on every test case.
- * <tr><td> Produce lists of assertions from assertion creation calls.
- * <tr><td> Produce JUnit failures from assertion failures.
- * <tr><td> Convert failed assertions to error messages.
- * </table>
- */
-public class FrameworkBaseCase extends QpidBrokerTestCase implements FrameworkTestContext, SetupTaskAware,
- BrokerLifecycleAware
-{
- /** Used for debugging purposes. */
- private static final Logger log = Logger.getLogger(FrameworkBaseCase.class);
-
- private CircuitFactory circuitFactory = new LocalAMQPCircuitFactory();
-
- private ParsedProperties testProps;
-
- private SetupTaskHandler taskHandler = new SetupTaskHandler();
-
- private boolean isUsingInVM;
-
- private CauseFailure failureMechanism = new CauseFailureUserPrompt();
-
- /**
- * Creates a new test case with the specified name.
- *
- * @param name The test case name.
- */
- public FrameworkBaseCase(String name)
- {
- super(name);
- }
-
- /** Holds the test sequencer to create and run test circuits with. */ /**
- * Returns the test case sequencer that provides test circuit, and test sequence implementations. The sequencer
- * that this base case returns by default is suitable for running a test circuit with both circuit ends colocated
- * on the same JVM.
- *
- * @return The test case sequencer.
- */
- protected CircuitFactory getCircuitFactory()
- {
- return circuitFactory;
- }
-
- /**
- * Overrides the default test circuit factory. Test decorators can use this to supply distributed test sequencers or
- * other test circuit factory specializations.
- *
- * @param circuitFactory The new test circuit factory.
- */
- public void setCircuitFactory(CircuitFactory circuitFactory)
- {
- this.circuitFactory = circuitFactory;
- }
-
- /**
- * Reports the current test case name.
- *
- * @return The current test case name.
- */
- public TestCaseVector getTestCaseVector()
- {
- return new TestCaseVector(this.getName(), 0);
- }
-
- /**
- * Reports the current test case parameters.
- *
- * @return The current test case parameters.
- */
- public MessagingTestConfigProperties getTestParameters()
- {
- return new MessagingTestConfigProperties(testProps);
- }
-
- /**
- * Creates a list of assertions.
- *
- * @param asserts The assertions to compile in a list.
- *
- * @return A list of assertions.
- */
- protected List<Assertion> assertionList(Assertion... asserts)
- {
- List<Assertion> result = new ArrayList<Assertion>();
-
- for (Assertion assertion : asserts)
- {
- result.add(assertion);
- }
-
- return result;
- }
-
- /**
- * Generates a JUnit assertion exception (failure) if any assertions are passed into this method, also concatenating
- * all of the error messages in the assertions together to form an error message to diagnose the test failure with.
- *
- * @param asserts The list of failed assertions.
- */
- protected static void assertNoFailures(List<Assertion> asserts)
- {
- log.debug("protected void assertNoFailures(List<Assertion> asserts = " + asserts + "): called");
-
- // Check if there are no assertion failures, and return without doing anything if so.
- if ((asserts == null) || asserts.isEmpty())
- {
- return;
- }
-
- // Compile all of the assertion failure messages together.
- String errorMessage = assertionsToString(asserts);
-
- // Fail with the error message from all of the assertions.
- fail(errorMessage);
- }
-
- /**
- * Converts a list of failed assertions into an error message.
- *
- * @param asserts The failed assertions.
- *
- * @return The error message.
- */
- protected static String assertionsToString(List<Assertion> asserts)
- {
- String errorMessage = "";
-
- for (Assertion assertion : asserts)
- {
- errorMessage += assertion.toString() + "\n";
- }
-
- return errorMessage;
- }
-
- /**
- * Ensures that the in-vm broker is created and initialized.
- *
- * @throws Exception Any exceptions allowed to fall through and fail the test.
- */
- protected void setUp() throws Exception
- {
- super.setUp();
- NDC.push(getName());
-
- testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
- }
-
- /**
- * Ensures that the in-vm broker is cleaned up after each test run.
- */
- protected void tearDown()
- {
- NDC.pop();
-
- // Process all optional tear down tasks. This may include in-vm broker clean up, if a decorator has added it.
- taskHandler.runTearDownTasks();
- }
-
- /**
- * Adds the specified task to the tests setup.
- *
- * @param task The task to add to the tests setup.
- */
- public void chainSetupTask(Runnable task)
- {
- taskHandler.chainSetupTask(task);
- }
-
- /**
- * Adds the specified task to the tests tear down.
- *
- * @param task The task to add to the tests tear down.
- */
- public void chainTearDownTask(Runnable task)
- {
- taskHandler.chainTearDownTask(task);
- }
-
- /**
- * Should provide a translation from the junit method name of a test to its test case name as known to the test
- * clients that will run the test. The purpose of this is to convert the JUnit method name into the correct test
- * case name to place into the test invite. For example the method "testP2P" might map onto the interop test case
- * name "TC2_BasicP2P".
- *
- * @param methodName The name of the JUnit test method.
- *
- * @return The name of the corresponding interop test case.
- */
- public String getTestCaseNameForTestMethod(String methodName)
- {
- return methodName;
- }
-
- public void setInVmBrokers()
- {
- isUsingInVM = true;
- }
-
- /**
- * Indicates whether or not a test case is using in-vm brokers.
- *
- * @return <tt>true</tt> if the test is using in-vm brokers, <tt>false</tt> otherwise.
- */
- public boolean usingInVmBroker()
- {
- return isUsingInVM;
- }
-
- /**
- * Sets the currently live in-vm broker.
- *
- * @param i The currently live in-vm broker.
- */
- public void setLiveBroker(int i)
- { }
-
- /**
- * Reports the currently live in-vm broker.
- *
- * @return The currently live in-vm broker.
- */
- public int getLiveBroker()
- {
- return 0;
- }
-
- /**
- * Accepts a failure mechanism.
- *
- * @param failureMechanism The failure mechanism.
- */
- public void setFailureMechanism(CauseFailure failureMechanism)
- {
- this.failureMechanism = failureMechanism;
- }
-
- protected ParsedProperties getTestProps()
- {
- return testProps;
- }
-
- protected void setTestProps(ParsedProperties testProps)
- {
- this.testProps = testProps;
- }
-
- protected SetupTaskHandler getTaskHandler()
- {
- return taskHandler;
- }
-
- protected CauseFailure getFailureMechanism()
- {
- return failureMechanism;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java b/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java
deleted file mode 100644
index 9a4668e86f..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java
+++ /dev/null
@@ -1,48 +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.test.framework;
-
-/**
- * A FrameworkTestContext provides context information to test code about the current test case being run; its name, its
- * parameters.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide the name of the current test case.
- * <tr><td> Provide the test parameters.
- * </table>
- */
-public interface FrameworkTestContext
-{
- /**
- * Reports the current test case name.
- *
- * @return The current test case name.
- */
- TestCaseVector getTestCaseVector();
-
- /**
- * Reports the current test case parameters.
- *
- * @return The current test case parameters.
- */
- MessagingTestConfigProperties getTestParameters();
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/LocalAMQPCircuitFactory.java b/java/systests/src/main/java/org/apache/qpid/test/framework/LocalAMQPCircuitFactory.java
deleted file mode 100644
index 899a808bdd..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/LocalAMQPCircuitFactory.java
+++ /dev/null
@@ -1,173 +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.test.framework;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.localcircuit.LocalAMQPPublisherImpl;
-import org.apache.qpid.test.framework.localcircuit.LocalPublisherImpl;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-
-/**
- * LocalAMQPCircuitFactory is a test sequencer that creates test circuits with publishing and receiving ends rooted
- * on the same JVM, allowing AMQP/Qpid specific options to be applied to the circuit.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide a standard test procedure over a test circuit.
- * <tr><td> Construct test circuits appropriate to a tests context.
- * <tr><td> Construct test circuits the support AMQP specific options.
- * </table>
- */
-public class LocalAMQPCircuitFactory extends LocalCircuitFactory
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(LocalAMQPCircuitFactory.class);
-
- /**
- * Builds a circuit end suitable for the publishing side of a test circuit, from standard test parameters.
- *
- * @param connection The connection to build the circuit end on.
- * @param testProps The test parameters to configure the circuit end construction.
- * @param uniqueId A unique number to being numbering destinations from, to make this circuit unique.
- *
- * @return A circuit end suitable for the publishing side of a test circuit.
- *
- * @throws javax.jms.JMSException Any underlying JMSExceptions are allowed to fall through and fail the creation.
- */
- public CircuitEndBase createPublisherCircuitEnd(Connection connection, ParsedProperties testProps, long uniqueId)
- throws JMSException
- {
- log.debug(
- "public CircuitEndBase createPublisherCircuitEnd(Connection connection, ParsedProperties testProps, long uniqueId = "
- + uniqueId + "): called");
-
- // Cast the test properties into a typed interface for convenience.
- MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProps);
-
- Session session = connection.createSession(props.getPublisherTransacted(), props.getAckMode());
-
- Destination destination =
- props.getPubsub() ? session.createTopic(props.getSendDestinationNameRoot() + "_" + uniqueId)
- : session.createQueue(props.getSendDestinationNameRoot() + "_" + uniqueId);
-
- MessageProducer producer =
- props.getPublisherProducerBind()
- ? ((props.getImmediate() || props.getMandatory())
- ? ((AMQSession) session).createProducer(destination, props.getMandatory(), props.getImmediate())
- : session.createProducer(destination)) : null;
-
- MessageConsumer consumer =
- props.getPublisherConsumerBind()
- ? session.createConsumer(session.createQueue(props.getReceiveDestinationNameRoot() + "_" + uniqueId)) : null;
-
- MessageMonitor messageMonitor = new MessageMonitor();
-
- if (consumer != null)
- {
- consumer.setMessageListener(messageMonitor);
- }
-
- ExceptionMonitor exceptionMonitor = new ExceptionMonitor();
- connection.setExceptionListener(exceptionMonitor);
-
- if (!props.getPublisherConsumerActive() && (consumer != null))
- {
- consumer.close();
- }
-
- return new CircuitEndBase(producer, consumer, session, messageMonitor, exceptionMonitor);
- }
-
- /**
- * Builds a circuit end suitable for the receiving side of a test circuit, from standard test parameters.
- *
- * @param connection The connection to build the circuit end on.
- * @param testProps The test parameters to configure the circuit end construction.
- * @param uniqueId A unique number to being numbering destinations from, to make this circuit unique.
- *
- * @return A circuit end suitable for the receiving side of a test circuit.
- *
- * @throws JMSException Any underlying JMSExceptions are allowed to fall through and fail the creation.
- */
- public CircuitEndBase createReceiverCircuitEnd(Connection connection, ParsedProperties testProps, long uniqueId)
- throws JMSException
- {
- log.debug(
- "public CircuitEndBase createReceiverCircuitEnd(Connection connection, ParsedProperties testProps, long uniqueId = "
- + uniqueId + "): called");
-
- // Cast the test properties into a typed interface for convenience.
- MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProps);
-
- Session session = connection.createSession(props.getPublisherTransacted(), props.getAckMode());
-
- MessageProducer producer =
- props.getReceiverProducerBind()
- ? session.createProducer(session.createQueue(props.getReceiveDestinationNameRoot() + "_" + uniqueId)) : null;
-
- Destination destination =
- props.getPubsub() ? session.createTopic(props.getSendDestinationNameRoot() + "_" + uniqueId)
- : session.createQueue(props.getSendDestinationNameRoot() + "_" + uniqueId);
-
- MessageConsumer consumer =
- props.getReceiverConsumerBind()
- ? ((props.getDurableSubscription() && props.getPubsub())
- ? session.createDurableSubscriber((Topic) destination, "testsub") : session.createConsumer(destination))
- : null;
-
- MessageMonitor messageMonitor = new MessageMonitor();
-
- if (consumer != null)
- {
- consumer.setMessageListener(messageMonitor);
- }
-
- if (!props.getReceiverConsumerActive() && (consumer != null))
- {
- consumer.close();
- }
-
- return new CircuitEndBase(producer, consumer, session, messageMonitor, null);
- }
-
- /**
- * Creates a local {@link Publisher} from a {@link CircuitEnd}. The publisher implementation provides AMQP
- * specific assertion methods, for testing beyond JMS.
- *
- * @param publisherEnd The publishing circuit end.
- *
- * @return A {@link Receiver}.
- */
- protected LocalPublisherImpl createPublisherFromCircuitEnd(CircuitEndBase publisherEnd)
- {
- return new LocalAMQPPublisherImpl(publisherEnd);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java b/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
deleted file mode 100644
index b8fd4cc7e7..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
+++ /dev/null
@@ -1,320 +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.test.framework;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.localcircuit.LocalCircuitImpl;
-import org.apache.qpid.test.framework.localcircuit.LocalPublisherImpl;
-import org.apache.qpid.test.framework.localcircuit.LocalReceiverImpl;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * LocalCircuitFactory is a circuit factory that creates test circuits with publishing and receiving ends rooted
- * on the same JVM. The ends of the circuit are presented as {@link Publisher} and {@link Receiver} interfaces, which
- * in turn provide methods to apply assertions to the circuit. The creation of the circuit ends, and the presentation
- * of the ends as publisher/receiver interfaces, are designed to be overriden, so that circuits and assertions that
- * use messaging features not available in JMS can be written. This provides an extension point for writing tests
- * against proprietary features of JMS implementations.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide a standard test procedure over a test circuit.
- * <tr><td> Construct test circuits appropriate to a tests context.
- * </table>
- */
-public class LocalCircuitFactory implements CircuitFactory
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(LocalCircuitFactory.class);
-
- /** Used to create unique destination names for each test. */
- protected static AtomicLong uniqueDestsId = new AtomicLong();
-
- /**
- * Holds a test coordinating conversation with the test clients. This should consist of assigning the test roles,
- * begining the test and gathering the test reports from the participants.
- *
- * @param testCircuit The test circuit.
- * @param assertions The list of assertions to apply to the test circuit.
- * @param testProperties The test case definition.
- */
- public void sequenceTest(Circuit testCircuit, List<Assertion> assertions, Properties testProperties)
- {
- if (testCircuit != null)
- {
- FrameworkBaseCase.assertNoFailures(testCircuit.test(1, assertions));
- }
- }
-
- /**
- * Creates a test circuit for the test, configered by the test parameters specified.
- *
- * @param testProperties The test parameters.
- *
- * @return A test circuit.
- */
- public Circuit createCircuit(Connection connection, ParsedProperties testProperties)
- {
- Circuit result;
-
- // Cast the test properties into a typed interface for convenience.
- MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProperties);
-
- // Create a standard publisher/receivers test client pair on a shared connection, individual sessions.
- try
- {
- // Get a unique offset to append to destination names to make them unique to the connection.
- long uniqueId = uniqueDestsId.incrementAndGet();
-
- // Add the connection exception listener to assert on exception conditions with.
- // ExceptionMonitor exceptionMonitor = new ExceptionMonitor();
- // connection.setExceptionListener(exceptionMonitor);
-
- // Set up the publisher.
- CircuitEndBase publisherEnd = createPublisherCircuitEnd(connection, props, uniqueId);
-
- // Set up the receiver.
- CircuitEndBase receiverEnd = createReceiverCircuitEnd(connection, props, uniqueId);
-
- // Start listening for incoming messages.
- connection.start();
-
- // Package everything up.
- LocalPublisherImpl publisher = createPublisherFromCircuitEnd(publisherEnd);
- LocalReceiverImpl receiver = createReceiverFromCircuitEnd(receiverEnd);
-
- result = new LocalCircuitImpl(testProperties, publisher, receiver, connection, publisher.getExceptionMonitor());
- }
- catch (JMSException e)
- {
- throw new RuntimeException("Could not create publisher/receivers pair due to a JMSException.", e);
- }
-
- return result;
- }
-
- /**
- * Creates a local {@link Receiver} from a {@link CircuitEnd}. Sub-classes may override this to provide more
- * specialized receivers if necessary.
- *
- * @param receiverEnd The receiving circuit end.
- *
- * @return A {@link Receiver}.
- */
- protected LocalReceiverImpl createReceiverFromCircuitEnd(CircuitEndBase receiverEnd)
- {
- return new LocalReceiverImpl(receiverEnd);
- }
-
- /**
- * Creates a local {@link Publisher} from a {@link CircuitEnd}. Sub-classes may override this to provide more
- * specialized receivers if necessary.
- *
- * @param publisherEnd The publishing circuit end.
- *
- * @return A {@link Receiver}.
- */
- protected LocalPublisherImpl createPublisherFromCircuitEnd(CircuitEndBase publisherEnd)
- {
- return new LocalPublisherImpl(publisherEnd);
- }
-
- /**
- * Builds a circuit end suitable for the publishing side of a test circuit, from standard test parameters.
- *
- * @param connection The connection to build the circuit end on.
- * @param testProps The test parameters to configure the circuit end construction.
- * @param uniqueId A unique number to being numbering destinations from, to make this circuit unique.
- *
- * @return A circuit end suitable for the publishing side of a test circuit.
- *
- * @throws JMSException Any underlying JMSExceptions are allowed to fall through and fail the creation.
- */
- public CircuitEndBase createPublisherCircuitEnd(Connection connection, ParsedProperties testProps, long uniqueId)
- throws JMSException
- {
- log.debug(
- "public CircuitEndBase createPublisherCircuitEnd(Connection connection, ParsedProperties testProps, long uniqueId = "
- + uniqueId + "): called");
-
- // Cast the test properties into a typed interface for convenience.
- MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProps);
-
- // Check that the test properties do not contain AMQP/Qpid specific settings, and fail if they do.
- if (props.getImmediate() || props.getMandatory())
- {
- throw new RuntimeException(
- "Cannot create a pure JMS circuit as the test properties require AMQP specific options.");
- }
-
- Session session = connection.createSession(props.getPublisherTransacted(), props.getAckMode());
-
- Destination destination =
- props.getPubsub() ? session.createTopic(props.getSendDestinationNameRoot() + "_" + uniqueId)
- : session.createQueue(props.getSendDestinationNameRoot() + "_" + uniqueId);
-
- MessageProducer producer = props.getPublisherProducerBind() ? session.createProducer(destination) : null;
-
- MessageConsumer consumer =
- props.getPublisherConsumerBind()
- ? session.createConsumer(session.createQueue(props.getReceiveDestinationNameRoot() + "_" + uniqueId)) : null;
-
- MessageMonitor messageMonitor = new MessageMonitor();
-
- if (consumer != null)
- {
- consumer.setMessageListener(messageMonitor);
- }
-
- ExceptionMonitor exceptionMonitor = new ExceptionMonitor();
- connection.setExceptionListener(exceptionMonitor);
-
- if (!props.getPublisherConsumerActive() && (consumer != null))
- {
- consumer.close();
- }
-
- return new CircuitEndBase(producer, consumer, session, messageMonitor, exceptionMonitor);
- }
-
- /**
- * Builds a circuit end suitable for the receiving side of a test circuit, from standard test parameters.
- *
- * @param connection The connection to build the circuit end on.
- * @param testProps The test parameters to configure the circuit end construction.
- * @param uniqueId A unique number to being numbering destinations from, to make this circuit unique.
- *
- * @return A circuit end suitable for the receiving side of a test circuit.
- *
- * @throws JMSException Any underlying JMSExceptions are allowed to fall through and fail the creation.
- */
- public CircuitEndBase createReceiverCircuitEnd(Connection connection, ParsedProperties testProps, long uniqueId)
- throws JMSException
- {
- log.debug(
- "public CircuitEndBase createReceiverCircuitEnd(Connection connection, ParsedProperties testProps, long uniqueId = "
- + uniqueId + "): called");
-
- // Cast the test properties into a typed interface for convenience.
- MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProps);
-
- // Check that the test properties do not contain AMQP/Qpid specific settings, and fail if they do.
- if (props.getImmediate() || props.getMandatory())
- {
- throw new RuntimeException(
- "Cannot create a pure JMS circuit as the test properties require AMQP specific options.");
- }
-
- Session session = connection.createSession(props.getPublisherTransacted(), props.getAckMode());
-
- MessageProducer producer =
- props.getReceiverProducerBind()
- ? session.createProducer(session.createQueue(props.getReceiveDestinationNameRoot() + "_" + uniqueId)) : null;
-
- Destination destination =
- props.getPubsub() ? session.createTopic(props.getSendDestinationNameRoot() + "_" + uniqueId)
- : session.createQueue(props.getSendDestinationNameRoot() + "_" + uniqueId);
-
- MessageConsumer consumer =
- props.getReceiverConsumerBind()
- ? ((props.getDurableSubscription() && props.getPubsub())
- ? session.createDurableSubscriber((Topic) destination, "testsub") : session.createConsumer(destination))
- : null;
-
- MessageMonitor messageMonitor = new MessageMonitor();
-
- if (consumer != null)
- {
- consumer.setMessageListener(messageMonitor);
- }
-
- if (!props.getReceiverConsumerActive() && (consumer != null))
- {
- consumer.close();
- }
-
- return new CircuitEndBase(producer, consumer, session, messageMonitor, null);
- }
-
- /**
- * Sets the sender test client to coordinate the test with.
- *
- * @param sender The contact details of the sending client in the test.
- */
- public void setSender(TestClientDetails sender)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Sets the receiving test client to coordinate the test with.
- *
- * @param receiver The contact details of the sending client in the test.
- */
- public void setReceiver(TestClientDetails receiver)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Supplies the sending test client.
- *
- * @return The sending test client.
- */
- public TestClientDetails getSender()
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Supplies the receiving test client.
- *
- * @return The receiving test client.
- */
- public List<TestClientDetails> getReceivers()
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Accepts the conversation factory over which to hold the test coordinating conversation.
- *
- * @param conversationFactory The conversation factory to coordinate the test over.
- */
- public void setConversationFactory(ConversationFactory conversationFactory)
- {
- throw new RuntimeException("Not implemented.");
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java b/java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java
deleted file mode 100644
index 397c4e9fbd..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java
+++ /dev/null
@@ -1,167 +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.test.framework;
-
-/**
- * MessageIdentityVector provides a message identification scheme, that matches individual messages with test cases.
- * Test messages are being sent by a number of test clients, sending messages over a set of routes, and being received
- * by another set of test clients. Each test is itself, being run within a test cycle, of which there could be many. It
- * is the job of the test coordinator to request and receive reports from the available test clients, on what has been
- * sent, what has been received, and what errors may have occurred, and to reconcile this information against the
- * assertions being applied by the test case. In order to be able to figure out which messages belong to which test,
- * there needs to be an identification scheme, that the coordinator can use to correlate messages in senders and
- * receiver reports. Every message sent in a test can be associated with this information.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Identify a test case, a handling client id, a circuit end within the client, and a test cycle number.
- * </table>
- */
-public class MessageIdentityVector
-{
- /** Holds the test case vector component of the message identity vector. */
- private TestCaseVector testCaseVector;
-
- /** The unique client id. */
- private String clientId;
-
- /** The unique circuit end number within the client id. */
- private int circuitEndId;
-
- /**
- * Creates a new identity vector for test messages.
- *
- * @param testCase The name of the test case generating the messages.
- * @param clientId The unique id of the client implementing a circuit end that is handling the messages.
- * @param circuitEndId The unique id number of the circuit end within the client.
- * @param testCycleNumber The cycle iteration number of the test case.
- */
- public MessageIdentityVector(String testCase, String clientId, int circuitEndId, int testCycleNumber)
- {
- this.testCaseVector = new TestCaseVector(testCase, testCycleNumber);
- this.clientId = clientId;
- this.circuitEndId = circuitEndId;
- }
-
- /**
- * Reports the test case vector component of the message identity vector.
- *
- * @return The test case vector component of the message identity vector.
- */
- public TestCaseVector getTestCaseVector()
- {
- return testCaseVector;
- }
-
- /**
- * Reports the name of the test case.
- *
- * @return The name of the test case.
- */
- public String getTestCase()
- {
- return testCaseVector.getTestCase();
- }
-
- /**
- * Reports the test iteration cycle number within the test case.
- *
- * @return The test iteration cycle number within the test case.
- */
- public int getTestCycleNumber()
- {
- return testCaseVector.getTestCycleNumber();
- }
-
- /**
- * Resports the client id.
- *
- * @return The client id.
- */
- public String getClientId()
- {
- return clientId;
- }
-
- /**
- * Reports the circuit end number within the test client.
- *
- * @return The circuit end number within the test client.
- */
- public int getCircuitEndId()
- {
- return circuitEndId;
- }
-
- /**
- * Compares this identity vector with another for equality. All fields must match.
- *
- * @param o The identity vector to compare with.
- *
- * @return <tt>true</tt> if the identity vector is identical to this one by all fields, <tt>false</tt> otherwise.
- */
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
-
- if ((o == null) || (getClass() != o.getClass()))
- {
- return false;
- }
-
- MessageIdentityVector that = (MessageIdentityVector) o;
-
- if (circuitEndId != that.circuitEndId)
- {
- return false;
- }
-
- if ((clientId != null) ? (!clientId.equals(that.clientId)) : (that.clientId != null))
- {
- return false;
- }
-
- if ((testCaseVector != null) ? (!testCaseVector.equals(that.testCaseVector)) : (that.testCaseVector != null))
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * Computes a hash code for this identity vector based on all fields.
- *
- * @return A hash code for this identity vector based on all fields.
- */
- public int hashCode()
- {
- int result;
- result = ((testCaseVector != null) ? testCaseVector.hashCode() : 0);
- result = (31 * result) + ((clientId != null) ? clientId.hashCode() : 0);
- result = (31 * result) + circuitEndId;
-
- return result;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java b/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java
deleted file mode 100644
index 5265c0416f..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java
+++ /dev/null
@@ -1,104 +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.test.framework;
-
-import org.apache.log4j.Logger;
-
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * MessageMonitor is used to record information about messages received. This will provide methods to check various
- * properties, such as the type, number and content of messages received in order to verify the correct behaviour of
- * tests.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Count incoming messages.
- * <tr><td> Record time ellapsed since the arrival of the first message.
- * <tr><td> Reset all counts and timings.
- * </table>
- */
-public class MessageMonitor implements MessageListener
-{
- /** Used for debugging. */
- private final Logger log = Logger.getLogger(MessageMonitor.class);
-
- /** Holds the count of messages received since the last query. */
- protected AtomicInteger numMessages = new AtomicInteger();
-
- /** Holds the time of arrival of the first message. */
- protected Long firstMessageTime = null;
-
- /**
- * Handles received messages. Does Nothing.
- *
- * @param message The message. Ignored.
- */
- public void onMessage(Message message)
- {
- // log.debug("public void onMessage(Message message): called");
-
- numMessages.getAndIncrement();
- }
-
- /**
- * Gets the count of messages.
- *
- * @return The count of messages.
- */
- public int getNumMessage()
- {
- if (firstMessageTime == null)
- {
- firstMessageTime = System.nanoTime();
- }
-
- return numMessages.get();
- }
-
- /**
- * Gets the time elapsed since the first message arrived, in nanos, or zero if no messages have arrived yet.
- *
- * @return The time elapsed since the first message arrived, in nanos, or zero if no messages have arrived yet.
- */
- public long getTime()
- {
- if (firstMessageTime != null)
- {
- return System.nanoTime() - firstMessageTime;
- }
- else
- {
- return 0L;
- }
- }
-
- /**
- * Resets the message count and timer to zero.
- */
- public void reset()
- {
- numMessages.set(0);
- firstMessageTime = null;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/MessagingTestConfigProperties.java b/java/systests/src/main/java/org/apache/qpid/test/framework/MessagingTestConfigProperties.java
deleted file mode 100644
index ceece2dae2..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/MessagingTestConfigProperties.java
+++ /dev/null
@@ -1,684 +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.test.framework;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-import javax.jms.Session;
-import java.util.Properties;
-
-/**
- * MessagingTestConfigProperties defines a set of property names and default values for specifying a messaging topology,
- * and test parameters for running a messaging test over that topology. A Properties object holding some of these
- * properties, superimposed onto the defaults, is used to establish test topologies and control test behaviour.
- *
- * <p/>A complete list of the parameters, default values and comments on their usage is provided here:
- *
- * <p/><table><caption>Parameters</caption>
- * <tr><th> Parameter <th> Default <th> Comments
- * <tr><td> messageSize <td> 0 <td> Message size in bytes. Not including any headers.
- * <tr><td> destinationName <td> ping <td> The root name to use to generate destination names to ping.
- * <tr><td> persistent <td> false <td> Determines whether peristent delivery is used.
- * <tr><td> transacted <td> false <td> Determines whether messages are sent/received in transactions.
- * <tr><td> broker <td> tcp://localhost:5672 <td> Determines the broker to connect to.
- * <tr><td> virtualHost <td> test <td> Determines the virtual host to send all ping over.
- * <tr><td> rate <td> 0 <td> The maximum rate (in hertz) to send messages at. 0 means no limit.
- * <tr><td> verbose <td> false <td> The verbose flag for debugging. Prints to console on every message.
- * <tr><td> pubsub <td> false <td> Whether to ping topics or queues. Uses p2p by default.
- * <tr><td> username <td> guest <td> The username to access the broker with.
- * <tr><td> password <td> guest <td> The password to access the broker with.
- * <tr><td> selector <td> null <td> Not used. Defines a message selector to filter pings with.
- * <tr><td> destinationCount <td> 1 <td> The number of receivers listening to the pings.
- * <tr><td> timeout <td> 30000 <td> In milliseconds. The timeout to stop waiting for replies.
- * <tr><td> commitBatchSize <td> 1 <td> The number of messages per transaction in transactional mode.
- * <tr><td> uniqueDests <td> true <td> Whether each receivers only listens to one ping destination or all.
- * <tr><td> durableDests <td> false <td> Whether or not durable destinations are used.
- * <tr><td> ackMode <td> AUTO_ACK <td> The message acknowledgement mode. Possible values are:
- * 0 - SESSION_TRANSACTED
- * 1 - AUTO_ACKNOWLEDGE
- * 2 - CLIENT_ACKNOWLEDGE
- * 3 - DUPS_OK_ACKNOWLEDGE
- * 257 - NO_ACKNOWLEDGE
- * 258 - PRE_ACKNOWLEDGE
- * <tr><td> maxPending <td> 0 <td> The maximum size in bytes, of messages sent but not yet received.
- * Limits the volume of messages currently buffered on the client
- * or broker. Can help scale test clients by limiting amount of buffered
- * data to avoid out of memory errors.
- * </table>
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide the names and defaults of all test parameters.
- * </table>
- *
- * @todo Put a type-safe wrapper around these properties, but continue to store the parameters as properties. This is
- * simply to ensure that it is a simple matter to serialize/deserialize string/string pairs onto messages.
- */
-public class MessagingTestConfigProperties extends ParsedProperties
-{
- // ====================== Connection Properties ==================================
-
- /** Holds the name of the default connection configuration. */
- public static final String CONNECTION_NAME = "broker";
-
- /** Holds the name of the property to get the initial context factory name from. */
- public static final String INITIAL_CONTEXT_FACTORY_PROPNAME = "java.naming.factory.initial";
-
- /** Defines the class to use as the initial context factory by default. */
- public static final String INITIAL_CONTEXT_FACTORY_DEFAULT = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
-
- /** Holds the name of the property to get the test broker url from. */
- public static final String BROKER_PROPNAME = "qpid.test.broker";
-
- /** Holds the default broker url for the test. */
- public static final String BROKER_DEFAULT = "vm://:1";
-
- /** Holds the name of the property to get the test broker virtual path. */
- public static final String VIRTUAL_HOST_PROPNAME = "virtualHost";
-
- /** Holds the default virtual path for the test. */
- public static final String VIRTUAL_HOST_DEFAULT = "test";
-
- /** Holds the name of the property to get the broker access username from. */
- public static final String USERNAME_PROPNAME = "username";
-
- /** Holds the default broker log on username. */
- public static final String USERNAME_DEFAULT = "guest";
-
- /** Holds the name of the property to get the broker access password from. */
- public static final String PASSWORD_PROPNAME = "password";
-
- /** Holds the default broker log on password. */
- public static final String PASSWORD_DEFAULT = "guest";
-
- // ====================== Messaging Topology Properties ==========================
-
- /** Holds the name of the property to get the bind publisher procuder flag from. */
- public static final String PUBLISHER_PRODUCER_BIND_PROPNAME = "publisherProducerBind";
-
- /** Holds the default value of the publisher producer flag. */
- public static final boolean PUBLISHER_PRODUCER_BIND_DEFAULT = true;
-
- /** Holds the name of the property to get the bind publisher procuder flag from. */
- public static final String PUBLISHER_CONSUMER_BIND_PROPNAME = "publisherConsumerBind";
-
- /** Holds the default value of the publisher consumer flag. */
- public static final boolean PUBLISHER_CONSUMER_BIND_DEFAULT = false;
-
- /** Holds the name of the property to get the bind receivers procuder flag from. */
- public static final String RECEIVER_PRODUCER_BIND_PROPNAME = "receiverProducerBind";
-
- /** Holds the default value of the receivers producer flag. */
- public static final boolean RECEIVER_PRODUCER_BIND_DEFAULT = false;
-
- /** Holds the name of the property to get the bind receivers procuder flag from. */
- public static final String RECEIVER_CONSUMER_BIND_PROPNAME = "receiverConsumerBind";
-
- /** Holds the default value of the receivers consumer flag. */
- public static final boolean RECEIVER_CONSUMER_BIND_DEFAULT = true;
-
- /** Holds the name of the property to get the publishers consumer active flag from. */
- public static final String PUBLISHER_CONSUMER_ACTIVE_PROPNAME = "publisherConsumerActive";
-
- /** Holds the default value of the publishers consumer active flag. */
- public static final boolean PUBLISHER_CONSUMER_ACTIVE_DEFAULT = true;
-
- /** Holds the name of the property to get the receivers consumer active flag from. */
- public static final String RECEIVER_CONSUMER_ACTIVE_PROPNAME = "receiverConsumerActive";
-
- /** Holds the default value of the receivers consumer active flag. */
- public static final boolean RECEIVER_CONSUMER_ACTIVE_DEFAULT = true;
-
- /** Holds the name of the property to get the destination name root from. */
- public static final String SEND_DESTINATION_NAME_ROOT_PROPNAME = "sendDestinationRoot";
-
- /** Holds the root of the name of the default destination to send to. */
- public static final String SEND_DESTINATION_NAME_ROOT_DEFAULT = "sendTo";
-
- /** Holds the name of the property to get the destination name root from. */
- public static final String RECEIVE_DESTINATION_NAME_ROOT_PROPNAME = "receiveDestinationRoot";
-
- /** Holds the root of the name of the default destination to send to. */
- public static final String RECEIVE_DESTINATION_NAME_ROOT_DEFAULT = "receiveFrom";
-
- /** Holds the name of the proeprty to get the destination count from. */
- public static final String DESTINATION_COUNT_PROPNAME = "destinationCount";
-
- /** Defines the default number of destinations to ping. */
- public static final int DESTINATION_COUNT_DEFAULT = 1;
-
- /** Holds the name of the property to get the p2p or pub/sub messaging mode from. */
- public static final String PUBSUB_PROPNAME = "pubsub";
-
- /** Holds the pub/sub mode default, true means ping a topic, false means ping a queue. */
- public static final boolean PUBSUB_DEFAULT = false;
-
- // ====================== JMS Options and Flags =================================
-
- /** Holds the name of the property to get the test delivery mode from. */
- public static final String PERSISTENT_MODE_PROPNAME = "persistent";
-
- /** Holds the message delivery mode to use for the test. */
- public static final boolean PERSISTENT_MODE_DEFAULT = false;
-
- /** Holds the name of the property to get the test transactional mode from. */
- public static final String TRANSACTED_PUBLISHER_PROPNAME = "transactedPublisher";
-
- /** Holds the transactional mode to use for the test. */
- public static final boolean TRANSACTED_PUBLISHER_DEFAULT = false;
-
- /** Holds the name of the property to get the test transactional mode from. */
- public static final String TRANSACTED_RECEIVER_PROPNAME = "transactedReceiver";
-
- /** Holds the transactional mode to use for the test. */
- public static final boolean TRANSACTED_RECEIVER_DEFAULT = false;
-
- /** Holds the name of the property to set the no local flag from. */
- public static final String NO_LOCAL_PROPNAME = "noLocal";
-
- /** Defines the default value of the no local flag to use when consuming messages. */
- public static final boolean NO_LOCAL_DEFAULT = false;
-
- /** Holds the name of the property to get the message acknowledgement mode from. */
- public static final String ACK_MODE_PROPNAME = "ackMode";
-
- /** Defines the default message acknowledgement mode. */
- public static final int ACK_MODE_DEFAULT = Session.AUTO_ACKNOWLEDGE;
-
- /** Holds the name of the property to get the durable subscriptions flag from, when doing pub/sub messaging. */
- public static final String DURABLE_SUBSCRIPTION_PROPNAME = "durableSubscription";
-
- /** Defines the default value of the durable subscriptions flag. */
- public static final boolean DURABLE_SUBSCRIPTION_DEFAULT = false;
-
- // ====================== Qpid/AMQP Options and Flags ================================
-
- /** Holds the name of the property to set the exclusive flag from. */
- public static final String EXCLUSIVE_PROPNAME = "exclusive";
-
- /** Defines the default value of the exclusive flag to use when consuming messages. */
- public static final boolean EXCLUSIVE_DEFAULT = false;
-
- /** Holds the name of the property to set the immediate flag from. */
- public static final String IMMEDIATE_PROPNAME = "immediate";
-
- /** Defines the default value of the immediate flag to use when sending messages. */
- public static final boolean IMMEDIATE_DEFAULT = false;
-
- /** Holds the name of the property to set the mandatory flag from. */
- public static final String MANDATORY_PROPNAME = "mandatory";
-
- /** Defines the default value of the mandatory flag to use when sending messages. */
- public static final boolean MANDATORY_DEFAULT = false;
-
- /** Holds the name of the property to get the durable destinations flag from. */
- public static final String DURABLE_DESTS_PROPNAME = "durableDests";
-
- /** Default value for the durable destinations flag. */
- public static final boolean DURABLE_DESTS_DEFAULT = false;
-
- /** Holds the name of the property to set the prefetch size from. */
- public static final String PREFETCH_PROPNAME = "prefetch";
-
- /** Defines the default prefetch size to use when consuming messages. */
- public static final int PREFETCH_DEFAULT = 100;
-
- // ====================== Common Test Parameters ================================
-
- /** Holds the name of the property to get the test message size from. */
- public static final String MESSAGE_SIZE_PROPNAME = "messageSize";
-
- /** Used to set up a default message size. */
- public static final int MESSAGE_SIZE_DEAFULT = 0;
-
- /** Holds the name of the property to get the message rate from. */
- public static final String RATE_PROPNAME = "rate";
-
- /** Defines the default rate (in pings per second) to send pings at. 0 means as fast as possible, no restriction. */
- public static final int RATE_DEFAULT = 0;
-
- /** Holds the name of the proeprty to get the. */
- public static final String SELECTOR_PROPNAME = "selector";
-
- /** Holds the default message selector. */
- public static final String SELECTOR_DEFAULT = "";
-
- /** Holds the name of the property to get the waiting timeout for response messages. */
- public static final String TIMEOUT_PROPNAME = "timeout";
-
- /** Default time to wait before assuming that a ping has timed out. */
- public static final long TIMEOUT_DEFAULT = 30000;
-
- /** Holds the name of the property to get the commit batch size from. */
- public static final String TX_BATCH_SIZE_PROPNAME = "commitBatchSize";
-
- /** Defines the default number of pings to send in each transaction when running transactionally. */
- public static final int TX_BATCH_SIZE_DEFAULT = 1;
-
- /** Holds the name of the property to set the maximum amount of pending message data for a producer to hold. */
- public static final String MAX_PENDING_PROPNAME = "maxPending";
-
- /** Defines the default maximum quantity of pending message data to allow producers to hold. */
- public static final int MAX_PENDING_DEFAULT = 0;
-
- /** Holds the name of the property to get the publisher rollback flag from. */
- public static final String ROLLBACK_PUBLISHER_PROPNAME = "rollbackPublisher";
-
- /** Holds the default publisher roll back setting. */
- public static final boolean ROLLBACK_PUBLISHER_DEFAULT = false;
-
- /** Holds the name of the property to get the publisher rollback flag from. */
- public static final String ROLLBACK_RECEIVER_PROPNAME = "rollbackReceiver";
-
- /** Holds the default publisher roll back setting. */
- public static final boolean ROLLBACK_RECEIVER_DEFAULT = false;
-
- // ====================== Options that control the bahviour of the test framework. =========================
-
- /** Holds the name of the property to get the behavioural mode of not applicable assertions. */
- public static final String NOT_APPLICABLE_ASSERTION_PROPNAME = "notApplicableAssertion";
-
- /** Holds the default behavioral mode of not applicable assertions, which is logging them as a warning. */
- public static final String NOT_APPLICABLE_ASSERTION_DEFAULT = "warn";
-
- /** Holds the name of the property to get the verbose mode proeprty from. */
- public static final String VERBOSE_PROPNAME = "verbose";
-
- /** Holds the default verbose mode. */
- public static final boolean VERBOSE_DEFAULT = false;
-
- /** Holds the default configuration properties. */
- public static ParsedProperties defaults = new ParsedProperties();
-
- static
- {
- defaults.setPropertyIfNull(INITIAL_CONTEXT_FACTORY_PROPNAME, INITIAL_CONTEXT_FACTORY_DEFAULT);
- defaults.setPropertyIfNull(BROKER_PROPNAME, BROKER_DEFAULT);
- defaults.setPropertyIfNull(VIRTUAL_HOST_PROPNAME, VIRTUAL_HOST_DEFAULT);
- defaults.setPropertyIfNull(USERNAME_PROPNAME, USERNAME_DEFAULT);
- defaults.setPropertyIfNull(PASSWORD_PROPNAME, PASSWORD_DEFAULT);
-
- defaults.setPropertyIfNull(PUBLISHER_PRODUCER_BIND_PROPNAME, PUBLISHER_PRODUCER_BIND_DEFAULT);
- defaults.setPropertyIfNull(PUBLISHER_CONSUMER_BIND_PROPNAME, PUBLISHER_CONSUMER_BIND_DEFAULT);
- defaults.setPropertyIfNull(RECEIVER_PRODUCER_BIND_PROPNAME, RECEIVER_PRODUCER_BIND_DEFAULT);
- defaults.setPropertyIfNull(RECEIVER_CONSUMER_BIND_PROPNAME, RECEIVER_CONSUMER_BIND_DEFAULT);
- defaults.setPropertyIfNull(PUBLISHER_CONSUMER_ACTIVE_PROPNAME, PUBLISHER_CONSUMER_ACTIVE_DEFAULT);
- defaults.setPropertyIfNull(RECEIVER_CONSUMER_ACTIVE_PROPNAME, RECEIVER_CONSUMER_ACTIVE_DEFAULT);
- defaults.setPropertyIfNull(SEND_DESTINATION_NAME_ROOT_PROPNAME, SEND_DESTINATION_NAME_ROOT_DEFAULT);
- defaults.setPropertyIfNull(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME, RECEIVE_DESTINATION_NAME_ROOT_DEFAULT);
- defaults.setPropertyIfNull(DESTINATION_COUNT_PROPNAME, DESTINATION_COUNT_DEFAULT);
- defaults.setPropertyIfNull(PUBSUB_PROPNAME, PUBSUB_DEFAULT);
-
- defaults.setPropertyIfNull(PERSISTENT_MODE_PROPNAME, PERSISTENT_MODE_DEFAULT);
- defaults.setPropertyIfNull(TRANSACTED_PUBLISHER_PROPNAME, TRANSACTED_PUBLISHER_DEFAULT);
- defaults.setPropertyIfNull(TRANSACTED_RECEIVER_PROPNAME, TRANSACTED_RECEIVER_DEFAULT);
- defaults.setPropertyIfNull(NO_LOCAL_PROPNAME, NO_LOCAL_DEFAULT);
- defaults.setPropertyIfNull(ACK_MODE_PROPNAME, ACK_MODE_DEFAULT);
- defaults.setPropertyIfNull(DURABLE_SUBSCRIPTION_PROPNAME, DURABLE_SUBSCRIPTION_DEFAULT);
-
- defaults.setPropertyIfNull(EXCLUSIVE_PROPNAME, EXCLUSIVE_DEFAULT);
- defaults.setPropertyIfNull(IMMEDIATE_PROPNAME, IMMEDIATE_DEFAULT);
- defaults.setPropertyIfNull(MANDATORY_PROPNAME, MANDATORY_DEFAULT);
- defaults.setPropertyIfNull(DURABLE_DESTS_PROPNAME, DURABLE_DESTS_DEFAULT);
- defaults.setPropertyIfNull(PREFETCH_PROPNAME, PREFETCH_DEFAULT);
-
- defaults.setPropertyIfNull(MESSAGE_SIZE_PROPNAME, MESSAGE_SIZE_DEAFULT);
- defaults.setPropertyIfNull(RATE_PROPNAME, RATE_DEFAULT);
- defaults.setPropertyIfNull(SELECTOR_PROPNAME, SELECTOR_DEFAULT);
- defaults.setPropertyIfNull(TIMEOUT_PROPNAME, TIMEOUT_DEFAULT);
- defaults.setPropertyIfNull(TX_BATCH_SIZE_PROPNAME, TX_BATCH_SIZE_DEFAULT);
- defaults.setPropertyIfNull(MAX_PENDING_PROPNAME, MAX_PENDING_DEFAULT);
- defaults.setPropertyIfNull(ROLLBACK_PUBLISHER_PROPNAME, ROLLBACK_PUBLISHER_DEFAULT);
- defaults.setPropertyIfNull(ROLLBACK_RECEIVER_PROPNAME, ROLLBACK_RECEIVER_DEFAULT);
-
- defaults.setPropertyIfNull(NOT_APPLICABLE_ASSERTION_PROPNAME, NOT_APPLICABLE_ASSERTION_DEFAULT);
- defaults.setPropertyIfNull(VERBOSE_PROPNAME, VERBOSE_DEFAULT);
- }
-
- /**
- * Creates a test configuration based on the defaults.
- */
- public MessagingTestConfigProperties()
- {
- super(defaults);
- }
-
- /**
- * Creates a test configuration based on the supplied properties.
- *
- * @param properties The test configuration.
- */
- public MessagingTestConfigProperties(Properties properties)
- {
- super(properties);
- }
-
- /**
- * The size of test messages to send.
- *
- * @return The size of test messages to send.
- */
- public int getMessageSize()
- {
- return getPropertyAsInteger(MESSAGE_SIZE_PROPNAME);
- }
-
- /**
- * Flag to indicate that the publishing producer should be set up to publish to a destination.
- *
- * @return Flag to indicate that the publishing producer should be set up to publish to a destination.
- */
- public boolean getPublisherProducerBind()
- {
- return getPropertyAsBoolean(PUBLISHER_PRODUCER_BIND_PROPNAME);
- }
-
- /**
- * Flag to indicate that the publishing consumer should be set up to receive from a destination.
- *
- * @return Flag to indicate that the publishing consumer should be set up to receive from a destination.
- */
- public boolean getPublisherConsumerBind()
- {
- return getPropertyAsBoolean(PUBLISHER_CONSUMER_BIND_PROPNAME);
- }
-
- /**
- * Flag to indicate that the receiving producer should be set up to publish to a destination.
- *
- * @return Flag to indicate that the receiving producer should be set up to publish to a destination.
- */
- public boolean getReceiverProducerBind()
- {
- return getPropertyAsBoolean(RECEIVER_PRODUCER_BIND_PROPNAME);
- }
-
- /**
- * Flag to indicate that the receiving consumer should be set up to receive from a destination.
- *
- * @return Flag to indicate that the receiving consumer should be set up to receive from a destination.
- */
- public boolean getReceiverConsumerBind()
- {
- return getPropertyAsBoolean(RECEIVER_CONSUMER_BIND_PROPNAME);
- }
-
- /**
- * Flag to indicate that the publishing consumer should be created and actively listening.
- *
- * @return Flag to indicate that the publishing consumer should be created.
- */
- public boolean getPublisherConsumerActive()
- {
- return getPropertyAsBoolean(PUBLISHER_CONSUMER_ACTIVE_PROPNAME);
- }
-
- /**
- * Flag to indicate that the receiving consumers should be created and actively listening.
- *
- * @return Flag to indicate that the receiving consumers should be created and actively listening.
- */
- public boolean getReceiverConsumerActive()
- {
- return getPropertyAsBoolean(RECEIVER_CONSUMER_ACTIVE_PROPNAME);
- }
-
- /**
- * A root to create all test destination names from.
- *
- * @return A root to create all test destination names from.
- */
- public String getSendDestinationNameRoot()
- {
- return getProperty(SEND_DESTINATION_NAME_ROOT_PROPNAME);
- }
-
- /**
- * A root to create all receiving destination names from.
- *
- * @return A root to create all receiving destination names from.
- */
- public String getReceiveDestinationNameRoot()
- {
- return getProperty(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME);
- }
-
- /**
- * Flag to indicate that persistent messages should be used.
- *
- * @return Flag to indicate that persistent messages should be used.
- */
- public boolean getPersistentMode()
- {
- return getPropertyAsBoolean(PERSISTENT_MODE_PROPNAME);
- }
-
- /**
- * Flag to indicate that transactional messages should be sent by the publisher.
- *
- * @return Flag to indicate that transactional messages should be sent by the publisher.
- */
- public boolean getPublisherTransacted()
- {
- return getPropertyAsBoolean(TRANSACTED_PUBLISHER_PROPNAME);
- }
-
- /**
- * Flag to indicate that transactional receives should be used by the receiver.
- *
- * @return Flag to indicate that transactional receives should be used by the receiver.
- */
- public boolean getReceiverTransacted()
- {
- return getPropertyAsBoolean(TRANSACTED_PUBLISHER_PROPNAME);
- }
-
- /**
- * The name of the virtual host to run all tests over.
- *
- * @return The name of the virtual host to run all tests over.
- */
- public String getVirtualHost()
- {
- return getProperty(VIRTUAL_HOST_PROPNAME);
- }
-
- /**
- * Limiting rate for each sender in messages per second, or zero for unlimited.
- *
- * @return Limiting rate for each sender in messages per second, or zero for unlimited.
- */
- public String getRate()
- {
- return getProperty(RATE_PROPNAME);
- }
-
- /**
- * Flag to indicate that test messages should be received publish/subscribe style by all receivers.
- *
- * @return Flag to indicate that test messages should be received publish/subscribe style by all receivers.
- */
- public boolean getPubsub()
- {
- return getPropertyAsBoolean(PUBSUB_PROPNAME);
- }
-
- /**
- * The username credentials to run tests with.
- *
- * @return The username credentials to run tests with.
- */
- public String getUsername()
- {
- return getProperty(USERNAME_PROPNAME);
- }
-
- /**
- * The password credentials to run tests with.
- *
- * @return The password credentials to run tests with.
- */
- public String getPassword()
- {
- return getProperty(PASSWORD_PROPNAME);
- }
-
- /**
- * The timeout duration to fail tests on, should they receive no messages within it.
- *
- * @return The timeout duration to fail tests on, should they receive no messages within it.
- */
- public long getTimeout()
- {
- return getPropertyAsLong(TIMEOUT_PROPNAME);
- }
-
- /**
- * The number of messages to batch into each transaction in transational tests.
- *
- * @return The number of messages to batch into each transaction in transational tests.
- */
- public int getTxBatchSize()
- {
- return getPropertyAsInteger(TX_BATCH_SIZE_PROPNAME);
- }
-
- /**
- * Flag to indicate that tests should use durable destinations.
- *
- * @return Flag to indicate that tests should use durable destinations.
- */
- public boolean getDurableDests()
- {
- return getPropertyAsBoolean(DURABLE_DESTS_PROPNAME);
- }
-
- /**
- * The ack mode for message receivers to use.
- *
- * @return The ack mode for message receivers to use.
- */
- public int getAckMode()
- {
- return getPropertyAsInteger(ACK_MODE_PROPNAME);
- }
-
- /**
- * Flag to indicate that tests should use durable subscriptions.
- *
- * @return Flag to indicate that tests should use durable subscriptions.
- */
- public boolean getDurableSubscription()
- {
- return getPropertyAsBoolean(DURABLE_SUBSCRIPTION_PROPNAME);
- }
-
- /**
- * The maximum amount of in-flight data, in bytes, that tests should send at any time.
- *
- * @return The maximum amount of in-flight data, in bytes, that tests should send at any time.
- */
- public int getMaxPending()
- {
- return getPropertyAsInteger(MAX_PENDING_PROPNAME);
- }
-
- /**
- * The size of the prefetch queue to use.
- *
- * @return The size of the prefetch queue to use.
- */
- public int getPrefetch()
- {
- return getPropertyAsInteger(PREFETCH_PROPNAME);
- }
-
- /**
- * Flag to indicate that subscriptions should be no-local.
- *
- * @return Flag to indicate that subscriptions should be no-local.
- */
- public boolean getNoLocal()
- {
- return getPropertyAsBoolean(NO_LOCAL_PROPNAME);
- }
-
- /**
- * Flag to indicate that subscriptions should be exclusive.
- *
- * @return Flag to indicate that subscriptions should be exclusive.
- */
- public boolean getExclusive()
- {
- return getPropertyAsBoolean(EXCLUSIVE_PROPNAME);
- }
-
- /**
- * Flag to indicate that messages must be delivered immediately.
- *
- * @return Flag to indicate that messages must be delivered immediately.
- */
- public boolean getImmediate()
- {
- return getPropertyAsBoolean(IMMEDIATE_PROPNAME);
- }
-
- /**
- * Flag to indicate that messages must be routable.
- *
- * @return Flag to indicate that messages must be routable.
- */
- public boolean getMandatory()
- {
- return getPropertyAsBoolean(MANDATORY_PROPNAME);
- }
-
- /**
- * Gets the value of a flag to indicate that the publisher should rollback all messages sent.
- *
- * @return A flag to indicate that the publisher should rollback all messages sent.
- */
- public boolean getRollbackPublisher()
- {
- return getPropertyAsBoolean(ROLLBACK_PUBLISHER_PROPNAME);
- }
-
- /**
- * Gets the value of a flag to indicate that the receiver should rollback all messages received, then receive them
- * again.
- *
- * @return A flag to indicate that the publisher should rollback all messages received.
- */
- public boolean getRollbackReceiver()
- {
- return getPropertyAsBoolean(ROLLBACK_RECEIVER_PROPNAME);
- }
-
- /**
- * Gets the behavioural mode of not applicable assertions. Should be one of 'quiet', 'warn' or 'fail'.
- *
- * @return The behavioural mode of not applicable assertions.
- */
- public String getNotApplicableAssertionMode()
- {
- return getProperty(NOT_APPLICABLE_ASSERTION_PROPNAME);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/NotApplicableAssertion.java b/java/systests/src/main/java/org/apache/qpid/test/framework/NotApplicableAssertion.java
deleted file mode 100644
index 2a20be12d6..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/NotApplicableAssertion.java
+++ /dev/null
@@ -1,112 +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.test.framework;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-/**
- * NotApplicableAssertion is a messaging assertion that can be used when an assertion requested by a test-case is not
- * applicable to the testing scenario. For example an assertion may relate to AMQP functionality, but a test case may be
- * being run over a non-AMQP JMS implementation, in which case the request to create the assertion may return this
- * instead of the proper assertion. The test framework is configurable to quietly drop these assertions, log them
- * as warnings to the console, or raise them as test failures.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Quitely pass.
- * <tr><td> Log a warning.
- * <tr><td> Raise a test failure.
- * </table>
- */
-public class NotApplicableAssertion implements Assertion
-{
- /** Used for logging to the console. */
- private static final Logger console = Logger.getLogger("CONSOLE." + NotApplicableAssertion.class.getName());
-
- /** The possible behavioural modes of this assertion. */
- private enum Mode
- {
- /** Quietly ignore the assertion by passing. */
- Quiet,
-
- /** Ignore the assertion by passing but log a warning about it. */
- Warn,
-
- /** Fail the assertion. */
- Fail;
- }
-
- /** The behavioural mode of the assertion. */
- private Mode mode;
-
- /**
- * Creates an assertion that is driven by the value of the 'notApplicableAssertion' property of the test
- * configuration. Its value should match one of 'quiet', 'warn' or 'fail' and if it does not it is automatically
- * read as 'fail'.
- *
- * @param testProperties The test configuration properties.
- */
- public NotApplicableAssertion(ParsedProperties testProperties)
- {
- // Cast the test properties into a typed interface for convenience.
- MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProperties);
-
- String modeName = props.getNotApplicableAssertionMode();
-
- if ("quiet".equals(modeName))
- {
- mode = Mode.Quiet;
- }
- else if ("warn".equals(modeName))
- {
- mode = Mode.Warn;
- }
- else
- {
- mode = Mode.Fail;
- }
- }
-
- /**
- * Applies the assertion.
- *
- * @return <tt>true</tt> if the assertion passes, <tt>false</tt> if it fails.
- */
- public boolean apply()
- {
- switch (mode)
- {
- case Quiet:
- return true;
-
- case Warn:
- console.warn("Warning: Not applicable assertion being ignored.");
-
- return true;
-
- case Fail:
- default:
- return false;
- }
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/Publisher.java b/java/systests/src/main/java/org/apache/qpid/test/framework/Publisher.java
deleted file mode 100644
index 2c8be4f787..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/Publisher.java
+++ /dev/null
@@ -1,74 +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.test.framework;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-/**
- * A Publisher represents the status of the publishing side of a test circuit. Its main purpose is to provide assertions
- * that can be applied to test the behaviour of the publishers.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Provide assertion that the publishers received no exceptions.
- * </table>
- *
- * @todo There are mixtures of AMQP and JMS assertions in this interface. Either keep them here, but quietly (or with a
- * warning or error) drop them from test cases where they are not relevant, or push them down into sub-classes.
- * I am tempted to go with the dropping/warning/error approach, that would imply that it makes sense to pull
- * the assertions back from AMQPPublisher to here.
- */
-public interface Publisher
-{
- // Assertions that are meaningfull to AMQP and to JMS.
-
- /**
- * Provides an assertion that the publisher encountered no exceptions.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the publisher encountered no exceptions.
- */
- public Assertion noExceptionsAssertion(ParsedProperties testProps);
-
- // Assertions that are meaningfull only to AMQP.
-
- /**
- * Provides an assertion that the AMQP channel was forcibly closed by an error condition.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the AMQP channel was forcibly closed by an error condition.
- */
- public Assertion channelClosedAssertion(ParsedProperties testProps);
-
- // Assertions that are meaningfull only to Java/JMS.
-
- /**
- * Provides an assertion that the publisher got a given exception during the test.
- *
- * @param testProps The test configuration properties.
- * @param exceptionClass The exception class to check for.
- *
- * @return An assertion that the publisher got a given exception during the test.
- */
- public Assertion exceptionAssertion(ParsedProperties testProps, Class<? extends Exception> exceptionClass);
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/Receiver.java b/java/systests/src/main/java/org/apache/qpid/test/framework/Receiver.java
deleted file mode 100644
index 19dc4d90e7..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/Receiver.java
+++ /dev/null
@@ -1,92 +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.test.framework;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-/**
- * A Receiver is a {@link CircuitEnd} that represents the status of the receiving side of a test circuit. Its main
- * purpose is to provide assertions that can be applied to check the behaviour of the receivers.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Provide assertion that the receivers received no exceptions.
- * <tr><td> Provide assertion that the receivers received all test messages sent to it.
- * </table>
- *
- * @todo There are mixtures of AMQP and JMS assertions in this interface. Either keep them here, but quietly (or with a
- * warning or error) drop them from test cases where they are not relevant, or push them down into sub-classes.
- * I am tempted to go with the dropping/warning/error approach.
- */
-public interface Receiver
-{
- // Assertions that are meaningfull to AMQP and to JMS.
-
- /**
- * Provides an assertion that the receivers encountered no exceptions.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the receivers encountered no exceptions.
- */
- public Assertion noExceptionsAssertion(ParsedProperties testProps);
-
- /**
- * Provides an assertion that the receivers got all messages that were sent to it.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the receivers got all messages that were sent to it.
- */
- public Assertion allMessagesReceivedAssertion(ParsedProperties testProps);
-
- /**
- * Provides an assertion that the receivers got none of the messages that were sent to it.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the receivers got none of the messages that were sent to it.
- */
- public Assertion noMessagesReceivedAssertion(ParsedProperties testProps);
-
- // Assertions that are meaningfull only to AMQP.
-
- /**
- * Provides an assertion that the AMQP channel was forcibly closed by an error condition.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the AMQP channel was forcibly closed by an error condition.
- */
- public Assertion channelClosedAssertion(ParsedProperties testProps);
-
- // Assertions that are meaningfull only to Java/JMS.
-
- /**
- * Provides an assertion that the receiver got a given exception during the test.
- *
- * @param testProps The test configuration properties.
- * @param exceptionClass The exception class to check for.
- *
- * @return An assertion that the receiver got a given exception during the test.
- */
- public Assertion exceptionAssertion(ParsedProperties testProps, Class<? extends Exception> exceptionClass);
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java b/java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java
deleted file mode 100644
index ad1e70f6f7..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java
+++ /dev/null
@@ -1,88 +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.test.framework;
-
-/**
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td>
- * </table>
- */
-public class TestCaseVector
-{
- /** The test case name. */
- private String testCase;
-
- /** The test cycle number within the test case. */
- private int testCycleNumber;
-
- public TestCaseVector(String testCase, int testCycleNumber)
- {
- this.testCase = testCase;
- this.testCycleNumber = testCycleNumber;
- }
-
- public String getTestCase()
- {
- return testCase;
- }
-
- public int getTestCycleNumber()
- {
- return testCycleNumber;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
-
- if ((o == null) || (getClass() != o.getClass()))
- {
- return false;
- }
-
- TestCaseVector that = (TestCaseVector) o;
-
- if (testCycleNumber != that.testCycleNumber)
- {
- return false;
- }
-
- if ((testCase != null) ? (!testCase.equals(that.testCase)) : (that.testCase != null))
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- int result;
- result = ((testCase != null) ? testCase.hashCode() : 0);
- result = (31 * result) + testCycleNumber;
-
- return result;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/TestClientDetails.java b/java/systests/src/main/java/org/apache/qpid/test/framework/TestClientDetails.java
deleted file mode 100644
index 7498f2b6b5..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/TestClientDetails.java
+++ /dev/null
@@ -1,86 +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.test.framework;
-
-/**
- * TestClientDetails is used to encapsulate information about an interop test client. It pairs together the unique
- * name of the client, and the route on which it listens to its control messages.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Record test clients control addresses together with their names.
- * </table>
- */
-public class TestClientDetails
-{
- /** The test clients name. */
- public String clientName;
-
- /* The test clients unique sequence number. Not currently used. */
-
- /** The routing key of the test clients control topic. */
- public String privateControlKey;
-
- /**
- * Two TestClientDetails are considered to be equal, iff they have the same client name.
- *
- * @param o The object to compare to.
- *
- * @return <tt>If the object to compare to is a TestClientDetails equal to this one, <tt>false</tt> otherwise.
- */
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
-
- if (!(o instanceof TestClientDetails))
- {
- return false;
- }
-
- final TestClientDetails testClientDetails = (TestClientDetails) o;
-
- return !((clientName != null) ? (!clientName.equals(testClientDetails.clientName))
- : (testClientDetails.clientName != null));
- }
-
- /**
- * Computes a hash code compatible with the equals method; based on the client name alone.
- *
- * @return A hash code for this.
- */
- public int hashCode()
- {
- return ((clientName != null) ? clientName.hashCode() : 0);
- }
-
- /**
- * Outputs the client name and address details. Mostly used for debugging purposes.
- *
- * @return The client name and address.
- */
- public String toString()
- {
- return "TestClientDetails: [ clientName = " + clientName + ", privateControlKey = " + privateControlKey + " ]";
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java b/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
deleted file mode 100644
index 919faa4754..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
+++ /dev/null
@@ -1,200 +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.test.framework;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.BROKER_PROPNAME;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.CONNECTION_NAME;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.PASSWORD_PROPNAME;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.USERNAME_PROPNAME;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.VIRTUAL_HOST_PROPNAME;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Map;
-
-/**
- * TestUtils provides static helper methods that are usefull for writing tests against QPid.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Create connections from test properties. <td> {@link MessagingTestConfigProperties}
- * <tr><td> Create test messages.
- * <tr><td> Inject a short pause in a test.
- * <tr><td> Serialize properties into a message.
- * </table>
- */
-public class TestUtils
-{
- /** Used for debugging. */
- private static Logger log = Logger.getLogger(TestUtils.class);
-
- /** Some dummy data to stuff all test messages with. */
- private static final byte[] MESSAGE_DATA_BYTES =
- "Test Message -- Test Message -- Test Message -- Test Message -- Test Message -- Test Message -- Test Message -- "
- .getBytes();
-
- /**
- * Establishes a JMS connection using a set of properties and qpids built in JNDI implementation. This is a simple
- * convenience method for code that does not anticipate handling connection failures. All exceptions that indicate
- * that the connection has failed, are wrapped as rutime exceptions, presumably handled by a top level failure
- * handler.
- *
- * <p/>This utility makes use of the following test parameters from {@link MessagingTestConfigProperties} to control
- * the connection creation:
- *
- * <p/><table>
- * <tr><td> {@link MessagingTestConfigProperties#USERNAME_PROPNAME} <td> The username.
- * <tr><td> {@link MessagingTestConfigProperties#PASSWORD_PROPNAME} <td> The password.
- * <tr><td> {@link MessagingTestConfigProperties#VIRTUAL_HOST_PROPNAME} <td> The virtual host name.
- * <tr><td> {@link MessagingTestConfigProperties#BROKER_PROPNAME} <td> The broker URL.
- * <tr><td> {@link MessagingTestConfigProperties#CONNECTION_NAME} <td> The broker name in the initial context.
- *
- * @param messagingProps Connection properties as defined in {@link MessagingTestConfigProperties}.
- *
- * @return A JMS conneciton.
- */
- public static Connection createConnection(ParsedProperties messagingProps)
- {
- log.debug("public static Connection createConnection(ParsedProperties messagingProps = " + messagingProps
- + "): called");
-
- try
- {
- // Extract the configured connection properties from the test configuration.
- String conUsername = messagingProps.getProperty(USERNAME_PROPNAME);
- String conPassword = messagingProps.getProperty(PASSWORD_PROPNAME);
- String virtualHost = messagingProps.getProperty(VIRTUAL_HOST_PROPNAME);
- String brokerUrl = messagingProps.getProperty(BROKER_PROPNAME);
-
- // Create the broker connection url.
- String connectionString =
- "amqp://" + conUsername + ":" + conPassword + "@clientid/" + ((virtualHost != null) ? virtualHost : "")
- + "?brokerlist='" + brokerUrl + "'";
-
- // Create properties to create the initial context from, and inject the connection factory configuration
- // for the defined connection name into it.
- messagingProps.setProperty("connectionfactory." + CONNECTION_NAME, connectionString);
-
- Context ctx = new InitialContext(messagingProps);
-
- ConnectionFactory cf = (ConnectionFactory) ctx.lookup(CONNECTION_NAME);
-
- return cf.createConnection();
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Got JNDI NamingException whilst looking up the connection factory.", e);
- }
- catch (JMSException e)
- {
- throw new RuntimeException("Could not establish connection due to JMSException.", e);
- }
- }
-
- /**
- * Creates a test message of the specified size, on the given JMS session.
- *
- * @param session The JMS session.
- * @param size The size of the message in bytes.
- *
- * @return A bytes message, of the specified size, filled with dummy data.
- *
- * @throws JMSException Any underlying JMSExceptions are allowed to fall through.
- */
- public static Message createTestMessageOfSize(Session session, int size) throws JMSException
- {
- BytesMessage message = session.createBytesMessage();
-
- if (size > 0)
- {
- int div = size / MESSAGE_DATA_BYTES.length;
- int mod = size % MESSAGE_DATA_BYTES.length;
-
- for (int i = 0; i < div; i++)
- {
- message.writeBytes(MESSAGE_DATA_BYTES);
- }
-
- if (mod != 0)
- {
- message.writeBytes(MESSAGE_DATA_BYTES, 0, mod);
- }
- }
-
- return message;
- }
-
- /**
- * Pauses for the specified length of time. In the event of failing to pause for at least that length of time
- * due to interuption of the thread, a RutimeException is raised to indicate the failure. The interupted status
- * of the thread is restores in that case. This method should only be used when it is expected that the pause
- * will be succesfull, for example in test code that relies on inejecting a pause.
- *
- * @param t The minimum time to pause for in milliseconds.
- */
- public static void pause(long t)
- {
- try
- {
- Thread.sleep(t);
- }
- catch (InterruptedException e)
- {
- // Restore the interrupted status
- Thread.currentThread().interrupt();
-
- throw new RuntimeException("Failed to generate the requested pause length.", e);
- }
- }
-
- /**
- * Sets properties of different types on a JMS Message.
- *
- * @param message The message to set properties on.
- * @param properties The property name/value pairs to set.
- *
- * @throws javax.jms.JMSException All underlying JMSExceptions are allowed to fall through.
- *
- * @todo Move this helper method somewhere else. For example, TestUtils.
- */
- public static void setPropertiesOnMessage(Message message, Map<Object, Object> properties) throws JMSException
- {
- for (Map.Entry<Object, Object> entry : properties.entrySet())
- {
- String name = entry.getKey().toString();
- Object value = entry.getValue();
-
- message.setObjectProperty(name, value);
- }
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchFailureException.java b/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchFailureException.java
deleted file mode 100644
index 00cc2d8966..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchFailureException.java
+++ /dev/null
@@ -1,45 +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.test.framework.clocksynch;
-
-/**
- * ClockSynchFailureException represents failure of a {@link ClockSynchronizer} to achieve synchronization. For example,
- * this could be because a reference signal is not available, or because a desired accurracy cannot be attained.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Represent failure to achieve synchronization.
- * </table>
- */
-public class ClockSynchFailureException extends Exception
-{
- /**
- * Creates a clock synch failure exception.
- *
- * @param message The detail message (which is saved for later retrieval by the {@link #getMessage()} method).
- * @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A <tt>null</tt>
- * value is permitted, and indicates that the cause is nonexistent or unknown.)
- */
- public ClockSynchFailureException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchThread.java b/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchThread.java
deleted file mode 100644
index 3d4c4f7d12..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchThread.java
+++ /dev/null
@@ -1,124 +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.test.framework.clocksynch;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.ShutdownHookable;
-import org.apache.qpid.junit.extensions.Throttle;
-
-/**
- * ClockSynchThread is a convenient utility for running a thread that periodically synchronizes the clock against
- * a reference. Supply it with a {@link ClockSynchronizer} and a {@link Throttle} and it will continually keep the
- * clock up-to-date at a rate determined by the throttle.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Continually sychronize the clock at a throttled rate.
- * </table>
- */
-public class ClockSynchThread extends Thread implements ShutdownHookable
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(ClockSynchThread.class);
-
- /** Holds the clock syncher for the synch thread. */
- private ClockSynchronizer clockSyncher;
-
- /** Holds the throttle to limit the synch rate. */
- private Throttle throttle;
-
- /** Flag to indicate that the periodic clock syncher should keep running. */
- boolean doSynch = true;
-
- /**
- * Creates a clock synchronizer thread from a clock synchronizer and a throttle.
- *
- * @param syncher The clock synchronizer.
- * @param throttle The throttle.
- */
- public ClockSynchThread(ClockSynchronizer syncher, Throttle throttle)
- {
- this.clockSyncher = syncher;
- this.throttle = throttle;
- }
-
- /**
- * Terminates the synchronization thread.
- */
- public void terminate()
- {
- doSynch = false;
- }
-
- /**
- * Continually updates the clock, until {@link #terminate()} is called.
- */
- public void run()
- {
- while (doSynch)
- {
- // Perform a clock clockSynch.
- try
- {
- // Wait controlled by the throttle before doing the next synch.
- throttle.throttle();
-
- clockSyncher.synch();
- log.debug("Clock synched, delta = " + clockSyncher.getDelta() + ", epsilon = " + clockSyncher.getEpsilon()
- + ".");
- }
- // Terminate the synch thread if the synchronization cannot be achieved.
- catch (ClockSynchFailureException e)
- {
- log.debug("Cannot synchronize the clock (reference service may be down). Terminating the synch thread.");
- doSynch = false;
- }
- }
- }
-
- /**
- * Gets the clock synchronizer that is kept continually up to date.
- *
- * @return The clock synchronizer that is kept continually up to date.
- */
- public ClockSynchronizer getClockSyncher()
- {
- return clockSyncher;
- }
-
- /**
- * Supplies a shutdown hook, that terminates the synching thread.
- *
- * @return The shut down hook.
- */
- public Thread getShutdownHook()
- {
- return new Thread(new Runnable()
- {
- public void run()
- {
- doSynch = false;
- }
- });
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchronizer.java b/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchronizer.java
deleted file mode 100644
index a92c551bc2..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/ClockSynchronizer.java
+++ /dev/null
@@ -1,69 +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.test.framework.clocksynch;
-
-/**
- * ClockSynchronizer provides an interface through which two nodes may synchronize their clocks. It is expected that one
- * node will act as the reference clock, to which no delta need be applied, and the other node will act as the slave,
- * and which must apply a delta to its local clock to get a clock synchronized with the reference.
- *
- * <p/>The slave side will initiate the computation of a clock delta by calling the {@link #synch} method. This method
- * will not return until the delta has been computed, at which point there is a method to return its value, as well as
- * an estimate of the likely error (usually one standard deviation), in the synchronization. For convenience there is a
- * {@link #nanoTime} method to return the value of System.nanoTime() with the delta added in.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Trigger a clock synchronization.
- * <tr><td> Compute a clock delta to apply to the local clock.
- * <tr><td> Estimate the error in the synchronzation.
- * </table>
- */
-public interface ClockSynchronizer
-{
- /**
- * The slave side should call this to copute a clock delta with the reference.
- *
- * @throws ClockSynchFailureException If synchronization cannot be achieved.
- */
- public void synch() throws ClockSynchFailureException;
-
- /**
- * Gets the clock delta in nano seconds.
- *
- * @return The clock delta in nano seconds.
- */
- public long getDelta();
-
- /**
- * Gets an estimate of the clock error in nan seconds.
- *
- * @return An estimate of the clock error in nan seconds.
- */
- public long getEpsilon();
-
- /**
- * Gets the local clock time with any computed delta added in.
- *
- * @return The local clock time with any computed delta added in.
- */
- public long nanoTime();
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/LocalClockSynchronizer.java b/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/LocalClockSynchronizer.java
deleted file mode 100644
index f448d5f23c..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/LocalClockSynchronizer.java
+++ /dev/null
@@ -1,73 +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.test.framework.clocksynch;
-
-/**
- * LocalClockSynchronizer is a fake {@link ClockSynchronizer} that simply calls System.nanoTime(). It exists so that
- * the same tests can be run distributed or locally, taking timings against the ClockSynchronizer interface without
- * being aware of how they are being run.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Supply the local clock with no delta.
- * </table>
- */
-public class LocalClockSynchronizer implements ClockSynchronizer
-{
- /**
- * The slave side should call this to copute a clock delta with the reference.
- *
- * @throws org.apache.qpid.test.framework.clocksynch.ClockSynchFailureException
- * If synchronization cannot be achieved.
- */
- public void synch() throws ClockSynchFailureException
- { }
-
- /**
- * Gets the clock delta in nano seconds.
- *
- * @return The clock delta in nano seconds.
- */
- public long getDelta()
- {
- return 0L;
- }
-
- /**
- * Gets an estimate of the clock error in nan seconds.
- *
- * @return An estimate of the clock error in nan seconds.
- */
- public long getEpsilon()
- {
- return 0L;
- }
-
- /**
- * Gets the local clock time with any computed delta added in.
- *
- * @return The local clock time with any computed delta added in.
- */
- public long nanoTime()
- {
- return System.nanoTime();
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockReference.java b/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockReference.java
deleted file mode 100644
index 8ee8d82636..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockReference.java
+++ /dev/null
@@ -1,169 +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.test.framework.clocksynch;
-
-import org.apache.qpid.junit.extensions.ShutdownHookable;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.nio.ByteBuffer;
-
-/**
- * UDPClockReference supplies a refernce clock signal (generated from System.nanoTime()).
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Supply a reference clock signal.
- * </table>
- *
- * @todo Port hard coded. Make configurable.
- *
- * @todo Errors rethrown as runtimes, or silently terminate the service. Could add better error handling if needed.
- */
-public class UDPClockReference implements Runnable, ShutdownHookable
-{
- /** Used for debugging. */
- // private static final Logger log = Logger.getLogger(UDPClockReference.class);
-
- /** Defines the timeout to use when polling the socket for time requests. */
- private static final int TIMEOUT = 200;
-
- /** Defines the port to run the clock reference on. */
- public static final int REFERENCE_PORT = 4444;
-
- /** Holds the socket to receive clock reference requests on. */
- protected DatagramSocket socket = null;
-
- /** Flag used to indicate that the time server should keep running. Set to false to terminate. */
- protected boolean publish = true;
-
- /**
- * Creates a clock reference service on the standard port.
- */
- public UDPClockReference()
- {
- try
- {
- socket = new DatagramSocket(REFERENCE_PORT);
- socket.setSoTimeout(TIMEOUT);
- }
- catch (SocketException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Implements the run loop for this reference time server. This waits for incoming time requests, and replies to
- * any, with a message with the local time stamp in it. Periodically (controlled by {@link #TIMEOUT}), the run
- * loop will check if the {@link #publish} flag has been cleared, and terminate the reference time service if so.
- */
- public void run()
- {
- byte[] buf = new byte[256];
- ByteBuffer bbuf = ByteBuffer.wrap(buf);
-
- while (publish)
- {
- try
- {
- // Wait for a reference time request.
- DatagramPacket packet = new DatagramPacket(buf, buf.length);
- boolean timedOut = false;
-
- try
- {
- socket.receive(packet);
- }
- catch (SocketTimeoutException e)
- {
- timedOut = true;
- }
-
- if (!timedOut)
- {
- // Work out from the received packet, where to reply to.
- InetAddress address = packet.getAddress();
- int port = packet.getPort();
-
- // Respond to the time request by sending back the local clock as the reference time.
- bbuf.putLong(System.nanoTime());
- bbuf.flip();
- packet = new DatagramPacket(bbuf.array(), bbuf.capacity(), address, port);
-
- socket.send(packet);
- }
- }
- catch (IOException e)
- {
- publish = false;
- }
- }
-
- socket.close();
- }
-
- /**
- * Supplies a shutdown hook.
- *
- * @return The shut down hook.
- */
- public Thread getShutdownHook()
- {
- return new Thread(new Runnable()
- {
- public void run()
- {
- publish = false;
- }
- });
- }
-
- /**
- * For testing purposes. Runs a reference clock on the default port.
- *
- * @param args None.
- */
- public static void main(String[] args)
- {
- try
- {
- // Create the clock reference service.
- UDPClockReference clock = new UDPClockReference();
-
- // Set up a shutdown hook for it.
- Runtime.getRuntime().addShutdownHook(clock.getShutdownHook());
-
- // Start the service.
- clock.run();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- System.exit(1);
- }
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockSynchronizer.java b/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockSynchronizer.java
deleted file mode 100644
index 226c84611d..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockSynchronizer.java
+++ /dev/null
@@ -1,468 +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.test.framework.clocksynch;
-
-import org.apache.qpid.junit.extensions.util.CommandLineParser;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-/**
- * UDPClockSynchronizer is a {@link ClockSynchronizer} that sends pings as UDP datagrams, and uses the following simple
- * algorithm to perform clock synchronization:
- *
- * <ol>
- * <li>Slave initiates synchronization with a Reference clock.</li>
- * <li>Slave stamps current local time on a "time request" message and sends to the Reference.</li>
- * <li>Upon receipt by Reference, Reference stamps Reference-time and returns.</li>
- * <li>Upon receipt by Slave, Slave subtracts current time from sent time and divides by two to compute latency. It
- * subtracts current time from Reference time to determine Slave-Reference time delta and adds in the
- * half-latency to get the correct clock delta.</li>
- * <li>The first result is immediately used to update the clock since it will get the local clock into at least
- * the right ballpark.</li>
- * <li>The Slave repeats steps 2 through 4, 15 more times.</li>
- * <li>The results of the packet receipts are accumulated and sorted in lowest-latency to highest-latency order. The
- * median latency is determined by picking the mid-point sample from this ordered list.</li>
- * <li>All samples outside 1 standard-deviation from the median are discarded and the remaining samples
- * are averaged using an arithmetic mean.</li>
- * </ol>
- *
- * <p/>The use of UDP datagrams, instead of TCP based communication eliminates the hidden delays that TCP can introduce,
- * as it can transparently re-order or re-send packets, or introduce delays as packets are naggled.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Trigger a clock synchronziation.
- * <tr><td> Compute a clock delta to apply to the local clock.
- * <tr><td> Estimate the error in the synchronzation.
- * </table>
- */
-public class UDPClockSynchronizer implements ClockSynchronizer
-{
- /** Used for debugging. */
- // private static final Logger log = Logger.getLogger(UDPClockSynchronizer.class);
-
- /** Defines the timeout to use when waiting for responses to time requests. */
- private static final int TIMEOUT = 50;
-
- /** The clock delta. */
- private long delta = 0L;
-
- /** Holds an estimate of the clock error relative to the reference clock. */
- private long epsilon = 0L;
-
- /** Holds the address of the reference clock. */
- private InetAddress referenceAddress;
-
- /** Holds the socket to communicate with the reference service over. */
- private DatagramSocket socket;
-
- /** Used to control the shutdown in the main test loop. */
- private static boolean doSynch = true;
-
- /**
- * Creates a clock synchronizer against the specified address for the reference.
- *
- * @param address The address of the reference service.
- */
- public UDPClockSynchronizer(String address)
- {
- try
- {
- referenceAddress = InetAddress.getByName(address);
- }
- catch (UnknownHostException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * The slave side should call this to compute a clock delta with the reference.
- *
- * @throws ClockSynchFailureException If synchronization cannot be achieved, due to unavailability of the reference
- * time service.
- */
- public void synch() throws ClockSynchFailureException
- {
- try
- {
- socket = new DatagramSocket();
- socket.setSoTimeout(TIMEOUT);
-
- // Synchronize on a single ping, to get the clock into the right ball-park.
- synch(1);
-
- // Synchronize on 15 pings.
- synch(15);
-
- // And again, for greater accuracy, on 31.
- synch(31);
-
- socket.close();
- }
- catch (SocketException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Updates the synchronization delta by performing the specified number of reference clock requests.
- *
- * @param n The number of reference clock request cycles to perform.
- *
- * @throws ClockSynchFailureException If synchronization cannot be achieved, due to unavailability of the reference
- * time service.
- */
- protected void synch(int n) throws ClockSynchFailureException
- {
- // log.debug("protected void synch(int n = " + n + "): called");
-
- // Create an array of deltas by performing n reference pings.
- long[] delta = new long[n];
-
- for (int i = 0; i < n; i++)
- {
- delta[i] = ping();
- }
-
- // Reject any deltas that are larger than 1 s.d. above the median.
- long median = median(delta);
- long sd = standardDeviation(delta);
-
- // log.debug("median = " + median);
- // log.debug("sd = " + sd);
-
- long[] tempDeltas = new long[n];
- int count = 0;
-
- for (int i = 0; i < n; i++)
- {
- if ((delta[i] <= (median + sd)) && (delta[i] >= (median - sd)))
- {
- tempDeltas[count] = delta[i];
- count++;
- }
- else
- {
- // log.debug("Rejected: " + delta[i]);
- }
- }
-
- System.arraycopy(tempDeltas, 0, delta, 0, count);
-
- // Estimate the delta as the mean of the remaining deltas.
- this.delta += mean(delta);
-
- // Estimate the error as the standard deviation of the remaining deltas.
- this.epsilon = standardDeviation(delta);
-
- // log.debug("this.delta = " + this.delta);
- // log.debug("this.epsilon = " + this.epsilon);
- }
-
- /**
- * Performs a single reference clock request cycle and returns the estimated delta relative to the local clock.
- * This is computed as the half-latency of the requst cycle, plus the reference clock, minus the local clock.
- *
- * @return The estimated clock delta.
- *
- * @throws ClockSynchFailureException If the reference service is not responding.
- */
- protected long ping() throws ClockSynchFailureException
- {
- // log.debug("protected long ping(): called");
-
- try
- {
- byte[] buf = new byte[256];
-
- boolean timedOut = false;
- long start = 0L;
- long refTime = 0L;
- long localTime = 0L;
- long latency = 0L;
- int failCount = 0;
-
- // Keep trying the ping until it gets a response, or 10 tries in a row all time out.
- do
- {
- // Start timing the request latency.
- start = nanoTime();
-
- // Get the reference time.
- DatagramPacket packet =
- new DatagramPacket(buf, buf.length, referenceAddress, UDPClockReference.REFERENCE_PORT);
- socket.send(packet);
- packet = new DatagramPacket(buf, buf.length);
-
- timedOut = false;
-
- try
- {
- socket.receive(packet);
- }
- catch (SocketTimeoutException e)
- {
- timedOut = true;
- failCount++;
-
- continue;
- }
-
- ByteBuffer bbuf = ByteBuffer.wrap(packet.getData());
- refTime = bbuf.getLong();
-
- // Stop timing the request latency.
- localTime = nanoTime();
- latency = localTime - start;
-
- // log.debug("refTime = " + refTime);
- // log.debug("localTime = " + localTime);
- // log.debug("start = " + start);
- // log.debug("latency = " + latency);
- // log.debug("delta = " + ((latency / 2) + (refTime - localTime)));
-
- }
- while (timedOut && (failCount < 10));
-
- // Fail completely if the fail count is too high.
- if (failCount >= 10)
- {
- throw new ClockSynchFailureException("Clock reference not responding.", null);
- }
-
- // Estimate delta as (ref clock + half-latency) - local clock.
- return (latency / 2) + (refTime - localTime);
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Gets the clock delta in nano seconds.
- *
- * @return The clock delta in nano seconds.
- */
- public long getDelta()
- {
- return delta;
- }
-
- /**
- * Gets an estimate of the clock error in nan seconds.
- *
- * @return An estimate of the clock error in nan seconds.
- */
- public long getEpsilon()
- {
- return epsilon;
- }
-
- /**
- * Gets the local clock time with any computed delta added in.
- *
- * @return The local clock time with any computed delta added in.
- */
- public long nanoTime()
- {
- return System.nanoTime() + delta;
- }
-
- /**
- * Computes the median of a series of values.
- *
- * @param values The values.
- *
- * @return The median.
- */
- public static long median(long[] values)
- {
- // log.debug("public static long median(long[] values = " + Arrays.toString(values) + "): called");
-
- long median;
-
- // Order the list of values.
- long[] orderedValues = new long[values.length];
- System.arraycopy(values, 0, orderedValues, 0, values.length);
- Arrays.sort(orderedValues);
-
- // Check if the median is computed from a pair of middle value.
- if ((orderedValues.length % 2) == 0)
- {
- int middle = orderedValues.length / 2;
-
- median = (orderedValues[middle] + orderedValues[middle - 1]) / 2;
- }
- // The median is computed from a single middle value.
- else
- {
- median = orderedValues[orderedValues.length / 2];
- }
-
- // log.debug("median = " + median);
-
- return median;
- }
-
- /**
- * Computes the mean of a series of values.
- *
- * @param values The values.
- *
- * @return The mean.
- */
- public static long mean(long[] values)
- {
- // log.debug("public static long mean(long[] values = " + Arrays.toString(values) + "): called");
-
- long total = 0L;
-
- for (long value : values)
- {
- total += value;
- }
-
- long mean = total / values.length;
-
- // log.debug("mean = " + mean);
-
- return mean;
- }
-
- /**
- * Computes the variance of series of values.
- *
- * @param values The values.
- *
- * @return The variance of the values.
- */
- public static long variance(long[] values)
- {
- // log.debug("public static long variance(long[] values = " + Arrays.toString(values) + "): called");
-
- long mean = mean(values);
-
- long totalVariance = 0;
-
- for (long value : values)
- {
- long diff = (value - mean);
- totalVariance += diff * diff;
- }
-
- long variance = totalVariance / values.length;
-
- // log.debug("variance = " + variance);
-
- return variance;
- }
-
- /**
- * Computes the standard deviation of a series of values.
- *
- * @param values The values.
- *
- * @return The standard deviation.
- */
- public static long standardDeviation(long[] values)
- {
- // log.debug("public static long standardDeviation(long[] values = " + Arrays.toString(values) + "): called");
-
- long sd = Double.valueOf(Math.sqrt(variance(values))).longValue();
-
- // log.debug("sd = " + sd);
-
- return sd;
- }
-
- /**
- * For testing purposes. Supply address of reference clock as arg 1.
- *
- * @param args Address of reference clock as arg 1.
- */
- public static void main(String[] args)
- {
- ParsedProperties options =
- new ParsedProperties(CommandLineParser.processCommandLine(args,
- new CommandLineParser(
- new String[][]
- {
- { "1", "Address of clock reference service.", "address", "true" }
- }), System.getProperties()));
-
- String address = options.getProperty("1");
-
- // Create a clock synchronizer.
- UDPClockSynchronizer clockSyncher = new UDPClockSynchronizer(address);
-
- // Set up a shutdown hook for it.
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
- {
- public void run()
- {
- doSynch = false;
- }
- }));
-
- // Repeat the clock synching until the user kills the progam.
- while (doSynch)
- {
- // Perform a clock clockSynch.
- try
- {
- clockSyncher.synch();
-
- // Print out the clock delta and estimate of the error.
- System.out.println("Delta = " + clockSyncher.getDelta());
- System.out.println("Epsilon = " + clockSyncher.getEpsilon());
-
- try
- {
- Thread.sleep(250);
- }
- catch (InterruptedException e)
- {
- // Restore the interrupted status and terminate the loop.
- Thread.currentThread().interrupt();
- doSynch = false;
- }
- }
- // Terminate if the reference time service is unavailable.
- catch (ClockSynchFailureException e)
- {
- doSynch = false;
- }
- }
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedCircuitImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedCircuitImpl.java
deleted file mode 100644
index 6c950fc307..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedCircuitImpl.java
+++ /dev/null
@@ -1,472 +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.test.framework.distributedcircuit;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.TimingController;
-import org.apache.qpid.junit.extensions.TimingControllerAware;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.Publisher;
-import org.apache.qpid.test.framework.Receiver;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.framework.TestUtils;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * DistributedCircuitImpl is a distributed implementation of the test {@link Circuit}. Many publishers and receivers
- * accross multiple machines may be combined to form a single test circuit. The test circuit extracts reports from
- * all of its publishers and receivers, and applies its assertions to these reports.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Supply the publishing and receiving ends of a test messaging circuit.
- * <tr><td> Start the circuit running.
- * <tr><td> Close the circuit down.
- * <tr><td> Take a reading of the circuits state.
- * <tr><td> Apply assertions against the circuits state.
- * <tr><td> Send test messages over the circuit.
- * <tr><td> Perform the default test procedue on the circuit.
- * </table>
- *
- * @todo There is a short pause after receiving sender reports before asking for receiver reports, because receivers may
- * not have finished receiving all their test messages before the report request arrives. This is going to be a
- * problem for taking test timings and needs to be eliminiated. Suggested solution: have receiver send back reports
- * asynchronously, on test batch size boundaries, and do so automatically rather than having to have the report
- * request sent to them. Number each test run, or otherwise uniquely identify it, when a receiver does not get
- * any more messages on a test run for more than a timeout, it can assume the test is complete and send a final
- * report. On the coordinator end a future will need to be created to wait for all final reports to come in, and
- * to register results and timings for the test. This must work in such a way that a new test cycle can be started
- * without waiting for the results of the old one to come in.
- *
- * @todo Add in setting of timing controller, from timing aware test cases.
- */
-public class DistributedCircuitImpl implements Circuit, TimingControllerAware
-{
- /** Used for debugging purposes. */
- private static final Logger log = Logger.getLogger(DistributedCircuitImpl.class);
-
- /** Holds the conversation factory over which to coordinate the test. */
- protected ConversationFactory conversationFactory;
-
- /** Holds the controlSession over which to hold the control conversation. */
- protected Session controlSession;
-
- /** Holds the sender nodes in the test circuit. */
- protected List<TestClientDetails> senders;
-
- /** Holds the receiver nodes in the test circuit. */
- protected List<TestClientDetails> receivers;
-
- /** Holds the sender control conversations. */
- protected ConversationFactory.Conversation[] senderConversation;
-
- /** Holds the receiver control conversations. */
- protected ConversationFactory.Conversation[] receiverConversation;
-
- /** Holds the control topics for the senders in the test circuit. */
- protected Destination[] senderControlTopic;
-
- /** Holds the control topics for the receivers in the test circuit. */
- protected Destination[] receiverControlTopic;
-
- /** Holds the number of messages to send per test run. */
- protected int numMessages;
-
- /**
- * Holds the timing controller for the circuit. This is used to log test times asynchronously, when reciever nodes
- * return their reports after senders have completed a test case.
- */
- TimingController timingController;
-
- /**
- * Creates a distributed test circuit on the specified senders and receivers.
- *
- * @param session The controlSession for all control conversations.
- * @param senders The senders.
- * @param receivers The receivers.
- * @param senderConversation A control conversation with the senders.
- * @param receiverConversation A control conversation with the receivers.
- * @param senderControlTopic The senders control topic.
- * @param receiverControlTopic The receivers control topic.
- */
- protected DistributedCircuitImpl(Session session, List<TestClientDetails> senders, List<TestClientDetails> receivers,
- ConversationFactory.Conversation[] senderConversation, ConversationFactory.Conversation[] receiverConversation,
- Destination[] senderControlTopic, Destination[] receiverControlTopic)
- {
- this.controlSession = session;
- this.senders = senders;
- this.receivers = receivers;
- this.senderConversation = senderConversation;
- this.receiverConversation = receiverConversation;
- this.senderControlTopic = senderControlTopic;
- this.receiverControlTopic = receiverControlTopic;
- }
-
- /**
- * Creates a distributed test circuit from the specified test parameters, on the senders and receivers
- * given.
- *
- * @param testProps The test parameters.
- * @param senders The sender ends in the test circuit.
- * @param receivers The receiver ends in the test circuit.
- * @param conversationFactory A conversation factory for creating the control conversations with senders and receivers.
- *
- * @return A connected and ready to start, test circuit.
- */
- public static Circuit createCircuit(ParsedProperties testProps, List<TestClientDetails> senders,
- List<TestClientDetails> receivers, ConversationFactory conversationFactory)
- {
- log.debug("public static Circuit createCircuit(ParsedProperties testProps, List<TestClientDetails> senders, "
- + " List<TestClientDetails> receivers, ConversationFactory conversationFactory)");
-
- try
- {
- Session session = conversationFactory.getSession();
-
- // Create control conversations with each of the senders.
- ConversationFactory.Conversation[] senderConversation = new ConversationFactory.Conversation[senders.size()];
- Destination[] senderControlTopic = new Destination[senders.size()];
-
- for (int i = 0; i < senders.size(); i++)
- {
- TestClientDetails sender = senders.get(i);
-
- senderControlTopic[i] = session.createTopic(sender.privateControlKey);
- senderConversation[i] = conversationFactory.startConversation();
- }
-
- log.debug("Sender conversations created.");
-
- // Create control conversations with each of the receivers.
- ConversationFactory.Conversation[] receiverConversation = new ConversationFactory.Conversation[receivers.size()];
- Destination[] receiverControlTopic = new Destination[receivers.size()];
-
- for (int i = 0; i < receivers.size(); i++)
- {
- TestClientDetails receiver = receivers.get(i);
-
- receiverControlTopic[i] = session.createTopic(receiver.privateControlKey);
- receiverConversation[i] = conversationFactory.startConversation();
- }
-
- log.debug("Receiver conversations created.");
-
- // Assign the sender role to each of the sending test clients.
- for (int i = 0; i < senders.size(); i++)
- {
- TestClientDetails sender = senders.get(i);
-
- Message assignSender = conversationFactory.getSession().createMessage();
- TestUtils.setPropertiesOnMessage(assignSender, testProps);
- assignSender.setStringProperty("CONTROL_TYPE", "ASSIGN_ROLE");
- assignSender.setStringProperty("ROLE", "SENDER");
-
- senderConversation[i].send(senderControlTopic[i], assignSender);
- }
-
- log.debug("Sender role assignments sent.");
-
- // Assign the receivers role to each of the receiving test clients.
- for (int i = 0; i < receivers.size(); i++)
- {
- TestClientDetails receiver = receivers.get(i);
-
- Message assignReceiver = session.createMessage();
- TestUtils.setPropertiesOnMessage(assignReceiver, testProps);
- assignReceiver.setStringProperty("CONTROL_TYPE", "ASSIGN_ROLE");
- assignReceiver.setStringProperty("ROLE", "RECEIVER");
-
- receiverConversation[i].send(receiverControlTopic[i], assignReceiver);
- }
-
- log.debug("Receiver role assignments sent.");
-
- // Wait for the senders and receivers to confirm their roles.
- for (int i = 0; i < senders.size(); i++)
- {
- senderConversation[i].receive();
- }
-
- log.debug("Got all sender role confirmations");
-
- for (int i = 0; i < receivers.size(); i++)
- {
- receiverConversation[i].receive();
- }
-
- log.debug("Got all receiver role confirmations");
-
- // Package everything up as a circuit.
- return new DistributedCircuitImpl(session, senders, receivers, senderConversation, receiverConversation,
- senderControlTopic, receiverControlTopic);
- }
- catch (JMSException e)
- {
- throw new RuntimeException("JMSException not handled.");
- }
- }
-
- /**
- * Used by tests cases that can supply a {@link org.apache.qpid.junit.extensions.TimingController} to set the
- * controller on an aware test.
- *
- * @param controller The timing controller.
- */
- public void setTimingController(TimingController controller)
- {
- this.timingController = controller;
- }
-
- /**
- * Gets the interface on the publishing end of the circuit.
- *
- * @return The publishing end of the circuit.
- */
- public Publisher getPublisher()
- {
- throw new RuntimeException("Not Implemented.");
- }
-
- /**
- * Gets the interface on the receiving end of the circuit.
- *
- * @return The receiving end of the circuit.
- */
- public Receiver getReceiver()
- {
- throw new RuntimeException("Not Implemented.");
- }
-
- /**
- * Connects and starts the circuit. After this method is called the circuit is ready to send messages.
- */
- public void start()
- {
- log.debug("public void start(): called");
-
- try
- {
- // Start the test on each of the senders.
- Message start = controlSession.createMessage();
- start.setStringProperty("CONTROL_TYPE", "START");
- start.setIntProperty("MESSAGE_COUNT", numMessages);
-
- for (int i = 0; i < senders.size(); i++)
- {
- senderConversation[i].send(senderControlTopic[i], start);
- }
-
- log.debug("All senders told to start their tests.");
- }
- catch (JMSException e)
- {
- throw new RuntimeException("Unhandled JMSException.", e);
- }
- }
-
- /**
- * Checks the test circuit. The effect of this is to gather the circuits state, for both ends of the circuit,
- * into a report, against which assertions may be checked.
- *
- * @todo Replace the asynch receiver report thread with a choice of direct or asynch executor, so that asynch
- * or synch logging of test timings is optional. Also need to provide an onMessage method that is capable
- * of receiving timing reports that receivers will generate during an ongoing test, on the test sample
- * size boundaries. The message timing logging code should be factored out as a common method that can
- * be called in response to the final report responses, or the onMessage method. Another alternative is
- * to abandon the final report request altogether and just use the onMessage method? I think the two
- * differ though, as the final report is used to apply assertions, and the ongoing report is just for
- * periodic timing results... In which case, maybe there needs to be a way for the onMessage method
- * to process just some of the incoming messages, and forward the rest on to the conversion helper, as
- * a sort of pre-conversation helper filter? Make conversation expose its onMessage method (it should
- * already) and allow another delivery thread to filter the incoming messages to the conversation.
- */
- public void check()
- {
- log.debug("public void check(): called");
-
- try
- {
- // Wait for all the test senders to return their reports.
- for (int i = 0; i < senders.size(); i++)
- {
- Message senderReport = senderConversation[i].receive();
- log.debug("Sender " + senderReport.getStringProperty("CLIENT_NAME") + " reports message count: "
- + senderReport.getIntProperty("MESSAGE_COUNT"));
- log.debug("Sender " + senderReport.getStringProperty("CLIENT_NAME") + " reports message time: "
- + senderReport.getLongProperty("TEST_TIME"));
- }
-
- log.debug("Got all sender test reports.");
-
- // Apply sender assertions to pass/fail the tests.
-
- // Inject a short pause to give the receivers time to finish receiving their test messages.
- TestUtils.pause(500);
-
- // Ask the receivers for their reports.
- Message statusRequest = controlSession.createMessage();
- statusRequest.setStringProperty("CONTROL_TYPE", "STATUS_REQUEST");
-
- for (int i = 0; i < receivers.size(); i++)
- {
- receiverConversation[i].send(receiverControlTopic[i], statusRequest);
- }
-
- log.debug("All receiver test reports requested.");
-
- // Wait for all receiver reports to come in, but do so asynchronously.
- Runnable gatherAllReceiverReports =
- new Runnable()
- {
- public void run()
- {
- try
- {
- // Wait for all the receivers to send their reports.
- for (int i = 0; i < receivers.size(); i++)
- {
- Message receiverReport = receiverConversation[i].receive();
-
- String clientName = receiverReport.getStringProperty("CLIENT_NAME");
- int messageCount = receiverReport.getIntProperty("MESSAGE_COUNT");
- long testTime = receiverReport.getLongProperty("TEST_TIME");
-
- log.debug("Receiver " + clientName + " reports message count: " + messageCount);
- log.debug("Receiver " + receiverReport.getStringProperty("CLIENT_NAME")
- + " reports message time: " + testTime);
-
- // Apply receiver assertions to pass/fail the tests.
-
- // Log the test timings on the asynchronous test timing controller.
- /*try
- {
- timingController.completeTest(true, messageCount, testTime);
- }
- // The timing controll can throw InterruptedException is the current test is to be
- // interrupted.
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }*/
- }
-
- log.debug("All receiver test reports received.");
- }
- catch (JMSException e)
- {
- throw new RuntimeException(e);
- }
- }
- };
-
- Thread receiverReportsThread = new Thread(gatherAllReceiverReports);
- receiverReportsThread.start();
-
- // return new Message[] { senderReport, receiverReport };
-
- }
- catch (JMSException e)
- {
- throw new RuntimeException("Unhandled JMSException.", e);
- }
- }
-
- /**
- * Closes the circuit. All associated resources are closed.
- */
- public void close()
- {
- log.debug("public void close(): called");
-
- // End the current test on all senders and receivers.
- }
-
- /**
- * Applies a list of assertions against the test circuit. The {@link #check()} method should be called before doing
- * this, to ensure that the circuit has gathered its state into a report to assert against.
- *
- * @param assertions The list of assertions to apply.
- *
- * @return Any assertions that failed.
- */
- public List<Assertion> applyAssertions(List<Assertion> assertions)
- {
- log.debug("public List<Assertion> applyAssertions(List<Assertion> assertions = " + assertions + "): called");
-
- List<Assertion> failures = new LinkedList<Assertion>();
-
- for (Assertion assertion : assertions)
- {
- if (!assertion.apply())
- {
- failures.add(assertion);
- }
- }
-
- return failures;
- }
-
- /**
- * Runs the default test procedure against the circuit, and checks that all of the specified assertions hold.
- *
- * @param numMessages The number of messages to send using the default test procedure.
- * @param assertions The list of assertions to apply.
- *
- * @return Any assertions that failed.
- *
- * @todo From check onwards needs to be handled as a future. The future must call back onto the test case to
- * report results asynchronously.
- */
- public List<Assertion> test(int numMessages, List<Assertion> assertions)
- {
- log.debug("public List<Assertion> test(int numMessages = " + numMessages + ", List<Assertion> assertions = "
- + assertions + "): called");
-
- // Keep the number of messages to send per test run, where the send method can reference it.
- this.numMessages = numMessages;
-
- // Start the test running on all sender circuit ends.
- start();
-
- // Request status reports to be handed in.
- check();
-
- // Assert conditions on the publishing end of the circuit.
- // Assert conditions on the receiving end of the circuit.
- List<Assertion> failures = applyAssertions(assertions);
-
- // Close the circuit ending the current test case.
- close();
-
- // Pass with no failed assertions or fail with a list of failed assertions.
- return failures;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedPublisherImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedPublisherImpl.java
deleted file mode 100644
index 130e908b0e..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedPublisherImpl.java
+++ /dev/null
@@ -1,94 +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.test.framework.distributedcircuit;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.Publisher;
-
-/**
- * DistributedPublisherImpl represents the status of the publishing side of a test circuit. Its main purpose is to
- * provide assertions that can be applied to verify the behaviour of a non-local publisher.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide assertion that the publishers received no exceptions.
- * <tr><td> Provide assertion that the publishers received a no consumers error code on every message.
- * <tr><td> Provide assertion that the publishers received a no route error code on every message.
- * </table>
- */
-public class DistributedPublisherImpl implements Publisher
-{
- /**
- * Provides an assertion that the publisher encountered no exceptions.
- *
- * @return An assertion that the publisher encountered no exceptions.
- * @param testProps
- */
- public Assertion noExceptionsAssertion(ParsedProperties testProps)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Provides an assertion that the publisher got a no consumers exception on every message.
- *
- * @return An assertion that the publisher got a no consumers exception on every message.
- */
- public Assertion noConsumersAssertion()
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Provides an assertion that the publisher got a no rout exception on every message.
- *
- * @return An assertion that the publisher got a no rout exception on every message.
- */
- public Assertion noRouteAssertion()
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Provides an assertion that the AMQP channel was forcibly closed by an error condition.
- *
- * @param testProps The test configuration properties.
- * @return An assertion that the AMQP channel was forcibly closed by an error condition.
- */
- public Assertion channelClosedAssertion(ParsedProperties testProps)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Provides an assertion that the publisher got a given exception during the test.
- *
- * @param testProps The test configuration properties.
- * @param exceptionClass The exception class to check for.
- * @return An assertion that the publisher got a given exception during the test.
- */
- public Assertion exceptionAssertion(ParsedProperties testProps, Class<? extends Exception> exceptionClass)
- {
- throw new RuntimeException("Not implemented.");
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedReceiverImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedReceiverImpl.java
deleted file mode 100644
index 4b801e7b66..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedReceiverImpl.java
+++ /dev/null
@@ -1,94 +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.test.framework.distributedcircuit;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.Receiver;
-
-/**
- * DistributedReceiverImpl represents the status of the receiving side of a test circuit. Its main purpose is to
- * provide assertions that can be applied to verify the behaviour of a non-local receiver.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide assertion that the receivers received no exceptions.
- * <tr><td> Provide assertion that the receivers received all test messages sent to it.
- * </table>
- */
-public class DistributedReceiverImpl implements Receiver
-{
- /**
- * Provides an assertion that the receivers encountered no exceptions.
- *
- * @return An assertion that the receivers encountered no exceptions.
- * @param testProps
- */
- public Assertion noExceptionsAssertion(ParsedProperties testProps)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Provides an assertion that the receivers got all messages that were sent to it.
- *
- * @return An assertion that the receivers got all messages that were sent to it.
- * @param testProps
- */
- public Assertion allMessagesReceivedAssertion(ParsedProperties testProps)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Provides an assertion that the receivers got none of the messages that were sent to it.
- *
- * @return An assertion that the receivers got none of the messages that were sent to it.
- * @param testProps
- */
- public Assertion noMessagesReceivedAssertion(ParsedProperties testProps)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Provides an assertion that the AMQP channel was forcibly closed by an error condition.
- *
- * @param testProps The test configuration properties.
- * @return An assertion that the AMQP channel was forcibly closed by an error condition.
- */
- public Assertion channelClosedAssertion(ParsedProperties testProps)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Provides an assertion that the receiver got a given exception during the test.
- *
- * @param testProps
- *@param exceptionClass The exception class to check for. @return An assertion that the receiver got a given exception during the test.
- */
- public Assertion exceptionAssertion(ParsedProperties testProps, Class<? extends Exception> exceptionClass)
- {
- throw new RuntimeException("Not implemented.");
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/TestClientCircuitEnd.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/TestClientCircuitEnd.java
deleted file mode 100644
index 09bcf24da5..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/TestClientCircuitEnd.java
+++ /dev/null
@@ -1,333 +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.test.framework.distributedcircuit;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.junit.extensions.util.TestContextProperties;
-import org.apache.qpid.test.framework.CircuitEnd;
-import org.apache.qpid.test.framework.ExceptionMonitor;
-import org.apache.qpid.test.framework.LocalCircuitFactory;
-import org.apache.qpid.test.framework.MessageMonitor;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-import org.apache.qpid.test.framework.TestUtils;
-import org.apache.qpid.test.framework.distributedtesting.TestClientControlledTest;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * A TestClientCircuitEnd is a {@link CircuitEnd} that may be controlled from a
- * {@link org.apache.qpid.test.framework.distributedtesting.TestClient}, and that forms a single publishing or
- * receiving end point in a distributed test {@link org.apache.qpid.test.framework.Circuit}.
- *
- * <p/>When operating in the SENDER role, this circuit end is capable of acting as part of the default circuit test
- * procedure (described in the class comment for {@link org.apache.qpid.test.framework.Circuit}). That is, it will
- * send the number of test messages required, using the test configuration parameters given in the test invite, and
- * return a report on its activities to the circuit controller.
- *
- * <p/>When operation in the RECEIVER role, this circuit end acts as part of the default circuit test procedure. It will
- * receive test messages, on the setup specified in the test configuration parameters, and keep count of the messages
- * received, and time taken to receive them. When requested by the circuit controller to provide a report, it will
- * return this report of its activities.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide a message producer for sending messages.
- * <td> {@link CircuitEnd}, {@link LocalCircuitFactory}, {@link TestUtils}
- * <tr><td> Provide a message consumer for receiving messages.
- * <td> {@link CircuitEnd}, {@link LocalCircuitFactory}, {@link TestUtils}
- * <tr><td> Supply the name of the test case that this implements.
- * <tr><td> Accept/Reject invites based on test parameters. <td> {@link MessagingTestConfigProperties}
- * <tr><td> Adapt to assigned roles. <td> {@link TestClientControlledTest.Roles}
- * <tr><td> Perform test case actions. <td> {@link MessageMonitor}
- * <tr><td> Generate test reports. <td> {@link MessageMonitor}
- * </table>
- */
-public class TestClientCircuitEnd implements CircuitEnd, TestClientControlledTest
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(TestClientCircuitEnd.class);
-
- /** Holds the test parameters. */
- ParsedProperties testProps;
-
- /** The number of test messages to send. */
- private int numMessages;
-
- /** The role to be played by the test. */
- private Roles role;
-
- /** The connection to send the test messages on. */
- private Connection connection;
-
- /** Holds the circuit end for this test. */
- CircuitEnd circuitEnd;
-
- /**
- * Holds a message monitor for this circuit end, either the monitor on the consumer when in RECEIVER more, or
- * a monitor updated on every message sent, when acting as a SENDER.
- */
- MessageMonitor messageMonitor;
-
- /**
- * Should provide the name of the test case that this class implements. The exact names are defined in the
- * interop testing spec.
- *
- * @return The name of the test case that this implements.
- */
- public String getName()
- {
- return "DEFAULT_CIRCUIT_TEST";
- }
-
- /**
- * Determines whether the test invite that matched this test case is acceptable.
- *
- * @param inviteMessage The invitation to accept or reject.
- * @return <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- */
- public boolean acceptInvite(Message inviteMessage) throws JMSException
- {
- log.debug("public boolean acceptInvite(Message inviteMessage): called");
-
- // Populate the test parameters from the invitation.
- testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
-
- for (Object key : testProps.keySet())
- {
- String propName = (String) key;
-
- // If the test parameters is overridden by the invitation, use it instead.
- String inviteValue = inviteMessage.getStringProperty(propName);
-
- if (inviteValue != null)
- {
- testProps.setProperty(propName, inviteValue);
- log.debug("Test invite supplied override to " + propName + " of " + inviteValue);
- }
-
- }
-
- // Accept the invitation.
- return true;
- }
-
- /**
- * Assigns the role to be played by this test case. The test parameters are fully specified in the
- * assignment message. When this method return the test case will be ready to execute.
- *
- * @param role The role to be played; sender or receivers.
- * @param assignRoleMessage The role assingment message, contains the full test parameters.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- */
- public void assignRole(Roles role, Message assignRoleMessage) throws JMSException
- {
- log.debug("public void assignRole(Roles role, Message assignRoleMessage): called");
-
- // Take note of the role to be played.
- this.role = role;
-
- // Extract and retain the test parameters.
- numMessages = 1; // assignRoleMessage.getIntProperty("NUM_MESSAGES");
-
- // Connect using the test parameters.
- connection = TestUtils.createConnection(testProps);
-
- // Create a circuit end that matches the assigned role and test parameters.
- LocalCircuitFactory circuitFactory = new LocalCircuitFactory();
-
- switch (role)
- {
- // Check if the sender role is being assigned, and set up a message producer if so.
- case SENDER:
-
- // Set up the publisher.
- circuitEnd = circuitFactory.createPublisherCircuitEnd(connection, testProps, 0L);
-
- // Create a custom message monitor that will be updated on every message sent.
- messageMonitor = new MessageMonitor();
-
- break;
-
- // Otherwise the receivers role is being assigned, so set this up to listen for messages.
- case RECEIVER:
-
- // Set up the receiver.
- circuitEnd = circuitFactory.createReceiverCircuitEnd(connection, testProps, 0L);
-
- // Use the message monitor from the consumer for stats.
- messageMonitor = getMessageMonitor();
-
- break;
- }
-
- // Reset all messaging stats for the report.
- messageMonitor.reset();
-
- connection.start();
- }
-
- /**
- * Performs the test case actions. Returning from here, indicates that the sending role has completed its test.
- *
- * @param numMessages The number of test messages to send.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- *
- * @todo Add round robin on destinations where multiple destinations being used.
- *
- * @todo Add rate limiting when rate limit specified on publishers.
- *
- * @todo Add Max pending message size protection. The receiver will have to send back some acks once in a while,
- * to notify the publisher that its messages are being consumed. This makes the safety valve harder to
- * implement than in the single VM case. For example, if the limit is 1000 messages, might want to get back
- * an ack every 500, to notify the publisher that it can keep sending. What about pub/sub tests? Will it be
- * necessary to wait for an ack from every receiver? This will have the effect of rate limiting to slow
- * consumers too.
- *
- * @todo Add commits on every commit batch size boundary.
- */
- public void start(int numMessages) throws JMSException
- {
- log.debug("public void start(): called");
-
- // If in the SENDER role, send the specified number of test messages to the circuit destinations.
- if (role.equals(Roles.SENDER))
- {
- Message testMessage = getSession().createMessage();
-
- for (int i = 0; i < numMessages; i++)
- {
- getProducer().send(testMessage);
-
- // Increment the message count and timings.
- messageMonitor.onMessage(testMessage);
- }
- }
- }
-
- /**
- * Gets a report on the actions performed by the test case in its assigned role.
- *
- * @param session The controlSession to create the report message in.
- * @return The report message.
- *
- * @throws JMSException Any JMSExceptions resulting from creating the report are allowed to fall through.
- */
- public Message getReport(Session session) throws JMSException
- {
- Message report = session.createMessage();
- report.setStringProperty("CONTROL_TYPE", "REPORT");
-
- // Add the count of messages sent/received to the report.
- report.setIntProperty("MESSAGE_COUNT", messageMonitor.getNumMessage());
-
- // Add the time to send/receive messages to the report.
- report.setLongProperty("TEST_TIME", messageMonitor.getTime());
-
- // Add any exceptions detected to the report.
-
- return report;
- }
-
- /**
- * Gets the message producer at this circuit end point.
- *
- * @return The message producer at with this circuit end point.
- */
- public MessageProducer getProducer()
- {
- return circuitEnd.getProducer();
- }
-
- /**
- * Gets the message consumer at this circuit end point.
- *
- * @return The message consumer at this circuit end point.
- */
- public MessageConsumer getConsumer()
- {
- return circuitEnd.getConsumer();
- }
-
- /**
- * Send the specified message over the producer at this end point.
- *
- * @param message The message to send.
- *
- * @throws JMSException Any JMS exception occuring during the send is allowed to fall through.
- */
- public void send(Message message) throws JMSException
- {
- // Send the message on the circuit ends producer.
- circuitEnd.send(message);
- }
-
- /**
- * Gets the JMS Session associated with this circuit end point.
- *
- * @return The JMS Session associated with this circuit end point.
- */
- public Session getSession()
- {
- return circuitEnd.getSession();
- }
-
- /**
- * Closes the message producers and consumers and the sessions, associated with this circuit end point.
- *
- * @throws JMSException Any JMSExceptions occurring during the close are allowed to fall through.
- */
- public void close() throws JMSException
- {
- // Close the producer and consumer.
- circuitEnd.close();
- }
-
- /**
- * Returns the message monitor for reporting on received messages on this circuit end.
- *
- * @return The message monitor for this circuit end.
- */
- public MessageMonitor getMessageMonitor()
- {
- return circuitEnd.getMessageMonitor();
- }
-
- /**
- * Returns the exception monitor for reporting on exceptions received on this circuit end.
- *
- * @return The exception monitor for this circuit end.
- */
- public ExceptionMonitor getExceptionMonitor()
- {
- return circuitEnd.getExceptionMonitor();
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/Coordinator.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/Coordinator.java
deleted file mode 100644
index e07b141cb5..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/Coordinator.java
+++ /dev/null
@@ -1,546 +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.test.framework.distributedtesting;
-
-import junit.framework.Test;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-import org.apache.log4j.Logger;
-import org.apache.log4j.NDC;
-
-import org.apache.qpid.junit.extensions.TKTestRunner;
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-import org.apache.qpid.junit.extensions.util.CommandLineParser;
-import org.apache.qpid.junit.extensions.util.MathUtils;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.junit.extensions.util.TestContextProperties;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.framework.TestUtils;
-import org.apache.qpid.test.framework.clocksynch.UDPClockReference;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/**
- * <p/>Implements the coordinator client described in the interop testing specification
- * (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). This coordinator is built on
- * top of the JUnit testing framework.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Find out what test clients are available. <td> {@link ConversationFactory}
- * <tr><td> Decorate available tests to run on all available clients. <td> {@link DistributedTestDecorator}
- * <tr><td> Attach XML test result logger.
- * <tr><td> Terminate the interop testing framework.
- * </table>
- *
- * @todo Should accumulate failures over all tests, and return with success or fail code based on all results. May need
- * to write a special TestResult to do this properly. At the moment only the last one used will be tested for
- * errors, as the start method creates a fresh one for each test case run.
- */
-public class Coordinator extends TKTestRunner
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(Coordinator.class);
-
- /** Used for reporting to the console. */
- private static final Logger console = Logger.getLogger("CONSOLE");
-
- /** Defines the possible distributed test engines available to run coordinated test cases with. */
- public enum TestEngine
- {
- /** Specifies the interop test engine. This tests all available clients in pairs. */
- INTEROP,
-
- /** Specifies the fanout test engine. This sets up one publisher role, and many reciever roles. */
- FANOUT
- }
-
- /**
- * Holds the test context properties that provides the default test parameters, plus command line overrides.
- * This is initialized with the default test parameters, to which command line overrides may be applied.
- */
- protected static ParsedProperties testContextProperties =
- TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
-
- /** Holds the URL of the broker to coordinate the tests on. */
- protected String brokerUrl;
-
- /** Holds the virtual host to coordinate the tests on. If <tt>null</tt>, then the default virtual host is used. */
- protected String virtualHost;
-
- /** Holds the list of all clients that enlisted, when the compulsory invite was issued. */
- protected Set<TestClientDetails> enlistedClients = new HashSet<TestClientDetails>();
-
- /** Holds the conversation helper for the control conversation. */
- protected ConversationFactory conversationFactory;
-
- /** Holds the connection that the coordinating messages are sent over. */
- protected Connection connection;
-
- /** Holds the path of the directory to output test results too, if one is defined. */
- protected String reportDir;
-
- /** Holds the coordinating test engine type to run the tests through. */
- protected TestEngine engine;
-
- /** Flag that indicates that all test clients should be terminated upon completion of the test cases. */
- protected boolean terminate;
-
- /**
- * Creates an interop test coordinator on the specified broker and virtual host.
- *
- * @param repetitions The number of times to repeat the test, or test batch size.
- * @param duration The length of time to run the tests for. -1 means no duration has been set.
- * @param threads The concurrency levels to ramp up to.
- * @param delay A delay in milliseconds between test runs.
- * @param params The sets of 'size' parameters to pass to test.
- * @param testCaseName The name of the test case to run.
- * @param reportDir The directory to output the test results to.
- * @param runName The name of the test run; used to name the output file.
- * @param verbose Whether to print comments during test run.
- * @param brokerUrl The URL of the broker to connect to.
- * @param virtualHost The virtual host to run all tests on. Optional, may be <tt>null</tt>.
- * @param engine The distributed test engine type to run the tests with.
- * @param terminate <tt>true</tt> if test client nodes should be terminated at the end of the tests.
- * @param csv <tt>true</tt> if the CSV results listener should be attached.
- * @param xml <tt>true</tt> if the XML results listener should be attached.
- * @param decoratorFactories List of factories for user specified decorators.
- */
- public Coordinator(Integer repetitions, Long duration, int[] threads, int delay, int[] params, String testCaseName,
- String reportDir, String runName, boolean verbose, String brokerUrl, String virtualHost, TestEngine engine,
- boolean terminate, boolean csv, boolean xml, List<TestDecoratorFactory> decoratorFactories)
- {
- super(repetitions, duration, threads, delay, params, testCaseName, reportDir, runName, csv, xml, decoratorFactories);
-
- log.debug("public Coordinator(Integer repetitions = " + repetitions + " , Long duration = " + duration
- + ", int[] threads = " + Arrays.toString(threads) + ", int delay = " + delay + ", int[] params = "
- + Arrays.toString(params) + ", String testCaseName = " + testCaseName + ", String reportDir = " + reportDir
- + ", String runName = " + runName + ", boolean verbose = " + verbose + ", String brokerUrl = " + brokerUrl
- + ", String virtualHost =" + virtualHost + ", TestEngine engine = " + engine + ", boolean terminate = "
- + terminate + ", boolean csv = " + csv + ", boolean xml = " + xml + "): called");
-
- // Retain the connection parameters.
- this.brokerUrl = brokerUrl;
- this.virtualHost = virtualHost;
- this.reportDir = reportDir;
- this.engine = engine;
- this.terminate = terminate;
- }
-
- /**
- * The entry point for the interop test coordinator. This client accepts the following command line arguments:
- *
- * <p/><table>
- * <tr><td> -b <td> The broker URL. <td> Mandatory.
- * <tr><td> -h <td> The virtual host. <td> Optional.
- * <tr><td> -o <td> The directory to output test results to. <td> Optional.
- * <tr><td> -e <td> The type of test distribution engine to use. <td> Optional. One of: interop, fanout.
- * <tr><td> ... <td> Free arguments. The distributed test cases to run.
- * <td> Mandatory. At least one must be defined.
- * <tr><td> name=value <td> Trailing argument define name/value pairs. Added to the test contenxt properties.
- * <td> Optional.
- * </table>
- *
- * @param args The command line arguments.
- */
- public static void main(String[] args)
- {
- NDC.push("coordinator");
- log.debug("public static void main(String[] args = " + Arrays.toString(args) + "): called");
- console.info("Qpid Distributed Test Coordinator.");
-
- // Override the default broker url to be localhost:5672.
- testContextProperties.setProperty(MessagingTestConfigProperties.BROKER_PROPNAME, "tcp://localhost:5672");
-
- try
- {
- // Use the command line parser to evaluate the command line with standard handling behaviour (print errors
- // and usage then exist if there are errors).
- // Any options and trailing name=value pairs are also injected into the test context properties object,
- // to override any defaults that may have been set up.
- ParsedProperties options =
- new ParsedProperties(CommandLineParser.processCommandLine(args,
- new CommandLineParser(
- new String[][]
- {
- { "b", "The broker URL.", "broker", "false" },
- { "h", "The virtual host to use.", "virtual host", "false" },
- { "o", "The name of the directory to output test timings to.", "dir", "false" },
- {
- "e", "The test execution engine to use. Default is interop.", "engine", "interop",
- "^interop$|^fanout$", "true"
- },
- { "t", "Terminate test clients on completion of tests.", null, "false" },
- { "-csv", "Output test results in CSV format.", null, "false" },
- { "-xml", "Output test results in XML format.", null, "false" },
- {
- "-trefaddr", "To specify an alternative to hostname for time singal reference.",
- "address", "false"
- },
- {
- "c", "The number of tests to run concurrently.", "num", "false",
- MathUtils.SEQUENCE_REGEXP
- },
- { "r", "The number of times to repeat each test.", "num", "false" },
- {
- "d", "The length of time to run the tests for.", "duration", "false",
- MathUtils.DURATION_REGEXP
- },
- {
- "f", "The maximum rate to call the tests at.", "frequency", "false",
- "^([1-9][0-9]*)/([1-9][0-9]*)$"
- },
- { "s", "The size parameter to run tests with.", "size", "false", MathUtils.SEQUENCE_REGEXP },
- { "v", "Verbose mode.", null, "false" },
- { "n", "A name for this test run, used to name the output file.", "name", "true" },
- {
- "X:decorators", "A list of additional test decorators to wrap the tests in.",
- "\"class.name[:class.name]*\"", "false"
- }
- }), testContextProperties));
-
- // Extract the command line options.
- String brokerUrl = options.getProperty("b");
- String virtualHost = options.getProperty("h");
- String reportDir = options.getProperty("o");
- reportDir = (reportDir == null) ? "." : reportDir;
- String testEngine = options.getProperty("e");
- TestEngine engine = "fanout".equals(testEngine) ? TestEngine.FANOUT : TestEngine.INTEROP;
- boolean terminate = options.getPropertyAsBoolean("t");
- boolean csvResults = options.getPropertyAsBoolean("-csv");
- boolean xmlResults = options.getPropertyAsBoolean("-xml");
- String threadsString = options.getProperty("c");
- Integer repetitions = options.getPropertyAsInteger("r");
- String durationString = options.getProperty("d");
- String paramsString = options.getProperty("s");
- boolean verbose = options.getPropertyAsBoolean("v");
- String testRunName = options.getProperty("n");
- String decorators = options.getProperty("X:decorators");
-
- int[] threads = (threadsString == null) ? null : MathUtils.parseSequence(threadsString);
- int[] params = (paramsString == null) ? null : MathUtils.parseSequence(paramsString);
- Long duration = (durationString == null) ? null : MathUtils.parseDuration(durationString);
-
- // If broker or virtual host settings were specified as command line options, override the defaults in the
- // test context properties with them.
-
- // Collection all of the test cases to be run.
- Collection<Class<? extends FrameworkBaseCase>> testCaseClasses =
- new ArrayList<Class<? extends FrameworkBaseCase>>();
-
- // Create a list of test decorator factories for use specified decorators to be applied.
- List<TestDecoratorFactory> decoratorFactories = parseDecorators(decorators);
-
- // Scan for available test cases using a classpath scanner.
- // ClasspathScanner.getMatches(DistributedTestCase.class, "^Test.*", true);
-
- // Hard code the test classes till the classpath scanner is fixed.
- // Collections.addAll(testCaseClasses, InteropTestCase1DummyRun.class, InteropTestCase2BasicP2P.class,
- // InteropTestCase3BasicPubSub.class);
-
- // Parse all of the free arguments as test cases to run.
- for (int i = 1; true; i++)
- {
- String nextFreeArg = options.getProperty(Integer.toString(i));
-
- // Terminate the loop once all free arguments have been consumed.
- if (nextFreeArg == null)
- {
- break;
- }
-
- try
- {
- Class nextClass = Class.forName(nextFreeArg);
-
- if (FrameworkBaseCase.class.isAssignableFrom(nextClass))
- {
- testCaseClasses.add(nextClass);
- console.info("Found distributed test case: " + nextFreeArg);
- }
- }
- catch (ClassNotFoundException e)
- {
- console.info("Unable to instantiate the test case: " + nextFreeArg + ".");
- }
- }
-
- // Check that some test classes were actually found.
- if (testCaseClasses.isEmpty())
- {
- throw new RuntimeException(
- "No test cases implementing FrameworkBaseCase were specified on the command line.");
- }
-
- // Extract the names of all the test classes, to pass to the start method.
- int i = 0;
- String[] testClassNames = new String[testCaseClasses.size()];
-
- for (Class testClass : testCaseClasses)
- {
- testClassNames[i++] = testClass.getName();
- }
-
- // Create a coordinator and begin its test procedure.
- Coordinator coordinator =
- new Coordinator(repetitions, duration, threads, 0, params, null, reportDir, testRunName, verbose, brokerUrl,
- virtualHost, engine, terminate, csvResults, xmlResults, decoratorFactories);
-
- TestResult testResult = coordinator.start(testClassNames);
-
- // Return different error codes, depending on whether or not there were test failures.
- if (testResult.failureCount() > 0)
- {
- System.exit(FAILURE_EXIT);
- }
- else
- {
- System.exit(SUCCESS_EXIT);
- }
- }
- catch (Exception e)
- {
- log.debug("Top level handler caught execption.", e);
- console.info(e.getMessage());
- e.printStackTrace();
- System.exit(EXCEPTION_EXIT);
- }
- }
-
- /**
- * Starts all of the test classes to be run by this coordinator.
- *
- * @param testClassNames An array of all the coordinating test case implementations.
- *
- * @return A JUnit TestResult to run the tests with.
- *
- * @throws Exception Any underlying exceptions are allowed to fall through, and fail the test process.
- */
- public TestResult start(String[] testClassNames) throws Exception
- {
- log.debug("public TestResult start(String[] testClassNames = " + Arrays.toString(testClassNames) + ": called");
-
- // Connect to the broker.
- connection = TestUtils.createConnection(TestContextProperties.getInstance());
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Destination controlTopic = session.createTopic("iop.control");
- Destination responseQueue = session.createQueue("coordinator");
-
- conversationFactory = new ConversationFactory(connection, responseQueue, LinkedBlockingQueue.class);
- ConversationFactory.Conversation conversation = conversationFactory.startConversation();
-
- connection.start();
-
- // Broadcast the compulsory invitation to find out what clients are available to test.
- Message invite = session.createMessage();
- invite.setStringProperty("CONTROL_TYPE", "INVITE");
- invite.setJMSReplyTo(responseQueue);
-
- conversation.send(controlTopic, invite);
-
- // Wait for a short time, to give test clients an opportunity to reply to the invitation.
- Collection<Message> enlists = conversation.receiveAll(0, 500);
- enlistedClients = extractEnlists(enlists);
-
- for (TestClientDetails client : enlistedClients)
- {
- log.debug("Got enlisted test client: " + client);
- console.info("Test node " + client.clientName + " available.");
- }
-
- // Start the clock reference service running.
- UDPClockReference clockReference = new UDPClockReference();
- Thread clockRefThread = new Thread(clockReference);
- registerShutdownHook(clockReference);
- clockRefThread.start();
-
- // Broadcast to all clients to synchronize their clocks against the coordinators clock reference.
- Message clockSynchRequest = session.createMessage();
- clockSynchRequest.setStringProperty("CONTROL_TYPE", "CLOCK_SYNCH");
-
- String localAddress = InetAddress.getByName(InetAddress.getLocalHost().getHostName()).getHostAddress();
- clockSynchRequest.setStringProperty("ADDRESS", localAddress);
-
- conversation.send(controlTopic, clockSynchRequest);
-
- // Run the test in the suite using JUnit.
- TestResult result = null;
-
- for (String testClassName : testClassNames)
- {
- // Record the current test class, so that the test results can be output to a file incorporating this name.
- this.currentTestClassName = testClassName;
-
- result = super.start(new String[] { testClassName });
- }
-
- // At this point in time, all tests have completed. Broadcast the shutdown message, if the termination option
- // was set on the command line.
- if (terminate)
- {
- Message terminate = session.createMessage();
- terminate.setStringProperty("CONTROL_TYPE", "TERMINATE");
-
- conversation.send(controlTopic, terminate);
- }
-
- return result;
- }
-
- /**
- * For a collection of enlist messages, this method pulls out of the client details for the enlisting clients.
- *
- * @param enlists The enlist messages.
- *
- * @return A set of enlisting clients, extracted from the enlist messages.
- *
- * @throws JMSException Any underlying JMSException is allowed to fall through.
- */
- public static Set<TestClientDetails> extractEnlists(Collection<Message> enlists) throws JMSException
- {
- log.debug("public static Set<TestClientDetails> extractEnlists(Collection<Message> enlists = " + enlists
- + "): called");
-
- Set<TestClientDetails> enlistedClients = new HashSet<TestClientDetails>();
-
- // Retain the list of all available clients.
- for (Message enlist : enlists)
- {
- TestClientDetails clientDetails = new TestClientDetails();
- clientDetails.clientName = enlist.getStringProperty("CLIENT_NAME");
- clientDetails.privateControlKey = enlist.getStringProperty("CLIENT_PRIVATE_CONTROL_KEY");
-
- String replyType = enlist.getStringProperty("CONTROL_TYPE");
-
- if ("ENLIST".equals(replyType))
- {
- enlistedClients.add(clientDetails);
- }
- else if ("DECLINE".equals(replyType))
- {
- log.debug("Test client " + clientDetails.clientName + " declined the invite.");
- }
- else
- {
- log.warn("Got an unknown reply type, " + replyType + ", to the invite.");
- }
- }
-
- return enlistedClients;
- }
-
- /**
- * Runs a test or suite of tests, using the super class implemenation. This method wraps the test to be run
- * in any test decorators needed to add in the coordinators ability to invite test clients to participate in
- * tests.
- *
- * @param test The test to run.
- * @param wait Undocumented. Nothing in the JUnit javadocs to say what this is for.
- *
- * @return The results of the test run.
- */
- public TestResult doRun(Test test, boolean wait)
- {
- log.debug("public TestResult doRun(Test \"" + test + "\", boolean " + wait + "): called");
-
- // Wrap all tests in the test suite with WrappedSuiteTestDecorators. This is quite ugly and a bit baffling,
- // but the reason it is done is because the JUnit implementation of TestDecorator has some bugs in it.
- WrappedSuiteTestDecorator targetTest = null;
-
- if (test instanceof TestSuite)
- {
- log.debug("targetTest is a TestSuite");
-
- TestSuite suite = (TestSuite)test;
-
- int numTests = suite.countTestCases();
- log.debug("There are " + numTests + " in the suite.");
-
- for (int i = 0; i < numTests; i++)
- {
- Test nextTest = suite.testAt(i);
- log.debug("suite.testAt(" + i + ") = " + nextTest);
-
- if (nextTest instanceof FrameworkBaseCase)
- {
- log.debug("nextTest is a FrameworkBaseCase");
- }
- }
-
- targetTest = new WrappedSuiteTestDecorator(suite);
- log.debug("Wrapped with a WrappedSuiteTestDecorator.");
- }
-
- // Apply any optional user specified decorators.
- targetTest = applyOptionalUserDecorators(targetTest);
-
- // Wrap the tests in a suitable distributed test decorator, to perform the invite/test cycle.
- targetTest = newTestDecorator(targetTest, enlistedClients, conversationFactory, connection);
-
- // TestSuite suite = new TestSuite();
- // suite.addTest(targetTest);
-
- // Wrap the tests in a scaled test decorator to them them as a 'batch' in one thread.
- // targetTest = new ScaledTestDecorator(targetTest, new int[] { 1 });
-
- return super.doRun(targetTest, wait);
- }
-
- /**
- * Creates a wrapped test decorator, that is capable of inviting enlisted clients to participate in a specified
- * test. This is the test engine that sets up the roles and sequences a distributed test case.
- *
- * @param targetTest The test decorator to wrap.
- * @param enlistedClients The enlisted clients available to run the test.
- * @param conversationFactory The conversation factory used to build conversation helper over the specified connection.
- * @param connection The connection to talk to the enlisted clients over.
- *
- * @return An invititing test decorator, that invites all the enlisted clients to participate in tests, in pairs.
- */
- protected DistributedTestDecorator newTestDecorator(WrappedSuiteTestDecorator targetTest,
- Set<TestClientDetails> enlistedClients, ConversationFactory conversationFactory, Connection connection)
- {
- switch (engine)
- {
- case FANOUT:
- return new FanOutTestDecorator(targetTest, enlistedClients, conversationFactory, connection);
- case INTEROP:
- default:
- return new InteropTestDecorator(targetTest, enlistedClients, conversationFactory, connection);
- }
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/DistributedTestDecorator.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/DistributedTestDecorator.java
deleted file mode 100644
index 49a01d3127..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/DistributedTestDecorator.java
+++ /dev/null
@@ -1,164 +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.test.framework.distributedtesting;
-
-import junit.framework.TestResult;
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * DistributedTestDecorator is a base class for writing test decorators that invite test clients to participate in
- * distributed test cases. It provides a helper method, {@link #signupClients}, that broadcasts an invitation and
- * returns the set of test clients that are available to particiapte in the test.
- *
- * <p/>When used to wrap a {@link FrameworkBaseCase} test, it replaces the default {@link CircuitFactory} implementations
- * with a suitable circuit factory for distributed tests. Concrete implementations can use this to configure the sending
- * and receiving roles on the test.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Broadcast test invitations and collect enlists. <td> {@link ConversationFactory}.
- * </table>
- */
-public abstract class DistributedTestDecorator extends WrappedSuiteTestDecorator
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(DistributedTestDecorator.class);
-
- /** Holds the contact information for all test clients that are available and that may take part in the test. */
- Set<TestClientDetails> allClients;
-
- /** Holds the conversation helper for the control level conversation for coordinating the test through. */
- ConversationFactory conversationFactory;
-
- /** Holds the connection that the control conversation is held over. */
- Connection connection;
-
- /** Holds the underlying test suite that this decorator wraps. */
- WrappedSuiteTestDecorator testSuite;
-
- /** Holds the control topic, on which test invitations are broadcast. */
- protected Destination controlTopic;
-
- /**
- * Creates a wrapped suite test decorator from another one.
- *
- * @param suite The test suite.
- * @param availableClients The list of all clients that responded to the compulsory invite.
- * @param controlConversation The conversation helper for the control level, test coordination conversation.
- * @param controlConnection The connection that the coordination messages are sent over.
- */
- public DistributedTestDecorator(WrappedSuiteTestDecorator suite, Set<TestClientDetails> availableClients,
- ConversationFactory controlConversation, Connection controlConnection)
- {
- super(suite);
-
- log.debug("public DistributedTestDecorator(WrappedSuiteTestDecorator suite, Set<TestClientDetails> allClients = "
- + availableClients + ", ConversationHelper controlConversation = " + controlConversation + "): called");
-
- testSuite = suite;
- allClients = availableClients;
- conversationFactory = controlConversation;
- connection = controlConnection;
-
- // Set up the test control topic.
- try
- {
- controlTopic = conversationFactory.getSession().createTopic("iop.control");
- }
- catch (JMSException e)
- {
- throw new RuntimeException("Unable to create the coordinating control topic to broadcast test invites on.", e);
- }
- }
-
- /**
- * Should run all of the tests in the wrapped test suite.
- *
- * @param testResult The the results object to monitor the test results with.
- */
- public abstract void run(TestResult testResult);
-
- /**
- * Should provide the distributed test sequencer to pass to {@link org.apache.qpid.test.framework.FrameworkBaseCase}
- * tests.
- *
- * @return A distributed test sequencer.
- */
- public abstract CircuitFactory getTestSequencer();
-
- /**
- * Broadcasts an invitation to participate in a coordinating test case to find out what clients are available to
- * run the test case.
- *
- * @param coordTest The coordinating test case to broadcast an inviate for.
- *
- * @return A set of test clients that accepted the invitation.
- */
- protected Set<TestClientDetails> signupClients(FrameworkBaseCase coordTest)
- {
- // Broadcast the invitation to find out what clients are available to test.
- Set<TestClientDetails> enlists;
- try
- {
- Message invite = conversationFactory.getSession().createMessage();
-
- ConversationFactory.Conversation conversation = conversationFactory.startConversation();
-
- invite.setStringProperty("CONTROL_TYPE", "INVITE");
- invite.setStringProperty("TEST_NAME", coordTest.getTestCaseNameForTestMethod(coordTest.getName()));
-
- conversation.send(controlTopic, invite);
-
- // Wait for a short time, to give test clients an opportunity to reply to the invitation.
- Collection<Message> replies = conversation.receiveAll(allClients.size(), 500);
- enlists = Coordinator.extractEnlists(replies);
- }
- catch (JMSException e)
- {
- throw new RuntimeException("There was a JMSException during the invite/enlist conversation.", e);
- }
-
- return enlists;
- }
-
- /**
- * Prints a string summarizing this test decorator, mainly for debugging purposes.
- *
- * @return String representation for debugging purposes.
- */
- public String toString()
- {
- return "DistributedTestDecorator: [ testSuite = " + testSuite + " ]";
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/FanOutTestDecorator.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/FanOutTestDecorator.java
deleted file mode 100644
index 809bb1dd2f..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/FanOutTestDecorator.java
+++ /dev/null
@@ -1,241 +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.test.framework.distributedtesting;
-
-import junit.framework.Test;
-import junit.framework.TestResult;
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-import org.apache.qpid.test.framework.DropInTest;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-import org.apache.qpid.test.framework.sequencers.FanOutCircuitFactory;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * FanOutTestDecorator is an {@link DistributedTestDecorator} that runs one test client in the sender role, and the remainder
- * in the receivers role. It also has the capability to listen for new test cases joining the test beyond the initial start
- * point. This feature can be usefull when experimenting with adding more load, in the form of more test clients, to assess
- * its impact on a running test.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Execute coordinated test cases. <td> {@link FrameworkBaseCase}
- * <tr><td> Accept test clients joining a running test.
- * </table>
- */
-public class FanOutTestDecorator extends DistributedTestDecorator implements MessageListener
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(FanOutTestDecorator.class);
-
- /** Holds the currently running test case. */
- private FrameworkBaseCase currentTest = null;
-
- /**
- * Creates a wrapped suite test decorator from another one.
- *
- * @param suite The test suite.
- * @param availableClients The list of all clients that responded to the compulsory invite.
- * @param controlConversation The conversation helper for the control level, test coordination conversation.
- * @param controlConnection The connection that the coordination messages are sent over.
- */
- public FanOutTestDecorator(WrappedSuiteTestDecorator suite, Set<TestClientDetails> availableClients,
- ConversationFactory controlConversation, Connection controlConnection)
- {
- super(suite, availableClients, controlConversation, controlConnection);
-
- log.debug("public DistributedTestDecorator(WrappedSuiteTestDecorator suite, Set<TestClientDetails> allClients = "
- + availableClients + ", ConversationHelper controlConversation = " + controlConversation + "): called");
-
- testSuite = suite;
- allClients = availableClients;
- conversationFactory = controlConversation;
- connection = controlConnection;
-
- // Sign available clients up to the test.
- for (Test test : getAllUnderlyingTests())
- {
- FrameworkBaseCase coordTest = (FrameworkBaseCase) test;
-
- // Get all of the clients able to participate in the test.
- Set<TestClientDetails> enlists = signupClients(coordTest);
-
- // Check that there were some clients available.
- if (enlists.size() == 0)
- {
- throw new RuntimeException("No clients to test with");
- }
-
- // Create a distributed test circuit factory for the test.
- CircuitFactory circuitFactory = getTestSequencer();
-
- // Set up the first client in the sender role, and the remainder in the receivers role.
- Iterator<TestClientDetails> clients = enlists.iterator();
- circuitFactory.setSender(clients.next());
-
- while (clients.hasNext())
- {
- // Set the sending and receiving client details on the test case.
- circuitFactory.setReceiver(clients.next());
- }
-
- // Pass down the connection to hold the coordinating conversation over.
- circuitFactory.setConversationFactory(conversationFactory);
-
- // If the current test case is a drop-in test, set it up as the currently running test for late joiners to
- // add in to. Otherwise the current test field is set to null, to indicate that late joiners are not allowed.
- currentTest = (coordTest instanceof DropInTest) ? coordTest : null;
-
- // Execute the test case.
- coordTest.setCircuitFactory(circuitFactory);
- }
- }
-
- /**
- * Broadcasts a test invitation and accepts enlists from participating clients. The wrapped test cases are run
- * with one test client in the sender role, and the remaining test clients in the receiving role.
- *
- * <p/>Any JMSExceptions during the invite/enlist conversation will be allowed to fall through as runtime
- * exceptions, resulting in the non-completion of the test run.
- *
- * @param testResult The the results object to monitor the test results with.
- *
- * @todo Better error recovery for failure of the invite/enlist conversation could be added.
- */
- public void run(TestResult testResult)
- {
- log.debug("public void run(TestResult testResult): called");
-
- // Listen for late joiners on the control topic.
- try
- {
- conversationFactory.getSession().createConsumer(controlTopic).setMessageListener(this);
- }
- catch (JMSException e)
- {
- throw new RuntimeException("Unable to set up the message listener on the control topic.", e);
- }
-
- // Run all of the test cases in the test suite.
- /*for (Test test : getAllUnderlyingTests())
- {
- FrameworkBaseCase coordTest = (FrameworkBaseCase) test;
-
- // Get all of the clients able to participate in the test.
- Set<TestClientDetails> enlists = signupClients(coordTest);
-
- // Check that there were some clients available.
- if (enlists.size() == 0)
- {
- throw new RuntimeException("No clients to test with");
- }
-
- // Create a distributed test circuit factory for the test.
- CircuitFactory circuitFactory = getTestSequencer();
-
- // Set up the first client in the sender role, and the remainder in the receivers role.
- Iterator<TestClientDetails> clients = enlists.iterator();
- circuitFactory.setSender(clients.next());
-
- while (clients.hasNext())
- {
- // Set the sending and receiving client details on the test case.
- circuitFactory.setReceiver(clients.next());
- }
-
- // Pass down the connection to hold the coordinating conversation over.
- circuitFactory.setConversationFactory(conversationFactory);
-
- // If the current test case is a drop-in test, set it up as the currently running test for late joiners to
- // add in to. Otherwise the current test field is set to null, to indicate that late joiners are not allowed.
- currentTest = (coordTest instanceof DropInTest) ? coordTest : null;
-
- // Execute the test case.
- coordTest.setCircuitFactory(circuitFactory);
- }*/
-
- // Run all of the test cases in the test suite.
- for (Test test : getAllUnderlyingTests())
- {
- FrameworkBaseCase coordTest = (FrameworkBaseCase) test;
-
- coordTest.run(testResult);
-
- currentTest = null;
- }
- }
-
- /**
- * Should provide the distributed test sequencer to pass to {@link org.apache.qpid.test.framework.FrameworkBaseCase}
- * tests.
- *
- * @return A distributed test sequencer.
- */
- public CircuitFactory getTestSequencer()
- {
- return new FanOutCircuitFactory();
- }
-
- /**
- * Listens to incoming messages on the control topic. If the messages are 'join' messages, signalling a new
- * test client wishing to join the current test, then the new client will be added to the current test in the
- * receivers role.
- *
- * @param message The incoming control message.
- */
- public void onMessage(Message message)
- {
- try
- {
- // Check if the message is from a test client attempting to join a running test, and join it to the current
- // test case if so.
- if (message.getStringProperty("CONTROL_TYPE").equals("JOIN") && (currentTest != null))
- {
- ((DropInTest) currentTest).lateJoin(message);
- }
- }
- // There is not a lot can be done with this error, so it is deliberately ignored.
- catch (JMSException e)
- {
- log.debug("Unable to process message:" + message);
- }
- }
-
- /**
- * Prints a string summarizing this test decorator, mainly for debugging purposes.
- *
- * @return String representation for debugging purposes.
- */
- public String toString()
- {
- return "FanOutTestDecorator: [ testSuite = " + testSuite + " ]";
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropTestDecorator.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropTestDecorator.java
deleted file mode 100644
index dd5007090b..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropTestDecorator.java
+++ /dev/null
@@ -1,210 +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.test.framework.distributedtesting;
-
-import junit.framework.Test;
-import junit.framework.TestResult;
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-import org.apache.qpid.test.framework.sequencers.InteropCircuitFactory;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Connection;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * DistributedTestDecorator is a test decorator, written to implement the interop test specification. Given a list
- * of enlisted test clients, that are available to run interop tests, this decorator invites them to participate
- * in each test in the wrapped test suite. Amongst all the clients that respond to the invite, all pairs are formed,
- * and each pairing (in both directions, but excluding the reflexive pairings) is split into a sender and receivers
- * role and a test case run between them. Any enlisted combinations that do not accept a test invite are automatically
- * failed.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Broadcast test invitations and collect enlists. <td> {@link org.apache.qpid.test.utils.ConversationFactory}.
- * <tr><td> Output test failures for clients unwilling to run the test case. <td> {@link Coordinator}
- * <tr><td> Execute distributed test cases. <td> {@link FrameworkBaseCase}
- * <tr><td> Fail non-participating pairings. <td> {@link OptOutTestCase}
- * </table>
- */
-public class InteropTestDecorator extends DistributedTestDecorator
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(InteropTestDecorator.class);
-
- /**
- * Creates a wrapped suite test decorator from another one.
- *
- * @param suite The test suite.
- * @param availableClients The list of all clients that responded to the compulsory invite.
- * @param controlConversation The conversation helper for the control level, test coordination conversation.
- * @param controlConnection The connection that the coordination messages are sent over.
- */
- public InteropTestDecorator(WrappedSuiteTestDecorator suite, Set<TestClientDetails> availableClients,
- ConversationFactory controlConversation, Connection controlConnection)
- {
- super(suite, availableClients, controlConversation, controlConnection);
- }
-
- /**
- * Broadcasts a test invitation and accetps enlisting from participating clients. The wrapped test case is
- * then repeated for every combination of test clients (provided the wrapped test case extends
- * {@link FrameworkBaseCase}.
- *
- * <p/>Any JMSExceptions during the invite/enlist conversation will be allowed to fall through as runtime exceptions,
- * resulting in the non-completion of the test run.
- *
- * @todo Better error recovery for failure of the invite/enlist conversation could be added.
- *
- * @param testResult The the results object to monitor the test results with.
- */
- public void run(TestResult testResult)
- {
- log.debug("public void run(TestResult testResult): called");
-
- Collection<Test> tests = testSuite.getAllUnderlyingTests();
-
- for (Test test : getAllUnderlyingTests())
- {
- FrameworkBaseCase coordTest = (FrameworkBaseCase) test;
-
- // Broadcast the invitation to find out what clients are available to test.
- Set<TestClientDetails> enlists = signupClients(coordTest);
-
- // Compare the list of willing clients to the list of all available.
- Set<TestClientDetails> optOuts = new HashSet<TestClientDetails>(allClients);
- optOuts.removeAll(enlists);
-
- // Output test failures for clients that will not particpate in the test.
- Set<List<TestClientDetails>> failPairs = allPairs(optOuts, allClients);
-
- for (List<TestClientDetails> failPair : failPairs)
- {
- // Create a distributed test circuit factory for the test.
- CircuitFactory circuitFactory = getTestSequencer();
-
- // Create an automatic failure test for the opted out test pair.
- FrameworkBaseCase failTest = new OptOutTestCase("testOptOut");
- circuitFactory.setSender(failPair.get(0));
- circuitFactory.setReceiver(failPair.get(1));
- failTest.setCircuitFactory(circuitFactory);
-
- failTest.run(testResult);
- }
-
- // Loop over all combinations of clients, willing to run the test.
- Set<List<TestClientDetails>> enlistedPairs = allPairs(enlists, enlists);
-
- for (List<TestClientDetails> enlistedPair : enlistedPairs)
- {
- // Create a distributed test circuit factory for the test.
- CircuitFactory circuitFactory = getTestSequencer();
-
- // Set the sending and receiving client details on the test circuitFactory.
- circuitFactory.setSender(enlistedPair.get(0));
- circuitFactory.setReceiver(enlistedPair.get(1));
-
- // Pass down the connection to hold the coordination conversation over.
- circuitFactory.setConversationFactory(conversationFactory);
-
- // Execute the test case.
- coordTest.setCircuitFactory(circuitFactory);
- coordTest.run(testResult);
- }
- }
- }
-
- /**
- * Should provide the distributed test sequencer to pass to {@link org.apache.qpid.test.framework.FrameworkBaseCase}
- * tests.
- *
- * @return A distributed test sequencer.
- */
- public CircuitFactory getTestSequencer()
- {
- return new InteropCircuitFactory();
- }
-
- /**
- * Produces all pairs of combinations of elements from two sets. The ordering of the elements in the pair is
- * important, that is the pair <l, r> is distinct from <r, l>; both pairs are generated. For any element, i, in
- * both the left and right sets, the reflexive pair <i, i> is not generated.
- *
- * @param left The left set.
- * @param right The right set.
- * @param <E> The type of the content of the pairs.
- *
- * @return All pairs formed from the permutations of all elements of the left and right sets.
- */
- private <E> Set<List<E>> allPairs(Set<E> left, Set<E> right)
- {
- log.debug("private <E> Set<List<E>> allPairs(Set<E> left = " + left + ", Set<E> right = " + right + "): called");
-
- Set<List<E>> results = new HashSet<List<E>>();
-
- // Form all pairs from left to right.
- // Form all pairs from right to left.
- for (E le : left)
- {
- for (E re : right)
- {
- if (!le.equals(re))
- {
- results.add(new Pair<E>(le, re));
- results.add(new Pair<E>(re, le));
- }
- }
- }
-
- log.debug("results = " + results);
-
- return results;
- }
-
- /**
- * A simple implementation of a pair, using a list.
- */
- private class Pair<T> extends ArrayList<T>
- {
- /**
- * Creates a new pair of elements.
- *
- * @param first The first element.
- * @param second The second element.
- */
- public Pair(T first, T second)
- {
- super();
- super.add(first);
- super.add(second);
- }
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/OptOutTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/OptOutTestCase.java
deleted file mode 100644
index 229c6a34da..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/OptOutTestCase.java
+++ /dev/null
@@ -1,69 +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.test.framework.distributedtesting;
-
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-
-/**
- * An OptOutTestCase is a test case that automatically fails. It is used when a list of test clients has been generated
- * from a compulsory invite, but only some of those clients have responded to a specific test case invite. The clients
- * that did not respond, may automatically be given a fail for some tests.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Fail the test with a suitable reason.
- * </table>
- */
-public class OptOutTestCase extends FrameworkBaseCase
-{
- /**
- * Creates a new coordinating test case with the specified name.
- *
- * @param name The test case name.
- */
- public OptOutTestCase(String name)
- {
- super(name);
- }
-
- /** Generates an appropriate test failure assertion. */
- public void testOptOut()
- {
- CircuitFactory circuitFactory = getCircuitFactory();
-
- fail("One of " + circuitFactory.getSender() + " and " + getCircuitFactory().getReceivers()
- + " opted out of the test.");
- }
-
- /**
- * Should provide a translation from the junit method name of a test to its test case name as defined in the
- * interop testing specification. For example the method "testP2P" might map onto the interop test case name
- * "TC2_BasicP2P".
- *
- * @param methodName The name of the JUnit test method.
- * @return The name of the corresponding interop test case.
- */
- public String getTestCaseNameForTestMethod(String methodName)
- {
- return "OptOutTest";
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java
deleted file mode 100644
index f9b8cbb898..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java
+++ /dev/null
@@ -1,510 +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.test.framework.distributedtesting;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.NDC;
-
-import org.apache.qpid.junit.extensions.SleepThrottle;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.junit.extensions.util.TestContextProperties;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-import org.apache.qpid.test.framework.TestUtils;
-import org.apache.qpid.test.framework.clocksynch.ClockSynchThread;
-import org.apache.qpid.test.framework.clocksynch.UDPClockSynchronizer;
-import org.apache.qpid.test.utils.ReflectionUtils;
-import org.apache.qpid.test.utils.ReflectionUtilsException;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Implements a test client as described in the interop testing spec
- * (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). A test client is an agent that
- * reacts to control message sequences send by the test {@link Coordinator}.
- *
- * <p/><table><caption>Messages Handled by TestClient</caption>
- * <tr><th> Message <th> Action
- * <tr><td> Invite(compulsory) <td> Reply with Enlist.
- * <tr><td> Invite(test case) <td> Reply with Enlist if test case available.
- * <tr><td> AssignRole(test case) <td> Reply with Accept Role if matches an enlisted test. Keep test parameters.
- * <tr><td> Start <td> Send test messages defined by test parameters. Send report on messages sent.
- * <tr><td> Status Request <td> Send report on messages received.
- * <tr><td> Terminate <td> Terminate the test client.
- * <tr><td> ClockSynch <td> Synch clock against the supplied UDP address.
- * </table>
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Handle all incoming control messages. <td> {@link TestClientControlledTest}
- * <tr><td> Configure and look up test cases by name. <td> {@link TestClientControlledTest}
- * </table>
- */
-public class TestClient implements MessageListener
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(TestClient.class);
-
- /** Used for reporting to the console. */
- private static final Logger console = Logger.getLogger("CONSOLE");
-
- /** Holds the default identifying name of the test client. */
- public static final String CLIENT_NAME = "java";
-
- /**
- * Holds the test context properties that provides the default test parameters, plus command line overrides.
- * This is initialized with the default test parameters, to which command line overrides may be applied.
- */
- public static ParsedProperties testContextProperties =
- TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
-
- /** Holds all the test cases loaded from the classpath. */
- Map<String, TestClientControlledTest> testCases = new HashMap<String, TestClientControlledTest>();
-
- /** Holds the test case currently being run by this client. */
- protected TestClientControlledTest currentTestCase;
-
- /** Holds the connection to the broker that the test is being coordinated on. */
- protected Connection connection;
-
- /** Holds the message producer to hold the test coordination over. */
- protected MessageProducer producer;
-
- /** Holds the JMS controlSession for the test coordination. */
- protected Session session;
-
- /** Holds the name of this client, with a default value. */
- protected String clientName = CLIENT_NAME;
-
- /** This flag indicates that the test client should attempt to join the currently running test case on start up. */
- protected boolean join;
-
- /** Holds the clock synchronizer for the test node. */
- ClockSynchThread clockSynchThread;
-
- /**
- * Creates a new interop test client, listenting to the specified broker and virtual host, with the specified client
- * identifying name.
- *
- * @param pBrokerUrl The url of the broker to connect to.
- * @param pVirtualHost The virtual host to conect to.
- * @param clientName The client name to use.
- * @param join Flag to indicate that this client should attempt to join running tests.
- */
- public TestClient(String pBrokerUrl, String pVirtualHost, String clientName, boolean join)
- {
- log.debug("public TestClient(String pBrokerUrl = " + pBrokerUrl + ", String pVirtualHost = " + pVirtualHost
- + ", String clientName = " + clientName + ", boolean join = " + join + "): called");
-
- // Retain the connection parameters.
- this.clientName = clientName;
- this.join = join;
-
- // Save properies from command line to defaults
- if (pBrokerUrl != null)
- {
- testContextProperties.setProperty(MessagingTestConfigProperties.BROKER_PROPNAME, pBrokerUrl);
- }
- if (pVirtualHost != null)
- {
- testContextProperties.setProperty(MessagingTestConfigProperties.VIRTUAL_HOST_PROPNAME, pVirtualHost);
- }
- }
-
- /**
- * The entry point for the interop test coordinator. This client accepts the following command line arguments:
- *
- * <p/><table>
- * <tr><td> -b <td> The broker URL. <td> Optional.
- * <tr><td> -h <td> The virtual host. <td> Optional.
- * <tr><td> -n <td> The test client name. <td> Optional.
- * <tr><td> name=value <td> Trailing argument define name/value pairs. Added to system properties. <td> Optional.
- * </table>
- *
- * @param args The command line arguments.
- */
- public static void main(String[] args)
- {
- log.debug("public static void main(String[] args = " + Arrays.toString(args) + "): called");
- console.info("Qpid Distributed Test Client.");
-
- // Override the default broker url to be localhost:5672.
- testContextProperties.setProperty(MessagingTestConfigProperties.BROKER_PROPNAME, "tcp://localhost:5672");
-
- // Use the command line parser to evaluate the command line with standard handling behaviour (print errors
- // and usage then exist if there are errors).
- // Any options and trailing name=value pairs are also injected into the test context properties object,
- // to override any defaults that may have been set up.
- ParsedProperties options =
- new ParsedProperties(org.apache.qpid.junit.extensions.util.CommandLineParser.processCommandLine(args,
- new org.apache.qpid.junit.extensions.util.CommandLineParser(
- new String[][]
- {
- { "b", "The broker URL.", "broker", "false" },
- { "h", "The virtual host to use.", "virtual host", "false" },
- { "o", "The name of the directory to output test timings to.", "dir", "false" },
- { "n", "The name of the test client.", "name", "false" },
- { "j", "Join this test client to running test.", "false" }
- }), testContextProperties));
-
- // Extract the command line options.
- String brokerUrl = options.getProperty("b");
- String virtualHost = options.getProperty("h");
- String clientName = options.getProperty("n");
- clientName = (clientName == null) ? CLIENT_NAME : clientName;
- boolean join = options.getPropertyAsBoolean("j");
-
- // To distinguish logging output set up an NDC on the client name.
- NDC.push(clientName);
-
- // Create a test client and start it running.
- TestClient client = new TestClient(brokerUrl, virtualHost, clientName, join);
-
- // Use a class path scanner to find all the interop test case implementations.
- // Hard code the test classes till the classpath scanner is fixed.
- Collection<Class<? extends TestClientControlledTest>> testCaseClasses =
- new ArrayList<Class<? extends TestClientControlledTest>>();
- // ClasspathScanner.getMatches(TestClientControlledTest.class, "^TestCase.*", true);
- testCaseClasses.addAll(loadTestCases("org.apache.qpid.interop.clienttestcases.TestCase1DummyRun",
- "org.apache.qpid.interop.clienttestcases.TestCase2BasicP2P",
- "org.apache.qpid.interop.clienttestcases.TestCase3BasicPubSub",
- "org.apache.qpid.interop.clienttestcases.TestCase4P2PMessageSize",
- "org.apache.qpid.interop.clienttestcases.TestCase5PubSubMessageSize",
- "org.apache.qpid.test.framework.distributedcircuit.TestClientCircuitEnd"));
-
- try
- {
- client.start(testCaseClasses);
- }
- catch (Exception e)
- {
- log.error("The test client was unable to start.", e);
- console.info(e.getMessage());
- System.exit(1);
- }
- }
-
- /**
- * Parses a list of class names, and loads them if they are available on the class path.
- *
- * @param classNames The names of the classes to load.
- *
- * @return A list of the loaded test case classes.
- */
- public static List<Class<? extends TestClientControlledTest>> loadTestCases(String... classNames)
- {
- List<Class<? extends TestClientControlledTest>> testCases =
- new LinkedList<Class<? extends TestClientControlledTest>>();
-
- for (String className : classNames)
- {
- try
- {
- Class<?> cls = ReflectionUtils.forName(className);
- testCases.add((Class<? extends TestClientControlledTest>) cls);
- }
- catch (ReflectionUtilsException e)
- {
- // Ignore, class could not be found, so test not available.
- console.warn("Requested class " + className + " cannot be found, ignoring it.");
- }
- catch (ClassCastException e)
- {
- // Ignore, class was not of correct type to be a test case.
- console.warn("Requested class " + className + " is not an instance of TestClientControlledTest.");
- }
- }
-
- return testCases;
- }
-
- /**
- * Starts the interop test client running. This causes it to start listening for incoming test invites.
- *
- * @param testCaseClasses The classes of the available test cases. The test case names from these are used to
- * matchin incoming test invites against.
- *
- * @throws JMSException Any underlying JMSExceptions are allowed to fall through.
- */
- protected void start(Collection<Class<? extends TestClientControlledTest>> testCaseClasses) throws JMSException
- {
- log.debug("protected void start(Collection<Class<? extends TestClientControlledTest>> testCaseClasses = "
- + testCaseClasses + "): called");
-
- // Create all the test case implementations and index them by the test names.
- for (Class<? extends TestClientControlledTest> nextClass : testCaseClasses)
- {
- try
- {
- TestClientControlledTest testCase = nextClass.newInstance();
- testCases.put(testCase.getName(), testCase);
- }
- catch (InstantiationException e)
- {
- log.warn("Could not instantiate test case class: " + nextClass.getName(), e);
- // Ignored.
- }
- catch (IllegalAccessException e)
- {
- log.warn("Could not instantiate test case class due to illegal access: " + nextClass.getName(), e);
- // Ignored.
- }
- }
-
- // Open a connection to communicate with the coordinator on.
- connection = TestUtils.createConnection(testContextProperties);
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Set this up to listen for control messages.
- Topic privateControlTopic = session.createTopic("iop.control." + clientName);
- MessageConsumer consumer = session.createConsumer(privateControlTopic);
- consumer.setMessageListener(this);
-
- Topic controlTopic = session.createTopic("iop.control");
- MessageConsumer consumer2 = session.createConsumer(controlTopic);
- consumer2.setMessageListener(this);
-
- // Create a producer to send replies with.
- producer = session.createProducer(null);
-
- // If the join flag was set, then broadcast a join message to notify the coordinator that a new test client
- // is available to join the current test case, if it supports it. This message may be ignored, or it may result
- // in this test client receiving a test invite.
- if (join)
- {
- Message joinMessage = session.createMessage();
-
- joinMessage.setStringProperty("CONTROL_TYPE", "JOIN");
- joinMessage.setStringProperty("CLIENT_NAME", clientName);
- joinMessage.setStringProperty("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
- producer.send(controlTopic, joinMessage);
- }
-
- // Start listening for incoming control messages.
- connection.start();
- }
-
- /**
- * Handles all incoming control messages.
- *
- * @param message The incoming message.
- */
- public void onMessage(Message message)
- {
- NDC.push(clientName);
- log.debug("public void onMessage(Message message = " + message + "): called");
-
- try
- {
- String controlType = message.getStringProperty("CONTROL_TYPE");
- String testName = message.getStringProperty("TEST_NAME");
-
- log.debug("Received control of type '" + controlType + "' for the test '" + testName + "'");
-
- // Check if the message is a test invite.
- if ("INVITE".equals(controlType))
- {
- // Flag used to indicate that an enlist should be sent. Only enlist to compulsory invites or invites
- // for which test cases exist.
- boolean enlist = false;
-
- if (testName != null)
- {
- log.debug("Got an invite to test: " + testName);
-
- // Check if the requested test case is available.
- TestClientControlledTest testCase = testCases.get(testName);
-
- if (testCase != null)
- {
- log.debug("Found implementing class for test '" + testName + "', enlisting for it.");
-
- // Check if the test case will accept the invitation.
- enlist = testCase.acceptInvite(message);
-
- log.debug("The test case "
- + (enlist ? " accepted the invite, enlisting for it."
- : " did not accept the invite, not enlisting."));
-
- // Make the requested test case the current test case.
- currentTestCase = testCase;
- }
- else
- {
- log.debug("Received an invite to the test '" + testName + "' but this test is not known.");
- }
- }
- else
- {
- log.debug("Got a compulsory invite, enlisting for it.");
-
- enlist = true;
- }
-
- if (enlist)
- {
- // Reply with the client name in an Enlist message.
- Message enlistMessage = session.createMessage();
- enlistMessage.setStringProperty("CONTROL_TYPE", "ENLIST");
- enlistMessage.setStringProperty("CLIENT_NAME", clientName);
- enlistMessage.setStringProperty("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
- enlistMessage.setJMSCorrelationID(message.getJMSCorrelationID());
-
- log.debug("Sending enlist message '" + enlistMessage.getJMSMessageID() + "' to " + message.getJMSReplyTo());
-
- producer.send(message.getJMSReplyTo(), enlistMessage);
- }
- else
- {
- // Reply with the client name in an Decline message.
- Message enlistMessage = session.createMessage();
- enlistMessage.setStringProperty("CONTROL_TYPE", "DECLINE");
- enlistMessage.setStringProperty("CLIENT_NAME", clientName);
- enlistMessage.setStringProperty("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
- enlistMessage.setJMSCorrelationID(message.getJMSCorrelationID());
-
- log.debug("Sending decline message '" + enlistMessage.getJMSMessageID() + "' to " + message.getJMSReplyTo());
-
- producer.send(message.getJMSReplyTo(), enlistMessage);
- }
- }
- else if ("ASSIGN_ROLE".equals(controlType))
- {
- // Assign the role to the current test case.
- String roleName = message.getStringProperty("ROLE");
-
- log.debug("Got a role assignment to role: " + roleName);
-
- TestClientControlledTest.Roles role = Enum.valueOf(TestClientControlledTest.Roles.class, roleName);
-
- currentTestCase.assignRole(role, message);
-
- // Reply by accepting the role in an Accept Role message.
- Message acceptRoleMessage = session.createMessage();
- acceptRoleMessage.setStringProperty("CLIENT_NAME", clientName);
- acceptRoleMessage.setStringProperty("CONTROL_TYPE", "ACCEPT_ROLE");
- acceptRoleMessage.setJMSCorrelationID(message.getJMSCorrelationID());
-
- log.debug("Sending accept role message '" + acceptRoleMessage.getJMSMessageID() + "' to " + message.getJMSReplyTo());
-
- producer.send(message.getJMSReplyTo(), acceptRoleMessage);
- }
- else if ("START".equals(controlType) || "STATUS_REQUEST".equals(controlType))
- {
- if ("START".equals(controlType))
- {
- log.debug("Got a start notification.");
-
- // Extract the number of test messages to send from the start notification.
- int numMessages;
-
- try
- {
- numMessages = message.getIntProperty("MESSAGE_COUNT");
- }
- catch (NumberFormatException e)
- {
- // If the number of messages is not specified, use the default of one.
- numMessages = 1;
- }
-
- // Start the current test case.
- currentTestCase.start(numMessages);
- }
- else
- {
- log.debug("Got a status request.");
- }
-
- // Generate the report from the test case and reply with it as a Report message.
- Message reportMessage = currentTestCase.getReport(session);
- reportMessage.setStringProperty("CLIENT_NAME", clientName);
- reportMessage.setStringProperty("CONTROL_TYPE", "REPORT");
- reportMessage.setJMSCorrelationID(message.getJMSCorrelationID());
-
- log.debug("Sending report message '" + reportMessage.getJMSMessageID() + "' to " + message.getJMSReplyTo());
-
- producer.send(message.getJMSReplyTo(), reportMessage);
- }
- else if ("TERMINATE".equals(controlType))
- {
- console.info("Received termination instruction from coordinator.");
-
- // Is a cleaner shutdown needed?
- connection.close();
- System.exit(0);
- }
- else if ("CLOCK_SYNCH".equals(controlType))
- {
- log.debug("Received clock synch command.");
- String address = message.getStringProperty("ADDRESS");
-
- log.debug("address = " + address);
-
- // Re-create (if necessary) and start the clock synch thread to synch the clock every ten seconds.
- if (clockSynchThread != null)
- {
- clockSynchThread.terminate();
- }
-
- SleepThrottle throttle = new SleepThrottle();
- throttle.setRate(0.1f);
-
- clockSynchThread = new ClockSynchThread(new UDPClockSynchronizer(address), throttle);
- clockSynchThread.start();
- }
- else
- {
- // Log a warning about this but otherwise ignore it.
- log.warn("Got an unknown control message, controlType = " + controlType + ", message = " + message);
- }
- }
- catch (JMSException e)
- {
- // Log a warning about this, but otherwise ignore it.
- log.warn("Got JMSException whilst handling message: " + message, e);
- }
- // Log any runtimes that fall through this message handler. These are fatal errors for the test client.
- catch (RuntimeException e)
- {
- log.error("The test client message handler got an unhandled exception: ", e);
- console.info("The message handler got an unhandled exception, terminating the test client.");
- System.exit(1);
- }
- finally
- {
- NDC.pop();
- }
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClientControlledTest.java b/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClientControlledTest.java
deleted file mode 100644
index 2e64c9ca2d..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClientControlledTest.java
+++ /dev/null
@@ -1,107 +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.test.framework.distributedtesting;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-
-/**
- * TestClientControlledTest provides an interface that classes implementing test cases to run on a {@link TestClient}
- * node can use. Implementations must be Java beans, that is, to provide a default constructor and to implement the
- * {@link #getName} method.
- *
- * <p/>The methods specified in this interface are called when the {@link TestClient} receives control instructions to
- * apply to the test. There are control instructions to present the test case with the test invite, so that it may
- * choose whether or not to participate in the test, assign the test to play the sender or receiver role, start the
- * test and obtain the test status report.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Supply the name of the test case that this implements.
- * <tr><td> Accept/Reject invites based on test parameters.
- * <tr><td> Adapt to assigned roles.
- * <tr><td> Perform test case actions.
- * <tr><td> Generate test reports.
- * </table>
- */
-public interface TestClientControlledTest
-{
- /** Defines the possible test case roles that an interop test case can take on. */
- public enum Roles
- {
- /** Specifies the sender role. */
- SENDER,
-
- /** Specifies the receivers role. */
- RECEIVER
- }
-
- /**
- * Should provide the name of the test case that this class implements. The exact names are defined in the
- * interop testing spec.
- *
- * @return The name of the test case that this implements.
- */
- public String getName();
-
- /**
- * Determines whether the test invite that matched this test case is acceptable.
- *
- * @param inviteMessage The invitation to accept or reject.
- *
- * @return <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- */
- public boolean acceptInvite(Message inviteMessage) throws JMSException;
-
- /**
- * Assigns the role to be played by this test case. The test parameters are fully specified in the
- * assignment message. When this method return the test case will be ready to execute.
- *
- * @param role The role to be played; sender or receivers.
- * @param assignRoleMessage The role assingment message, contains the full test parameters.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- */
- public void assignRole(Roles role, Message assignRoleMessage) throws JMSException;
-
- /**
- * Performs the test case actions. Returning from here, indicates that the sending role has completed its test.
- *
- * @param numMessages The number of test messages to send.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- */
- public void start(int numMessages) throws JMSException;
-
- /**
- * Gets a report on the actions performed by the test case in its assigned role.
- *
- * @param session The controlSession to create the report message in.
- *
- * @return The report message.
- *
- * @throws JMSException Any JMSExceptions resulting from creating the report are allowed to fall through.
- */
- public Message getReport(Session session) throws JMSException;
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/listeners/XMLTestListener.java b/java/systests/src/main/java/org/apache/qpid/test/framework/listeners/XMLTestListener.java
deleted file mode 100644
index ad2c196adb..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/listeners/XMLTestListener.java
+++ /dev/null
@@ -1,414 +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.test.framework.listeners;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.ShutdownHookable;
-import org.apache.qpid.junit.extensions.listeners.TKTestListener;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Listens for test results for a named test and outputs these in the standard JUnit XML format to the specified
- * writer.
- *
- * <p/>The API for this listener accepts notifications about different aspects of a tests results through different
- * methods, so some assumption needs to be made as to which test result a notification refers to. For example
- * {@link #startTest} will be called, then possibly {@link #timing} will be called, even though the test instance is
- * passed in both cases, it is not enough to distinguish a particular run of the test, as the test case instance may
- * be being shared between multiple threads, or being run a repeated number of times, and can therfore be re-used
- * between calls. The listeners make the assumption that, for every test, a unique thread will call {@link #startTest}
- * and {@link #endTest} to delimit each test. All calls to set test parameters, timings, state and so on, will occur
- * between the start and end and will be given with the same thread id as the start and end, so the thread id provides
- * a unqiue value to identify a particular test run against.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Listen to test lifecycle notifications.
- * <tr><td> Listen to test errors and failures.
- * <tr><td> Listen to test timings.
- * <tr><td> Listen to test memory usages.
- * <tr><td> Listen to parameterized test parameters.
- * <tr><th> Responsibilities
- * </table>
- *
- * @todo Merge this class with CSV test listener, making the collection of results common to both, and only factoring
- * out the results printing code into sub-classes. Provide a simple XML results formatter with the same format as
- * the ant XML formatter, and a more structured one for outputing results with timings and summaries from
- * performance tests.
- */
-public class XMLTestListener implements TKTestListener, ShutdownHookable
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(XMLTestListener.class);
-
- /** The results file writer. */
- protected Writer writer;
-
- /** Holds the results for individual tests. */
- // protected Map<Result, Result> results = new LinkedHashMap<Result, Result>();
- // protected List<Result> results = new ArrayList<Result>();
-
- /**
- * Map for holding results on a per thread basis as they come in. A ThreadLocal is not used as sometimes an
- * explicit thread id must be used, where notifications come from different threads than the ones that called
- * the test method.
- */
- Map<Long, Result> threadLocalResults = Collections.synchronizedMap(new LinkedHashMap<Long, Result>());
-
- /**
- * Holds results for tests that have ended. Transferring these results here from the per-thread results map, means
- * that the thread id is freed for the thread to generate more results.
- */
- List<Result> results = new ArrayList<Result>();
-
- /** Holds the overall error count. */
- protected int errors = 0;
-
- /** Holds the overall failure count. */
- protected int failures = 0;
-
- /** Holds the overall tests run count. */
- protected int runs = 0;
-
- /** Holds the name of the class that tests are being run for. */
- String testClassName;
-
- /**
- * Creates a new XML results output listener that writes to the specified location.
- *
- * @param writer The location to write results to.
- * @param testClassName The name of the test class to include in the test results.
- */
- public XMLTestListener(Writer writer, String testClassName)
- {
- log.debug("public XMLTestListener(Writer writer, String testClassName = " + testClassName + "): called");
-
- this.writer = writer;
- this.testClassName = testClassName;
- }
-
- /**
- * Resets the test results to the default state of time zero, memory usage zero, parameter zero, test passed.
- *
- * @param test The test to resest any results for.
- * @param threadId Optional thread id if not calling from thread that started the test method. May be null.
- */
- public void reset(Test test, Long threadId)
- {
- log.debug("public void reset(Test test = " + test + ", Long threadId = " + threadId + "): called");
-
- XMLTestListener.Result r =
- (threadId == null) ? threadLocalResults.get(Thread.currentThread().getId()) : threadLocalResults.get(threadId);
-
- r.error = null;
- r.failure = null;
-
- }
-
- /**
- * Notification that a test started.
- *
- * @param test The test that started.
- */
- public void startTest(Test test)
- {
- log.debug("public void startTest(Test test = " + test + "): called");
-
- Result newResult = new Result(test.getClass().getName(), ((TestCase) test).getName());
-
- // Initialize the thread local test results.
- threadLocalResults.put(Thread.currentThread().getId(), newResult);
- runs++;
- }
-
- /**
- * Should be called every time a test completes with the run time of that test.
- *
- * @param test The name of the test.
- * @param nanos The run time of the test in nanoseconds.
- * @param threadId Optional thread id if not calling from thread that started the test method. May be null.
- */
- public void timing(Test test, long nanos, Long threadId)
- { }
-
- /**
- * Optionally called every time a test completes with the second timing test.
- *
- * @param test The name of the test.
- * @param nanos The second timing information of the test in nanoseconds.
- * @param threadId Optional thread id if not calling from thread that started the test method. May be null.
- */
- public void timing2(Test test, Long nanos, Long threadId)
- { }
-
- /**
- * Should be called every time a test completed with the amount of memory used before and after the test was run.
- *
- * @param test The test which memory was measured for.
- * @param memStart The total JVM memory used before the test was run.
- * @param memEnd The total JVM memory used after the test was run.
- * @param threadId Optional thread id if not calling from thread that started the test method. May be null.
- */
- public void memoryUsed(Test test, long memStart, long memEnd, Long threadId)
- { }
-
- /**
- * Should be called every time a parameterized test completed with the int value of its test parameter.
- *
- * @param test The test which memory was measured for.
- * @param parameter The int parameter value.
- * @param threadId Optional thread id if not calling from thread that started the test method. May be null.
- */
- public void parameterValue(Test test, int parameter, Long threadId)
- { }
-
- /**
- * Should be called every time a test completes with the current number of test threads running.
- *
- * @param test The test for which the measurement is being generated.
- * @param threads The number of tests being run concurrently.
- * @param threadId Optional thread id if not calling from thread that started the test method. May be null.
- */
- public void concurrencyLevel(Test test, int threads, Long threadId)
- { }
-
- /**
- * Notifies listeners of the tests read/set properties.
- *
- * @param properties The tests read/set properties.
- */
- public void properties(Properties properties)
- { }
-
- /**
- * Notification that a test ended.
- *
- * @param test The test that ended.
- */
- public void endTest(Test test)
- {
- log.debug("public void endTest(Test test = " + test + "): called");
-
- // Move complete test results into the completed tests list.
- Result r = threadLocalResults.get(Thread.currentThread().getId());
- results.add(r);
-
- // Clear all the test results for the thread.
- threadLocalResults.remove(Thread.currentThread().getId());
- }
-
- /**
- * Called when a test completes. Success, failure and errors. This method should be used when registering an
- * end test from a different thread than the one that started the test.
- *
- * @param test The test which completed.
- * @param threadId Optional thread id if not calling from thread that started the test method. May be null.
- */
- public void endTest(Test test, Long threadId)
- {
- log.debug("public void endTest(Test test = " + test + ", Long threadId = " + threadId + "): called");
-
- // Move complete test results into the completed tests list.
- Result r =
- (threadId == null) ? threadLocalResults.get(Thread.currentThread().getId()) : threadLocalResults.get(threadId);
- results.add(r);
-
- // Clear all the test results for the thread.
- threadLocalResults.remove(Thread.currentThread().getId());
- }
-
- /**
- * An error occurred.
- *
- * @param test The test in which the error occurred.
- * @param t The throwable that resulted from the error.
- */
- public void addError(Test test, Throwable t)
- {
- log.debug("public void addError(Test test = " + test + ", Throwable t = " + t + "): called");
-
- Result r = threadLocalResults.get(Thread.currentThread().getId());
- r.error = t;
- errors++;
- }
-
- /**
- * A failure occurred.
- *
- * @param test The test in which the failure occurred.
- * @param t The JUnit assertions that led to the failure.
- */
- public void addFailure(Test test, AssertionFailedError t)
- {
- log.debug("public void addFailure(Test test = " + test + ", AssertionFailedError t = " + t + "): called");
-
- Result r = threadLocalResults.get(Thread.currentThread().getId());
- r.failure = t;
- failures++;
- }
-
- /**
- * Called when a test completes to mark it as a test fail. This method should be used when registering a
- * failure from a different thread than the one that started the test.
- *
- * @param test The test which failed.
- * @param e The assertion that failed the test.
- * @param threadId Optional thread id if not calling from thread that started the test method. May be null.
- */
- public void addFailure(Test test, AssertionFailedError e, Long threadId)
- {
- log.debug("public void addFailure(Test test, AssertionFailedError e, Long threadId): called");
-
- Result r =
- (threadId == null) ? threadLocalResults.get(Thread.currentThread().getId()) : threadLocalResults.get(threadId);
- r.failure = e;
- failures++;
- }
-
- /**
- * Notifies listeners of the start of a complete run of tests.
- */
- public void startBatch()
- {
- log.debug("public void startBatch(): called");
-
- // Reset all results counts.
- threadLocalResults = Collections.synchronizedMap(new HashMap<Long, Result>());
- errors = 0;
- failures = 0;
- runs = 0;
-
- // Write out the file header.
- try
- {
- writer.write("<?xml version=\"1.0\" ?>\n");
- }
- catch (IOException e)
- {
- throw new RuntimeException("Unable to write the test results.", e);
- }
- }
-
- /**
- * Notifies listeners of the end of a complete run of tests.
- *
- * @param parameters The optional test parameters to log out with the batch results.
- */
- public void endBatch(Properties parameters)
- {
- log.debug("public void endBatch(Properties parameters = " + parameters + "): called");
-
- // Write out the results.
- try
- {
- // writer.write("<?xml version=\"1.0\" ?>\n");
- writer.write("<testsuite errors=\"" + errors + "\" failures=\"" + failures + "\" tests=\"" + runs + "\" name=\""
- + testClassName + "\">\n");
-
- for (Result result : results)
- {
- writer.write(" <testcase classname=\"" + result.testClass + "\" name=\"" + result.testName + "\">\n");
-
- if (result.error != null)
- {
- writer.write(" <error type=\"" + result.error.getClass() + "\">");
- result.error.printStackTrace(new PrintWriter(writer));
- writer.write(" </error>");
- }
- else if (result.failure != null)
- {
- writer.write(" <failure type=\"" + result.failure.getClass() + "\">");
- result.failure.printStackTrace(new PrintWriter(writer));
- writer.write(" </failure>");
- }
-
- writer.write(" </testcase>\n");
- }
-
- writer.write("</testsuite>\n");
- writer.flush();
- }
- catch (IOException e)
- {
- throw new RuntimeException("Unable to write the test results.", e);
- }
- }
-
- /**
- * Supplies the shutdown hook.
- *
- * @return The shut down hook.
- */
- public Thread getShutdownHook()
- {
- return new Thread(new Runnable()
- {
- public void run()
- {
- log.debug("XMLTestListener::ShutdownHook: called");
- }
- });
- }
-
- /**
- * Used to capture the results of a particular test run.
- */
- protected static class Result
- {
- /** Holds the name of the test class. */
- public String testClass;
-
- /** Holds the name of the test method. */
- public String testName;
-
- /** Holds the exception that caused error in this test. */
- public Throwable error;
-
- /** Holds the assertion exception that caused failure in this test. */
- public AssertionFailedError failure;
-
- /**
- * Creates a placeholder for the results of a test.
- *
- * @param testClass The test class.
- * @param testName The name of the test that was run.
- */
- public Result(String testClass, String testName)
- {
- this.testClass = testClass;
- this.testName = testName;
- }
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalAMQPPublisherImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalAMQPPublisherImpl.java
deleted file mode 100644
index 6a0e8cba4b..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalAMQPPublisherImpl.java
+++ /dev/null
@@ -1,137 +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.test.framework.localcircuit;
-
-import org.apache.qpid.client.AMQNoConsumersException;
-import org.apache.qpid.client.AMQNoRouteException;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.AMQPPublisher;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.AssertionBase;
-import org.apache.qpid.test.framework.CircuitEndBase;
-import org.apache.qpid.test.framework.ExceptionMonitor;
-import org.apache.qpid.test.framework.MessageMonitor;
-
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * LocalAMQPPublisherImpl is an extension of {@link LocalPublisherImpl} that adds AMQP specific features. Specifically
- * extra assertions for AMQP features not available through generic JMS.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td>
- * </table>
- */
-public class LocalAMQPPublisherImpl extends LocalPublisherImpl implements AMQPPublisher
-{
- /**
- * Creates a circuit end point on the specified producer, consumer and controlSession. Monitors are also configured
- * for messages and exceptions received by the circuit end.
- *
- * @param producer The message producer for the circuit end point.
- * @param consumer The message consumer for the circuit end point.
- * @param session The controlSession for the circuit end point.
- * @param messageMonitor The monitor to notify of all messages received by the circuit end.
- * @param exceptionMonitor The monitor to notify of all exceptions received by the circuit end.
- */
- public LocalAMQPPublisherImpl(MessageProducer producer, MessageConsumer consumer, Session session,
- MessageMonitor messageMonitor, ExceptionMonitor exceptionMonitor)
- {
- super(producer, consumer, session, messageMonitor, exceptionMonitor);
- }
-
- /**
- * Creates a circuit end point from the producer, consumer and controlSession in a circuit end base implementation.
- *
- * @param end The circuit end base implementation to take producers and consumers from.
- */
- public LocalAMQPPublisherImpl(CircuitEndBase end)
- {
- super(end);
- }
-
- /**
- * Provides an assertion that the publisher got a no consumers exception on every message.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the publisher got a no consumers exception on every message.
- */
- public Assertion noConsumersAssertion(ParsedProperties testProps)
- {
- return new AssertionBase()
- {
- public boolean apply()
- {
- boolean passed = true;
- ExceptionMonitor connectionExceptionMonitor = circuit.getConnectionExceptionMonitor();
-
- if (!connectionExceptionMonitor.assertOneJMSExceptionWithLinkedCause(AMQNoConsumersException.class))
- {
- passed = false;
-
- addError("Was expecting linked exception type " + AMQNoConsumersException.class.getName()
- + " on the connection.\n");
- addError((connectionExceptionMonitor.size() > 0)
- ? ("Actually got the following exceptions on the connection, " + connectionExceptionMonitor)
- : "Got no exceptions on the connection.");
- }
-
- return passed;
- }
- };
- }
-
- /**
- * Provides an assertion that the publisher got a no rout exception on every message.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the publisher got a no rout exception on every message.
- */
- public Assertion noRouteAssertion(ParsedProperties testProps)
- {
- return new AssertionBase()
- {
- public boolean apply()
- {
- boolean passed = true;
- ExceptionMonitor connectionExceptionMonitor = circuit.getConnectionExceptionMonitor();
-
- if (!connectionExceptionMonitor.assertOneJMSExceptionWithLinkedCause(AMQNoRouteException.class))
- {
- passed = false;
-
- addError("Was expecting linked exception type " + AMQNoRouteException.class.getName()
- + " on the connection.\n");
- addError((connectionExceptionMonitor.size() > 0)
- ? ("Actually got the following exceptions on the connection, " + connectionExceptionMonitor)
- : "Got no exceptions on the connection.");
- }
-
- return passed;
- }
- };
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java
deleted file mode 100644
index dc9ee0ac28..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java
+++ /dev/null
@@ -1,313 +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.test.framework.localcircuit;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.CircuitEnd;
-import org.apache.qpid.test.framework.ExceptionMonitor;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-import org.apache.qpid.test.framework.Publisher;
-import org.apache.qpid.test.framework.Receiver;
-import org.apache.qpid.test.framework.TestUtils;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * LocalCircuitImpl provides an implementation of the test circuit. This is a local only circuit implementation that
- * supports a single producer/consumer on each end of the circuit, with both ends of the circuit on the same JVM.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Supply the publishing and receiving ends of a test messaging circuit.
- * <td> {@link LocalPublisherImpl}, {@link LocalReceiverImpl}
- * <tr><td> Start the circuit running.
- * <tr><td> Close the circuit down.
- * <tr><td> Take a reading of the circuits state.
- * <tr><td> Apply assertions against the circuits state. <td> {@link Assertion}
- * <tr><td> Send test messages over the circuit.
- * <tr><td> Perform the default test procedure on the circuit.
- * <tr><td> Provide access to connection and controlSession exception monitors. <td> {@link ExceptionMonitor}
- * </table>
- */
-public class LocalCircuitImpl implements Circuit
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(LocalCircuitImpl.class);
-
- /** Holds the test configuration for the circuit. */
- private ParsedProperties testProps;
-
- /** Holds the publishing end of the circuit. */
- private LocalPublisherImpl publisher;
-
- /** Holds the receiving end of the circuit. */
- private LocalReceiverImpl receiver;
-
- /** Holds the connection for the publishing end of the circuit. */
- private Connection connection;
-
- /** Holds the exception listener for the connection on the publishing end of the circuit. */
- private ExceptionMonitor connectionExceptionMonitor;
-
- /** Holds the exception listener for the controlSession on the publishing end of the circuit. */
- private ExceptionMonitor exceptionMonitor;
-
- /**
- * Creates a test circuit using the specified test parameters. The publisher, receivers, connection and
- * connection monitor must already have been created, to assemble the circuit.
- *
- * @param testProps The test parameters.
- * @param publisher The test publisher.
- * @param receiver The test receivers.
- * @param connection The connection.
- * @param connectionExceptionMonitor The connection exception monitor.
- */
- public LocalCircuitImpl(ParsedProperties testProps, LocalPublisherImpl publisher, LocalReceiverImpl receiver,
- Connection connection, ExceptionMonitor connectionExceptionMonitor)
- {
- this.testProps = testProps;
- this.publisher = publisher;
- this.receiver = receiver;
- this.connection = connection;
- this.connectionExceptionMonitor = connectionExceptionMonitor;
- this.exceptionMonitor = new ExceptionMonitor();
-
- // Set this as the parent circuit on the publisher and receivers.
- publisher.setCircuit(this);
- receiver.setCircuit(this);
- }
-
- /**
- * Gets the interface on the publishing end of the circuit.
- *
- * @return The publishing end of the circuit.
- */
- public Publisher getPublisher()
- {
- return publisher;
- }
-
- /**
- * Gets the local publishing circuit end, for direct manipulation.
- *
- * @return The local publishing circuit end.
- */
- public CircuitEnd getLocalPublisherCircuitEnd()
- {
- return publisher;
- }
-
- /**
- * Gets the interface on the receiving end of the circuit.
- *
- * @return The receiving end of the circuit.
- */
- public Receiver getReceiver()
- {
- return receiver;
- }
-
- /**
- * Gets the local receiving circuit end, for direct manipulation.
- *
- * @return The local receiving circuit end.
- */
- public CircuitEnd getLocalReceiverCircuitEnd()
- {
- return receiver;
- }
-
- /**
- * Checks the test circuit. The effect of this is to gather the circuits state, for both ends of the circuit,
- * into a report, against which assertions may be checked.
- */
- public void check()
- { }
-
- /**
- * Applied a list of assertions against the test circuit. The {@link #check()} method should be called before doing
- * this, to ensure that the circuit has gathered its state into a report to assert against.
- *
- * @param assertions The list of assertions to apply.
- * @return Any assertions that failed.
- */
- public List<Assertion> applyAssertions(List<Assertion> assertions)
- {
- List<Assertion> failures = new LinkedList<Assertion>();
-
- for (Assertion assertion : assertions)
- {
- if (!assertion.apply())
- {
- failures.add(assertion);
- }
- }
-
- return failures;
- }
-
- /**
- * Connects and starts the circuit. After this method is called the circuit is ready to send messages.
- */
- public void start()
- { }
-
- /**
- * Closes the circuit. All associated resources are closed.
- */
- public void close()
- {
- try
- {
- publisher.close();
- receiver.close();
- connection.close();
- }
- catch (JMSException e)
- {
- throw new RuntimeException("Got JMSException during close:" + e.getMessage(), e);
- }
- }
-
- /**
- * Sends a message on the test circuit. The exact nature of the message sent is controlled by the test parameters.
- */
- protected void send()
- {
- // Cast the test properties into a typed interface for convenience.
- MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProps);
-
- boolean transactional = props.getPublisherTransacted();
- boolean rollback = props.getRollbackPublisher();
-
- // Send a message through the publisher and log any exceptions raised.
- try
- {
- CircuitEnd end = getLocalPublisherCircuitEnd();
-
- end.send(createTestMessage(end));
-
- if (rollback)
- {
- end.getSession().rollback();
- }
- else if (transactional)
- {
- end.getSession().commit();
- }
- }
- catch (JMSException e)
- {
- exceptionMonitor.onException(e);
- }
- }
-
- /**
- * Runs the default test procedure against the circuit, and checks that all of the specified assertions hold. The
- * outline of the default test procedure is:
- *
- * <p/><pre>
- * Start the circuit.
- * Send test messages.
- * Request a status report.
- * Assert conditions on the publishing end of the circuit.
- * Assert conditions on the receiving end of the circuit.
- * Close the circuit.
- * Pass with no failed assertions or fail with a list of failed assertions.
- * </pre>
- *
- * @param numMessages The number of messages to send using the default test procedure.
- * @param assertions The list of assertions to apply.
- * @return Any assertions that failed.
- */
- public List<Assertion> test(int numMessages, List<Assertion> assertions)
- {
- // Start the test circuit.
- start();
-
- // Send the requested number of test messages.
- for (int i = 0; i < numMessages; i++)
- {
- send();
- }
-
- // Inject a short pause to allow time for exceptions to come back asynchronously.
- TestUtils.pause(500L);
-
- // Request a status report.
- check();
-
- // Clean up the publisher/receivers/controlSession/connections.
- close();
-
- // Apply all of the requested assertions, keeping record of any that fail.
- List<Assertion> failures = applyAssertions(assertions);
-
- // Return any failed assertions to the caller.
- return failures;
- }
-
- /**
- * Creates a message with the properties defined as per the test parameters.
- *
- * @param client The circuit end to create the message on.
- *
- * @return The test message.
- *
- * @throws JMSException Any JMSException occurring during creation of the message is allowed to fall through.
- */
- private Message createTestMessage(CircuitEnd client) throws JMSException
- {
- // Cast the test properties into a typed interface for convenience.
- MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProps);
-
- return TestUtils.createTestMessageOfSize(client.getSession(), props.getMessageSize());
- }
-
- /**
- * Gets the exception monitor for the publishing ends connection.
- *
- * @return The exception monitor for the publishing ends connection.
- */
- public ExceptionMonitor getConnectionExceptionMonitor()
- {
- return connectionExceptionMonitor;
- }
-
- /**
- * Gets the exception monitor for the publishing ends controlSession.
- *
- * @return The exception monitor for the publishing ends controlSession.
- */
- public ExceptionMonitor getExceptionMonitor()
- {
- return exceptionMonitor;
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalPublisherImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalPublisherImpl.java
deleted file mode 100644
index 9920be003a..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalPublisherImpl.java
+++ /dev/null
@@ -1,176 +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.test.framework.localcircuit;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.AssertionBase;
-import org.apache.qpid.test.framework.CircuitEnd;
-import org.apache.qpid.test.framework.CircuitEndBase;
-import org.apache.qpid.test.framework.ExceptionMonitor;
-import org.apache.qpid.test.framework.MessageMonitor;
-import org.apache.qpid.test.framework.NotApplicableAssertion;
-import org.apache.qpid.test.framework.Publisher;
-
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * Provides an implementation of the {@link Publisher} interface and wraps a single message producer and consumer on
- * a single controlSession, as a {@link CircuitEnd}. A local publisher also acts as a circuit end, because for a locally
- * located circuit the assertions may be applied directly, there does not need to be any inter-process messaging
- * between the publisher and its single circuit end, in order to ascertain its status.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide a message producer for sending messages.
- * <tr><td> Provide a message consumer for receiving messages.
- * <tr><td> Provide assertion that the publisher received no exceptions.
- * <tr><td> Provide assertion that the publisher received a no consumers error code.
- * <tr><td> Provide assertion that the publisher received a no route error code.
- * </table>
- */
-public class LocalPublisherImpl extends CircuitEndBase implements Publisher
-{
- /** Holds a reference to the containing circuit. */
- protected LocalCircuitImpl circuit;
-
- /**
- * Creates a circuit end point on the specified producer, consumer and controlSession. Monitors are also configured
- * for messages and exceptions received by the circuit end.
- *
- * @param producer The message producer for the circuit end point.
- * @param consumer The message consumer for the circuit end point.
- * @param session The controlSession for the circuit end point.
- * @param messageMonitor The monitor to notify of all messages received by the circuit end.
- * @param exceptionMonitor The monitor to notify of all exceptions received by the circuit end.
- */
- public LocalPublisherImpl(MessageProducer producer, MessageConsumer consumer, Session session,
- MessageMonitor messageMonitor, ExceptionMonitor exceptionMonitor)
- {
- super(producer, consumer, session, messageMonitor, exceptionMonitor);
- }
-
- /**
- * Creates a circuit end point from the producer, consumer and controlSession in a circuit end base implementation.
- *
- * @param end The circuit end base implementation to take producers and consumers from.
- */
- public LocalPublisherImpl(CircuitEndBase end)
- {
- super(end.getProducer(), end.getConsumer(), end.getSession(), end.getMessageMonitor(), end.getExceptionMonitor());
- }
-
- /**
- * Provides an assertion that the publisher encountered no exceptions.
- *
- * @param testProps
- *
- * @return An assertion that the publisher encountered no exceptions.
- */
- public Assertion noExceptionsAssertion(ParsedProperties testProps)
- {
- return new AssertionBase()
- {
- public boolean apply()
- {
- boolean passed = true;
- ExceptionMonitor sessionExceptionMonitor = circuit.getExceptionMonitor();
- ExceptionMonitor connectionExceptionMonitor = circuit.getConnectionExceptionMonitor();
-
- if (!connectionExceptionMonitor.assertNoExceptions())
- {
- passed = false;
-
- addError("Was expecting no exceptions.\n");
- addError("Got the following exceptions on the connection, "
- + circuit.getConnectionExceptionMonitor());
- }
-
- if (!sessionExceptionMonitor.assertNoExceptions())
- {
- passed = false;
-
- addError("Was expecting no exceptions.\n");
- addError("Got the following exceptions on the producer, " + circuit.getExceptionMonitor());
- }
-
- return passed;
- }
- };
- }
-
- /**
- * Provides an assertion that the AMQP channel was forcibly closed by an error condition.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the AMQP channel was forcibly closed by an error condition.
- */
- public Assertion channelClosedAssertion(ParsedProperties testProps)
- {
- return new NotApplicableAssertion(testProps);
- }
-
- /**
- * Provides an assertion that the publisher got a given exception during the test.
- *
- * @param testProps The test configuration properties.
- * @param exceptionClass The exception class to check for.
- *
- * @return An assertion that the publisher got a given exception during the test.
- */
- public Assertion exceptionAssertion(ParsedProperties testProps, final Class<? extends Exception> exceptionClass)
- {
- return new AssertionBase()
- {
- public boolean apply()
- {
- boolean passed = true;
- ExceptionMonitor connectionExceptionMonitor = circuit.getConnectionExceptionMonitor();
-
- if (!connectionExceptionMonitor.assertExceptionOfType(exceptionClass))
- {
- passed = false;
-
- addError("Was expecting linked exception type " + exceptionClass.getName()
- + " on the connection.\n");
- addError((connectionExceptionMonitor.size() > 0)
- ? ("Actually got the following exceptions on the connection, " + connectionExceptionMonitor)
- : "Got no exceptions on the connection.");
- }
-
- return passed;
- }
- };
- }
-
- /**
- * Sets the contianing circuit.
- *
- * @param circuit The containing circuit.
- */
- public void setCircuit(LocalCircuitImpl circuit)
- {
- this.circuit = circuit;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalReceiverImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalReceiverImpl.java
deleted file mode 100644
index bb242faf90..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalReceiverImpl.java
+++ /dev/null
@@ -1,149 +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.test.framework.localcircuit;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.CircuitEnd;
-import org.apache.qpid.test.framework.CircuitEndBase;
-import org.apache.qpid.test.framework.ExceptionMonitor;
-import org.apache.qpid.test.framework.MessageMonitor;
-import org.apache.qpid.test.framework.NotApplicableAssertion;
-import org.apache.qpid.test.framework.Receiver;
-
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * Provides an implementation of the {@link Receiver} interface that wraps a single message producer and consumer on
- * a single controlSession, as a {@link CircuitEnd}. A local receiver also acts as a circuit end, because for a locally
- * located circuit the assertions may be applied directly, there does not need to be any inter process messaging
- * between the publisher and its single circuit end, in order to ascertain its status.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide a message producer for sending messages.
- * <tr><td> Provide a message consumer for receiving messages.
- * <tr><td> Provide assertion that the receivers received no exceptions.
- * <tr><td> Provide assertion that the receivers received all test messages sent to it.
- * </table>
- */
-public class LocalReceiverImpl extends CircuitEndBase implements Receiver
-{
- /** Holds a reference to the containing circuit. */
- private LocalCircuitImpl circuit;
-
- /**
- * Creates a circuit end point on the specified producer, consumer and controlSession. Monitors are also configured
- * for messages and exceptions received by the circuit end.
- *
- * @param producer The message producer for the circuit end point.
- * @param consumer The message consumer for the circuit end point.
- * @param session The controlSession for the circuit end point.
- * @param messageMonitor The monitor to notify of all messages received by the circuit end.
- * @param exceptionMonitor The monitor to notify of all exceptions received by the circuit end.
- */
- public LocalReceiverImpl(MessageProducer producer, MessageConsumer consumer, Session session,
- MessageMonitor messageMonitor, ExceptionMonitor exceptionMonitor)
- {
- super(producer, consumer, session, messageMonitor, exceptionMonitor);
- }
-
- /**
- * Creates a circuit end point from the producer, consumer and controlSession in a circuit end base implementation.
- *
- * @param end The circuit end base implementation to take producers and consumers from.
- */
- public LocalReceiverImpl(CircuitEndBase end)
- {
- super(end.getProducer(), end.getConsumer(), end.getSession(), end.getMessageMonitor(), end.getExceptionMonitor());
- }
-
- /**
- * Provides an assertion that the receivers encountered no exceptions.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the receivers encountered no exceptions.
- */
- public Assertion noExceptionsAssertion(ParsedProperties testProps)
- {
- return new NotApplicableAssertion(testProps);
- }
-
- /**
- * Provides an assertion that the AMQP channel was forcibly closed by an error condition.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the AMQP channel was forcibly closed by an error condition.
- */
- public Assertion channelClosedAssertion(ParsedProperties testProps)
- {
- return new NotApplicableAssertion(testProps);
- }
-
- /**
- * Provides an assertion that the receivers got all messages that were sent to it.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the receivers got all messages that were sent to it.
- */
- public Assertion allMessagesReceivedAssertion(ParsedProperties testProps)
- {
- return new NotApplicableAssertion(testProps);
- }
-
- /**
- * Provides an assertion that the receivers got none of the messages that were sent to it.
- *
- * @param testProps The test configuration properties.
- *
- * @return An assertion that the receivers got none of the messages that were sent to it.
- */
- public Assertion noMessagesReceivedAssertion(ParsedProperties testProps)
- {
- return new NotApplicableAssertion(testProps);
- }
-
- /**
- * Provides an assertion that the receiver got a given exception during the test.
- *
- * @param testProps The test configuration properties.
- * @param exceptionClass The exception class to check for. @return An assertion that the receiver got a given exception during the test.
- */
- public Assertion exceptionAssertion(ParsedProperties testProps, Class<? extends Exception> exceptionClass)
- {
- return new NotApplicableAssertion(testProps);
- }
-
- /**
- * Sets the contianing circuit.
- *
- * @param circuit The containing circuit.
- */
- public void setCircuit(LocalCircuitImpl circuit)
- {
- this.circuit = circuit;
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/package.html b/java/systests/src/main/java/org/apache/qpid/test/framework/package.html
deleted file mode 100644
index ac4e30d312..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/package.html
+++ /dev/null
@@ -1,43 +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.
-
--->
-
-<html>
-<body>
-<p/>A framework for testing Qpid, built around a standard 'test circuit' design. The idea behind this framework is the
-use of a test circuit which is configured by a set of test parameters, that may be projected onto a topology of
-test nodes, with tests scripted to run over test circuits, making as few assumptions as possible about the underlying
-topology. The standardization of the design, whilst limiting in some respectes, allows a large variety of test
-scenarios to be written with minimal amounts of coding.
-
-<p/>The standard consruction block for a test, is a test circuit. This consists of a publisher, and a receiver. The
-publisher and receiver may reside on the same machine, or may be distributed. Will use a standard set of properties to
-define the desired circuit topology.
-
-<p/>Tests are always to be controlled from the publishing side only. The receiving end of the circuit is to be exposed
-to the test code through an interface, that abstracts as much as possible the receiving end of the test. The interface
-exposes a set of 'assertions' that may be applied to the receiving end of the test circuit.
-
-<p/>In the case where the receiving end of the circuit resides on the same JVM, the assertions will call the receivers
-code locally. Where the receiving end is distributed accross one or more machines, the assertions will be applied to a
-test report gethered from all of the receivers. Test code will be written to the assertions making as few assumptions
-as possible about the exact test topology.
-</body>
-</html>
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/BaseCircuitFactory.java b/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/BaseCircuitFactory.java
deleted file mode 100644
index bd27fc3d90..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/BaseCircuitFactory.java
+++ /dev/null
@@ -1,136 +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.test.framework.sequencers;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * BaseCircuitFactory provides some functionality common to all {@link CircuitFactory}s, such as the details of
- * all {@link org.apache.qpid.test.framework.distributedtesting.TestClient}s that make up the end-points of
- * the circuits that the factory creates, and an active {@link ConversationFactory} that can be used to generate
- * control conversations with those circuit end-points.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Hold the details of the sending and receiving end-points to create circuits from.
- * <tr><td> Provide a conversation factory to create control conversations with the end-points.
- * </table>
- */
-public abstract class BaseCircuitFactory implements CircuitFactory
-{
-
- /** Used for debugging. */
- private final Logger log = Logger.getLogger(BaseCircuitFactory.class);
-
- /** Holds the contact details for the sending test client. */
- protected TestClientDetails sender;
-
- /** Holds the contact details for the receving test client. */
- protected List<TestClientDetails> receivers = new LinkedList<TestClientDetails>();
-
- /** Holds the conversation factory over which to coordinate the test. */
- protected ConversationFactory conversationFactory;
-
- /**
- * Creates a test circuit for the test, configered by the test parameters specified.
- *
- * @param testProperties The test parameters.
- * @return A test circuit.
- */
- public Circuit createCircuit(Properties testProperties)
- {
- throw new RuntimeException("Not implemented.");
- }
-
- /**
- * Sets the sender test client to coordinate the test with.
- *
- * @param sender The contact details of the sending client in the test.
- */
- public void setSender(TestClientDetails sender)
- {
- log.debug("public void setSender(TestClientDetails sender = " + sender + "): called");
-
- this.sender = sender;
- }
-
- /**
- * Sets the receiving test client to coordinate the test with.
- *
- * @param receiver The contact details of the sending client in the test.
- */
- public void setReceiver(TestClientDetails receiver)
- {
- log.debug("public void setReceiver(TestClientDetails receivers = " + receiver + "): called");
-
- this.receivers.add(receiver);
- }
-
- /**
- * Supplies the sending test client.
- *
- * @return The sending test client.
- */
- public TestClientDetails getSender()
- {
- return sender;
- }
-
- /**
- * Supplies the receiving test client.
- *
- * @return The receiving test client.
- */
- public List<TestClientDetails> getReceivers()
- {
- return receivers;
- }
-
- /**
- * Accepts the conversation factory over which to hold the test coordinating conversation.
- *
- * @param conversationFactory The conversation factory to coordinate the test over.
- */
- public void setConversationFactory(ConversationFactory conversationFactory)
- {
- this.conversationFactory = conversationFactory;
- }
-
- /**
- * Provides the conversation factory for providing the distributed test sequencing conversations over the test
- * connection.
- *
- * @return The conversation factory to create test sequencing conversations with.
- */
- public ConversationFactory getConversationFactory()
- {
- return conversationFactory;
- }
-}
-
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java b/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java
deleted file mode 100644
index 9b5d40fd48..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java
+++ /dev/null
@@ -1,101 +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.test.framework.sequencers;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Connection;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * A CircuitFactory is responsibile for creating test circuits appropriate to the context that a test case is
- * running in, and providing an implementation of a standard test procedure over a test circuit.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Provide a standard test procedure over a test circuit.
- * <tr><td> Construct test circuits appropriate to a tests context.
- * </table>
- */
-public interface CircuitFactory
-{
- /**
- * Holds a test coordinating conversation with the test clients. This should consist of assigning the test roles,
- * begining the test, gathering the test reports from the participants, and checking for assertion failures against
- * the test reports.
- *
- * @param testCircuit The test circuit.
- * @param assertions The list of assertions to apply to the test circuit.
- * @param testProperties The test case definition.
- *
- * @deprecated Use test circuits and Circuit.test instead.
- */
- public void sequenceTest(Circuit testCircuit, List<Assertion> assertions, Properties testProperties);
-
- /**
- * Creates a test circuit for the test, configered by the test parameters specified.
- *
- * @param testProperties The test parameters.
- *
- * @return A test circuit.
- */
- public Circuit createCircuit(Connection connection, ParsedProperties testProperties);
-
- /**
- * Sets the sender test client to coordinate the test with.
- *
- * @param sender The contact details of the sending client in the test.
- */
- public void setSender(TestClientDetails sender);
-
- /**
- * Sets the receiving test client to coordinate the test with.
- *
- * @param receiver The contact details of the sending client in the test.
- */
- public void setReceiver(TestClientDetails receiver);
-
- /**
- * Supplies the sending test client.
- *
- * @return The sending test client.
- */
- public TestClientDetails getSender();
-
- /**
- * Supplies the receiving test client.
- *
- * @return The receiving test client.
- */
- public List<TestClientDetails> getReceivers();
-
- /**
- * Accepts the conversation factory over which to hold the test coordinating conversation.
- *
- * @param conversationFactory The conversation factory to coordinate the test over.
- */
- public void setConversationFactory(ConversationFactory conversationFactory);
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java b/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java
deleted file mode 100644
index 833f5fb674..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java
+++ /dev/null
@@ -1,200 +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.test.framework.sequencers;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.framework.TestUtils;
-import org.apache.qpid.test.framework.distributedcircuit.DistributedCircuitImpl;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * FanOutCircuitFactory is a circuit factory that creates distributed test circuits. Given a set of participating
- * test client nodes, it assigns one node to the SENDER role and the remainder to the RECEIVER role.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Create distributed circuits from one to many test nodes, for fanout style testing.
- * </table>
- *
- * @todo Adapt this to be an n*m topology circuit factory. Need to add circuit topology definitions to the test
- * parameters. Place n senders onto the available test clients, and m receivers. Where n or m is larger than
- * the available nodes, start stacking multiple test clients on each node. There will also be an option that
- * indicates whether nodes can play both roles, and how many nodes out of all available may be assigned to
- * each role.
- *
- * @todo The createCircuit methods on this and InteropCircuitFactory are going to be identical. This is because the
- * partitioning into senders and receivers is already done by the test decorators. Either eliminate these factories
- * as unnesesary, or move the partitioning functionality into the factories, in which case the test decorators
- * can probably be merged or eliminated. There is confusion over the placement of responsibilities between the
- * factories and the test decorators... although the test decorators may well do more than just circuit creation
- * in the future. For example, there may have to be a special decorator for test repetition that does one circuit
- * creation, but the runs many tests over it, in which case the handling of responsibilities becomes clearer.
- */
-public class FanOutCircuitFactory extends BaseCircuitFactory
-{
- /** Used for debugging. */
- private Logger log = Logger.getLogger(FanOutCircuitFactory.class);
-
- /**
- * Creates a test circuit for the test, configered by the test parameters specified.
- *
- * @param testProperties The test parameters.
- * @return A test circuit.
- */
- public Circuit createCircuit(Connection connection, ParsedProperties testProperties)
- {
- log.debug("public Circuit createCircuit(ParsedProperties testProperties): called");
-
- List<TestClientDetails> senders = new LinkedList<TestClientDetails>();
- senders.add(getSender());
- List<TestClientDetails> receivers = getReceivers();
- ConversationFactory conversationFactory = getConversationFactory();
-
- return DistributedCircuitImpl.createCircuit(testProperties, senders, receivers, conversationFactory);
- }
-
- /**
- * Holds a test coordinating conversation with the test clients. This should consist of assigning the test roles,
- * begining the test, gathering the test reports from the participants, and checking for assertion failures against
- * the test reports.
- *
- * @param testCircuit The test circuit.
- * @param assertions The list of assertions to apply to the test circuit.
- * @param testProperties The test case definition.
- *
- * @deprecated Scheduled for removal once existing tests converted over to use test circuits.
- */
- public void sequenceTest(Circuit testCircuit, List<Assertion> assertions, Properties testProperties)
- {
- log.debug("protected Message[] sequenceTest(Object... testProperties = " + testProperties + "): called");
-
- TestClientDetails sender = getSender();
- List<TestClientDetails> receivers = getReceivers();
- ConversationFactory conversationFactory = getConversationFactory();
-
- try
- {
- // Create a conversation on the sender clients private control route.
- Session session = conversationFactory.getSession();
- Destination senderControlTopic = session.createTopic(sender.privateControlKey);
- ConversationFactory.Conversation senderConversation = conversationFactory.startConversation();
-
- // Assign the sender role to the sending test client.
- Message assignSender = conversationFactory.getSession().createMessage();
- TestUtils.setPropertiesOnMessage(assignSender, testProperties);
- assignSender.setStringProperty("CONTROL_TYPE", "ASSIGN_ROLE");
- assignSender.setStringProperty("ROLE", "SENDER");
- assignSender.setStringProperty("CLIENT_NAME", "Sustained_SENDER");
-
- senderConversation.send(senderControlTopic, assignSender);
-
- // Wait for the sender to confirm its role.
- senderConversation.receive();
-
- // Assign the receivers roles.
- for (TestClientDetails receiver : receivers)
- {
- assignReceiverRole(receiver, testProperties, true);
- }
-
- // Start the test on the sender.
- Message start = session.createMessage();
- start.setStringProperty("CONTROL_TYPE", "START");
-
- senderConversation.send(senderControlTopic, start);
-
- // Wait for the test sender to return its report.
- Message senderReport = senderConversation.receive();
- TestUtils.pause(500);
-
- // Ask the receivers for their reports.
- Message statusRequest = session.createMessage();
- statusRequest.setStringProperty("CONTROL_TYPE", "STATUS_REQUEST");
-
- // Gather the reports from all of the receiving clients.
-
- // Return all of the test reports, the senders report first.
- // return new Message[] { senderReport };
- }
- catch (JMSException e)
- {
- throw new RuntimeException("Unhandled JMSException.");
- }
- }
-
- /**
- * Assigns the receivers role to the specified test client that is to act as a receivers during the test. This method
- * does not always wait for the receiving clients to confirm their role assignments. This is because this method
- * may be called from an 'onMessage' method, when a client is joining the test at a later point in time, and it
- * is not possible to do a synchronous receive during an 'onMessage' method. There is a flag to indicate whether
- * or not to wait for role confirmations.
- *
- * @param receiver The test client to assign the receivers role to.
- * @param testProperties The test parameters.
- * @param confirm Indicates whether role confirmation should be waited for.
- *
- * @throws JMSException Any JMSExceptions occurring during the conversation are allowed to fall through.
- *
- * @deprecated Scheduled for removal once existing tests converted over to use test circuits.
- */
- protected void assignReceiverRole(TestClientDetails receiver, Properties testProperties, boolean confirm)
- throws JMSException
- {
- log.info("assignReceiverRole(TestClientDetails receivers = " + receiver + ", Map<String, Object> testProperties = "
- + testProperties + "): called");
-
- ConversationFactory conversationFactory = getConversationFactory();
-
- // Create a conversation with the receiving test client.
- Session session = conversationFactory.getSession();
- Destination receiverControlTopic = session.createTopic(receiver.privateControlKey);
- ConversationFactory.Conversation receiverConversation = conversationFactory.startConversation();
-
- // Assign the receivers role to the receiving client.
- Message assignReceiver = session.createMessage();
- TestUtils.setPropertiesOnMessage(assignReceiver, testProperties);
- assignReceiver.setStringProperty("CONTROL_TYPE", "ASSIGN_ROLE");
- assignReceiver.setStringProperty("ROLE", "RECEIVER");
- assignReceiver.setStringProperty("CLIENT_NAME", receiver.clientName);
-
- receiverConversation.send(receiverControlTopic, assignReceiver);
-
- // Wait for the role confirmation to come back.
- if (confirm)
- {
- receiverConversation.receive();
- }
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java b/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java
deleted file mode 100644
index a4c6888d68..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java
+++ /dev/null
@@ -1,154 +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.test.framework.sequencers;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.test.framework.Assertion;
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.framework.TestUtils;
-import org.apache.qpid.test.framework.distributedcircuit.DistributedCircuitImpl;
-import org.apache.qpid.test.utils.ConversationFactory;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * InteropCircuitFactory is a circuit factory that creates distributed test circuits. Given a set of participating
- * test client nodes, it assigns one node to the SENDER role and one the RECEIVER role.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Create distributed circuits from pairs of test nodes, for interop style testing.
- * </table>
- *
- * @todo The partitioning of a set of nodes into sender and receiver roles is actually done by the interop test
- * decorator. See the todo comment in FanOutCircuitFactory about merging the factories with the decorators, or
- * more carefully dividing up responsibilities between them.
- *
- * @todo The squenceTest code is deprecated, but currently still used by the interop tests. It will be removed once it
- * have been fully replaced by the default test procedure.
- */
-public class InteropCircuitFactory extends BaseCircuitFactory
-{
- /** Used for debugging. */
- private Logger log = Logger.getLogger(InteropCircuitFactory.class);
-
- /**
- * Creates a test circuit for the test, configered by the test parameters specified.
- *
- * @param testProperties The test parameters.
- * @return A test circuit.
- */
- public Circuit createCircuit(Connection connection, ParsedProperties testProperties)
- {
- log.debug("public Circuit createCircuit(ParsedProperties testProperties): called");
-
- List<TestClientDetails> senders = new LinkedList<TestClientDetails>();
- senders.add(getSender());
- List<TestClientDetails> receivers = getReceivers();
- ConversationFactory conversationFactory = getConversationFactory();
-
- return DistributedCircuitImpl.createCircuit(testProperties, senders, receivers, conversationFactory);
- }
-
- /**
- * Holds a test coordinating conversation with the test clients. This should consist of assigning the test roles,
- * begining the test, gathering the test reports from the participants, and checking for assertion failures against
- * the test reports.
- *
- * @param testCircuit The test circuit.
- * @param assertions The list of assertions to apply to the test circuit.
- * @param testProperties The test case definition.
- */
- public void sequenceTest(Circuit testCircuit, List<Assertion> assertions, Properties testProperties)
- {
- log.debug("protected Message[] sequenceTest(Object... testProperties = " + testProperties + "): called");
-
- TestClientDetails sender = getSender();
- List<TestClientDetails> receivers = getReceivers();
- ConversationFactory conversationFactory = getConversationFactory();
-
- try
- {
- Session session = conversationFactory.getSession();
- Destination senderControlTopic = session.createTopic(sender.privateControlKey);
- Destination receiverControlTopic = session.createTopic(receivers.get(0).privateControlKey);
-
- ConversationFactory.Conversation senderConversation = conversationFactory.startConversation();
- ConversationFactory.Conversation receiverConversation = conversationFactory.startConversation();
-
- Message assignSender = conversationFactory.getSession().createMessage();
- TestUtils.setPropertiesOnMessage(assignSender, testProperties);
- assignSender.setStringProperty("CONTROL_TYPE", "ASSIGN_ROLE");
- assignSender.setStringProperty("ROLE", "SENDER");
-
- senderConversation.send(senderControlTopic, assignSender);
-
- // Assign the receivers role the receiving client.
- Message assignReceiver = session.createMessage();
- TestUtils.setPropertiesOnMessage(assignReceiver, testProperties);
- assignReceiver.setStringProperty("CONTROL_TYPE", "ASSIGN_ROLE");
- assignReceiver.setStringProperty("ROLE", "RECEIVER");
-
- receiverConversation.send(receiverControlTopic, assignReceiver);
-
- // Wait for the senders and receivers to confirm their roles.
- senderConversation.receive();
- receiverConversation.receive();
-
- // Start the test.
- Message start = session.createMessage();
- start.setStringProperty("CONTROL_TYPE", "START");
-
- senderConversation.send(senderControlTopic, start);
-
- // Wait for the test sender to return its report.
- Message senderReport = senderConversation.receive();
- TestUtils.pause(500);
-
- // Ask the receivers for its report.
- Message statusRequest = session.createMessage();
- statusRequest.setStringProperty("CONTROL_TYPE", "STATUS_REQUEST");
-
- receiverConversation.send(receiverControlTopic, statusRequest);
-
- // Wait for the receivers to send its report.
- Message receiverReport = receiverConversation.receive();
-
- // return new Message[] { senderReport, receiverReport };
-
- // Apply assertions.
- }
- catch (JMSException e)
- {
- throw new RuntimeException("JMSException not handled.");
- }
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java
index 707c4b6a47..841d0ea4ba 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java
@@ -56,7 +56,6 @@ public class AcknowledgeTest extends QpidBrokerTestCase
_queue = getTestQueue();
- _logger.info("AT: setup");
//Create Producer put some messages on the queue
_connection = getConnection();
}
@@ -70,13 +69,10 @@ public class AcknowledgeTest extends QpidBrokerTestCase
// These should all end up being prefetched by session
sendMessage(_consumerSession, _queue, 1);
- if(!transacted)
- {
- ((AMQSession)_consumerSession).sync();
- }
+ syncIfNotTransacted(transacted);
assertEquals("Wrong number of messages on queue", 1,
- ((AMQSession) _consumerSession).getQueueDepth((AMQDestination) _queue));
+ ((AMQSession<?,?>) _consumerSession).getQueueDepth((AMQDestination) _queue));
}
/**
@@ -114,6 +110,7 @@ public class AcknowledgeTest extends QpidBrokerTestCase
{
//Send the next message
_producer.send(createNextMessage(_consumerSession, count));
+ syncIfNotTransacted(transacted);
}
doAcknowlegement(msg);
@@ -128,7 +125,7 @@ public class AcknowledgeTest extends QpidBrokerTestCase
}
assertEquals("Wrong number of messages on queue", 0,
- ((AMQSession) _consumerSession).getQueueDepth((AMQDestination) _queue));
+ ((AMQSession<?,?>) _consumerSession).getQueueDepth((AMQDestination) _queue));
}
/**
@@ -181,4 +178,11 @@ public class AcknowledgeTest extends QpidBrokerTestCase
testAcking(false, AMQSession.PRE_ACKNOWLEDGE);
}
+ private void syncIfNotTransacted(boolean transacted) throws Exception
+ {
+ if(!transacted)
+ {
+ ((AMQSession<?,?>)_consumerSession).sync();
+ }
+ }
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
index 8afc3f6997..a121b39a56 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
@@ -36,6 +36,7 @@ import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
+import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.MessageNotReadableException;
import javax.jms.MessageNotWriteableException;
@@ -278,4 +279,46 @@ public class BytesMessageTest extends QpidBrokerTestCase implements MessageListe
test._count = count;
test.test();
}
+
+ public void testModificationAfterSend() throws Exception
+ {
+ Connection connection = getConnection();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ BytesMessage jmsMsg = session.createBytesMessage();
+ Destination destination = getTestQueue();
+
+ /* Set the constant message contents. */
+
+ jmsMsg.setStringProperty("foo", "test");
+
+ /* Pre-populate the message body buffer to the target size. */
+ byte[] jmsMsgBodyBuffer = new byte[1024];
+
+ connection.start();
+
+ /* Send messages. */
+ MessageProducer producer = session.createProducer(destination);
+
+ MessageConsumer consumer = session.createConsumer(destination);
+
+ for(int writtenMsgCount = 0; writtenMsgCount < 10; writtenMsgCount++)
+ {
+ /* Set the per send message contents. */
+ jmsMsgBodyBuffer[0] = (byte) writtenMsgCount;
+ jmsMsg.writeBytes(jmsMsgBodyBuffer, 0, jmsMsgBodyBuffer.length);
+ /** Try to write a message. */
+ producer.send(jmsMsg);
+ }
+
+
+ for(int writtenMsgCount = 0; writtenMsgCount < 10; writtenMsgCount++)
+ {
+ BytesMessage recvdMsg = (BytesMessage) consumer.receive(1000L);
+ assertNotNull("Expected to receive message " + writtenMsgCount + " but did not", recvdMsg);
+ assertEquals("Message "+writtenMsgCount+" not of expected size", (long) ((writtenMsgCount + 1)*1024),
+ recvdMsg.getBodyLength());
+
+ }
+ }
+
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ReceiveTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
deleted file mode 100644
index c764eda799..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
+++ /dev/null
@@ -1,82 +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.test.unit.basic;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-
-public class ReceiveTest extends QpidBrokerTestCase
-{
- private AMQConnection _connection;
- private AMQDestination _destination;
- private AMQSession _session;
- private MessageConsumer _consumer;
-
- protected void setUp() throws Exception
- {
- super.setUp();
- init((AMQConnection) getConnection("guest", "guest"));
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- private void init(AMQConnection connection) throws Exception
- {
- init(connection, new AMQQueue(connection,"ReceiveTest", true));
- }
-
- private void init(AMQConnection connection, AMQDestination destination) throws Exception
- {
- _connection = connection;
- _destination = destination;
- _session = (AMQSession) connection.createSession(true, AMQSession.NO_ACKNOWLEDGE);
- _consumer = _session.createConsumer(_destination);
- _connection.start();
- }
-
- public void test() throws Exception
- {
- Message m = _consumer.receive(5000);
- assertNull("should not have received a message", m);
- _connection.close();
- }
-
-
- public static junit.framework.Test suite()
- {
- // TODO: note that this test doesn't use the VMBrokerSetup
- // test helper class to create and tear down its
- // VMBroker. This is because the main() above seems to
- // indicate that it's also used outside of the surefire test
- // framework. If it isn't, then this test should also be
- // changed to use VMBrokerSetup here.
- return new junit.framework.TestSuite(ReceiveTest.class);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
index 6b83929258..5b3bca7033 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.qpid.AMQConnectionClosedException;
import org.apache.qpid.AMQDisconnectedException;
+import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.management.jmx.ManagedConnectionMBeanTest;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.apache.qpid.transport.ConnectionException;
@@ -62,10 +63,13 @@ public class BrokerClosesClientConnectionTest extends QpidBrokerTestCase
{
final Class<? extends Exception> expectedLinkedException = isBroker010() ? ConnectionException.class : AMQConnectionClosedException.class;
+ assertConnectionOpen();
+
stopBroker();
JMSException exception = _recordingExceptionListener.awaitException(10000);
assertConnectionCloseWasReported(exception, expectedLinkedException);
+ assertConnectionClosed();
ensureCanCloseWithoutException();
}
@@ -79,10 +83,13 @@ public class BrokerClosesClientConnectionTest extends QpidBrokerTestCase
return;
}
+ assertConnectionOpen();
+
killBroker();
JMSException exception = _recordingExceptionListener.awaitException(10000);
assertConnectionCloseWasReported(exception, expectedLinkedException);
+ assertConnectionClosed();
ensureCanCloseWithoutException();
}
@@ -107,6 +114,16 @@ public class BrokerClosesClientConnectionTest extends QpidBrokerTestCase
assertEquals("Unexpected linked exception", linkedExceptionClass, exception.getLinkedException().getClass());
}
+ private void assertConnectionClosed()
+ {
+ assertTrue("Connection should be marked as closed", ((AMQConnection)_connection).isClosed());
+ }
+
+ private void assertConnectionOpen()
+ {
+ assertFalse("Connection should not be marked as closed", ((AMQConnection)_connection).isClosed());
+ }
+
private final class RecordingExceptionListener implements ExceptionListener
{
private final CountDownLatch _exceptionReceivedLatch = new CountDownLatch(1);
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/close/CloseBeforeAckTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/close/CloseBeforeAckTest.java
deleted file mode 100644
index 4da9a1db29..0000000000
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/close/CloseBeforeAckTest.java
+++ /dev/null
@@ -1,140 +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.test.unit.close;
-
-import junit.framework.Assert;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.junit.concurrency.TestRunnable;
-import org.apache.qpid.junit.concurrency.ThreadTestCoordinator;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-
-/**
- * This test forces the situation where a session is closed whilst a message consumer is still in its onMessage method.
- * Running in AUTO_ACK mode, the close call ought to wait until the onMessage method completes, and the ack is sent
- * before closing the connection.
- *
- * <p><table id="crc"><caption>CRC Card</caption> <tr><th> Responsibilities <th> Collaborations <tr><td> Check that
- * closing a connection whilst handling a message, blocks till completion of the handler. </table>
- */
-public class CloseBeforeAckTest extends QpidBrokerTestCase
-{
- private static final Logger log = LoggerFactory.getLogger(CloseBeforeAckTest.class);
-
- private Connection connection;
- private Session session;
- public static final String TEST_QUEUE_NAME = "TestQueue";
- private int TEST_COUNT = 25;
-
- class TestThread1 extends TestRunnable implements MessageListener
- {
- public void runWithExceptions() throws Exception
- {
- // Set this up to listen for message on the test session.
- session.createConsumer(session.createQueue(TEST_QUEUE_NAME)).setMessageListener(this);
- }
-
- public void onMessage(Message message)
- {
- // Give thread 2 permission to close the session.
- allow(new int[] { 1 });
-
- // Wait until thread 2 has closed the connection, or is blocked waiting for this to complete.
- waitFor(new int[] { 1 }, true);
- }
- }
-
- private TestThread1 testThread1 = new TestThread1();
-
- private TestRunnable testThread2 =
- new TestRunnable()
- {
- public void runWithExceptions() throws Exception
- {
- // Send a message to be picked up by thread 1.
- session.createProducer(null).send(session.createQueue(TEST_QUEUE_NAME),
- session.createTextMessage("Hi there thread 1!"));
-
- // Wait for thread 1 to pick up the message and give permission to continue.
- waitFor(new int[] { 0 }, false);
-
- // Close the connection.
- session.close();
-
- // Allow thread 1 to continue to completion, if it is erronously still waiting.
- allow(new int[] { 1 });
- }
- };
-
- public void testCloseBeforeAutoAck_QPID_397() throws Exception
- {
- // Create a session in auto acknowledge mode. This problem shows up in auto acknowledge if the client acks
- // message at the end of the onMessage method, after a close has been sent.
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- ThreadTestCoordinator tt = new ThreadTestCoordinator(2);
-
- tt.addTestThread(testThread1, 0);
- tt.addTestThread(testThread2, 1);
- tt.setDeadlockTimeout(500);
- tt.run();
-
- String errorMessage = tt.joinAndRetrieveMessages();
-
- // Print any error messages or exceptions.
- log.debug(errorMessage);
-
- if (!tt.getExceptions().isEmpty())
- {
- for (Exception e : tt.getExceptions())
- {
- log.debug("Exception thrown during test thread: ", e);
- }
- }
-
- Assert.assertTrue(errorMessage, "".equals(errorMessage));
- }
-
- public void closeBeforeAutoAckManyTimes() throws Exception
- {
- for (int i = 0; i < TEST_COUNT; i++)
- {
- testCloseBeforeAutoAck_QPID_397();
- }
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- connection = getConnection("guest", "guest");
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
new file mode 100644
index 0000000000..df32bd7858
--- /dev/null
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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 java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+public class MessageConsumerCloseTest extends QpidBrokerTestCase
+{
+ Exception _exception;
+
+ public void testConsumerCloseAndSessionRollback() throws Exception
+ {
+ Connection connection = getConnection();
+ final CountDownLatch receiveLatch = new CountDownLatch(1);
+ final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Destination destination = getTestQueue();
+ MessageConsumer consumer = session.createConsumer(destination);
+ sendMessage(session, destination, 2);
+ connection.start();
+ consumer.setMessageListener(new MessageListener()
+ {
+ @Override
+ public void onMessage(Message message)
+ {
+ try
+ {
+ receiveLatch.countDown();
+ session.rollback();
+ }
+ catch (JMSException e)
+ {
+ _exception = e;
+ }
+ }
+ });
+ boolean messageReceived = receiveLatch.await(1l, TimeUnit.SECONDS);
+ consumer.close();
+
+ assertNull("Exception occured on rollback:" + _exception, _exception);
+ assertTrue("Message is not received", messageReceived);
+
+ consumer = session.createConsumer(destination);
+ Message message1 = consumer.receive(1000l);
+ assertNotNull("message1 is not received", message1);
+ Message message2 = consumer.receive(1000l);
+ assertNotNull("message2 is not received", message2);
+ }
+}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
index 77627e2782..c292c718bb 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
@@ -379,7 +379,7 @@ public class DurableSubscriberTest extends QpidBrokerTestCase
// Create durable subscriber that matches A
TopicSubscriber subA = session.createDurableSubscriber(topic,
- "testResubscribeWithChangedSelector",
+ "testResubscribeWithChangedSelectorAndRestart",
"Match = True", false);
// Send 1 matching message and 1 non-matching message
@@ -397,8 +397,8 @@ public class DurableSubscriberTest extends QpidBrokerTestCase
((TextMessage) rMsg).getText());
// Queue has no messages left
- AMQQueue subQueueTmp = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
- assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueueTmp));
+ AMQQueue subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
+ assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
rMsg = subA.receive(1000);
assertNull(rMsg);
@@ -423,8 +423,7 @@ public class DurableSubscriberTest extends QpidBrokerTestCase
//verify no messages are now present on the queue as changing selector should have issued
//an unsubscribe and thus deleted the previous durable backing queue for the subscription.
//check the dur sub's underlying queue now has msg count 0
- AMQQueue subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
- assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue));
+ assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
// Check that new messages are received properly
msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart1");
@@ -444,8 +443,8 @@ public class DurableSubscriberTest extends QpidBrokerTestCase
assertNull(rMsg);
//check the dur sub's underlying queue now has msg count 0
- subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
- assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue));
+ assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
+ conn.close();
//now restart the server
try
@@ -467,8 +466,7 @@ public class DurableSubscriberTest extends QpidBrokerTestCase
//verify no messages now present on the queue after we restart the broker
//check the dur sub's underlying queue now has msg count 0
- subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
- assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue));
+ assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
// Reconnect with new selector that matches B
TopicSubscriber subC = session.createDurableSubscriber(topic,
@@ -484,8 +482,7 @@ public class DurableSubscriberTest extends QpidBrokerTestCase
producer.send(msg);
//check the dur sub's underlying queue now has msg count 1
- subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
- assertEquals("Msg count should be 1", 1, ((AMQSession<?, ?>) session).getQueueDepth(subQueue));
+ assertEquals("Msg count should be 1", 1, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
rMsg = subC.receive(1000);
assertNotNull(rMsg);
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
index 40c78284da..a07e531b98 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
@@ -147,7 +147,7 @@ public class DurableSubscriptionTest extends QpidBrokerTestCase
((AMQSession<?, ?>) session2).sync();
- if(isJavaBroker() && isExternalBroker())
+ if(isJavaBroker())
{
//Verify that the queue was deleted by querying for its JMX MBean
_jmxc = JMXConnnectionFactory.getJMXConnection(5000, "127.0.0.1",
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java
index f554b0089e..cc76d89a67 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java
@@ -20,6 +20,12 @@
*/
package org.apache.qpid.test.unit.transacted;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+
/**
* This tests the behaviour of transactional sessions when the {@code transactionTimeout} configuration
* is set for a virtual host.
@@ -305,4 +311,33 @@ public class TransactionTimeoutTest extends TransactionTimeoutTestCase
monitor(0, 0);
}
+
+ /**
+ * Tests that sending an unroutable persistent message does not result in a long running store transaction [warning].
+ */
+ public void testTransactionCommittedOnNonRoutableQueuePersistentMessage() throws Exception
+ {
+ checkTransactionCommittedOnNonRoutableQueueMessage(DeliveryMode.PERSISTENT);
+ }
+
+ /**
+ * Tests that sending an unroutable transient message does not result in a long running store transaction [warning].
+ */
+ public void testTransactionCommittedOnNonRoutableQueueTransientMessage() throws Exception
+ {
+ checkTransactionCommittedOnNonRoutableQueueMessage(DeliveryMode.NON_PERSISTENT);
+ }
+
+ private void checkTransactionCommittedOnNonRoutableQueueMessage(int deliveryMode) throws JMSException, Exception
+ {
+ Queue nonExisting = _psession.createQueue(getTestQueueName() + System.currentTimeMillis());
+ MessageProducer producer = _psession.createProducer(nonExisting);
+ Message message = _psession.createMessage();
+ producer.send(message, deliveryMode, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+ _psession.commit();
+
+ // give time to house keeping thread to log messages
+ sleep(3f);
+ monitor(0, 0);
+ }
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java
index 86ba5c2cb7..e940a73bbb 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java
@@ -118,7 +118,7 @@ public class FaultTest extends AbstractXATestCase
_queueFactory = getConnectionFactory();
_xaqueueConnection = _queueFactory.createXAQueueConnection("guest", "guest");
XAQueueSession session = _xaqueueConnection.createXAQueueSession();
- _queueConnection = _queueFactory.createQueueConnection();
+ _queueConnection = _queueFactory.createQueueConnection("guest","guest");
_nonXASession = _queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
init(session, _queue);
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java
index eb19504dec..3fbe76323a 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java
@@ -162,11 +162,12 @@ public class QueueTest extends AbstractXATestCase
// create a standard session
try
{
- _queueConnection = _queueFactory.createQueueConnection();
+ _queueConnection = _queueFactory.createQueueConnection("guest", "guest");
_nonXASession = _queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
}
catch (JMSException e)
{
+ e.printStackTrace();
fail("cannot create queue session: " + e.getMessage());
}
init(session, _queue);
@@ -638,7 +639,8 @@ public class QueueTest extends AbstractXATestCase
TextMessage message1 = (TextMessage) nonXAConsumer.receive(1000);
if (message1 != null)
{
- fail("The queue is not empty! ");
+
+ fail("The queue is not empty! " + message1.getLongProperty(_sequenceNumberPropertyName));
}
}
catch (JMSException e)
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java
index 3a6d573205..d955979ad6 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java
@@ -18,6 +18,7 @@
package org.apache.qpid.test.unit.xa;
import junit.framework.TestSuite;
+import org.apache.qpid.configuration.ClientProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -25,6 +26,8 @@ import javax.jms.*;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -103,7 +106,7 @@ public class TopicTest extends AbstractXATestCase
}
catch (Exception e)
{
- fail("Exception thrown when cleaning standard connection: " + e.getStackTrace());
+ fail("Exception thrown when cleaning standard connection: " + e);
}
}
super.tearDown();
@@ -116,6 +119,7 @@ public class TopicTest extends AbstractXATestCase
{
if (!isBroker08())
{
+ setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, "1");
// lookup test queue
try
{
@@ -650,7 +654,12 @@ public class TopicTest extends AbstractXATestCase
{
message = (TextMessage) xaDurSub.receive(1000);
- _logger.debug(" received message: " + message.getLongProperty(_sequenceNumberPropertyName));
+
+ if(message != null)
+ {
+ _logger.debug(" received message: " + message.getLongProperty(_sequenceNumberPropertyName));
+ }
+
if (message == null)
{
fail("no message received! expected: " + i);
@@ -882,35 +891,40 @@ public class TopicTest extends AbstractXATestCase
// receive 3 message within tx1: 3, 4 and 7
_xaResource.start(xid1, XAResource.TMRESUME);
// receive messages 3, 4 and 7
+ Set<Long> expected = new HashSet<Long>();
+ expected.add(3L);
+ expected.add(4L);
+ expected.add(7L);
message = (TextMessage) xaDurSub.receive(1000);
if (message == null)
{
- fail("no message received! expected: " + 3);
+ fail("no message received! expected one of: " + expected);
}
- else if (message.getLongProperty(_sequenceNumberPropertyName) != 3)
+ else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
{
fail("wrong sequence number: " + message
- .getLongProperty(_sequenceNumberPropertyName) + " 3 was expected");
+ .getLongProperty(_sequenceNumberPropertyName) + " expected one from " + expected);
}
message = (TextMessage) xaDurSub.receive(1000);
if (message == null)
{
- fail("no message received! expected: " + 4);
+ fail("no message received! expected one of: " + expected);
}
- else if (message.getLongProperty(_sequenceNumberPropertyName) != 4)
+ else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
{
+
fail("wrong sequence number: " + message
- .getLongProperty(_sequenceNumberPropertyName) + " 4 was expected");
+ .getLongProperty(_sequenceNumberPropertyName) + " expected one from " + expected);
}
message = (TextMessage) xaDurSub.receive(1000);
if (message == null)
{
- fail("no message received! expected: " + 7);
+ fail("no message received! expected one of: " + expected);
}
- else if (message.getLongProperty(_sequenceNumberPropertyName) != 7)
+ else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
{
fail("wrong sequence number: " + message
- .getLongProperty(_sequenceNumberPropertyName) + " 7 was expected");
+ .getLongProperty(_sequenceNumberPropertyName) + " expected one from " + expected);
}
}
catch (Exception e)
@@ -936,8 +950,18 @@ public class TopicTest extends AbstractXATestCase
try
{
- // consume messages 1 - 4
- //----- start xid1
+ // consume messages: could be any from (1 - 4, 7-10)
+ //----- start xid4
+ Set<Long> expected = new HashSet<Long>();
+ Set<Long> xid4msgs = new HashSet<Long>();
+ for(long l = 1; l <= 4l; l++)
+ {
+ expected.add(l);
+ }
+ for(long l = 7; l <= 10l; l++)
+ {
+ expected.add(l);
+ }
_xaResource.start(xid4, XAResource.TMNOFLAGS);
for (int i = 1; i <= 4; i++)
{
@@ -946,9 +970,14 @@ public class TopicTest extends AbstractXATestCase
{
fail("no message received! expected: " + i);
}
- else if (message.getLongProperty(_sequenceNumberPropertyName) != i)
+
+ long seqNo = message.getLongProperty(_sequenceNumberPropertyName);
+ xid4msgs.add(seqNo);
+
+ if (!expected.remove(seqNo))
{
- fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName));
+ fail("wrong sequence number: " + seqNo +
+ " expected one from " + expected);
}
}
_xaResource.end(xid4, XAResource.TMSUSPEND);
@@ -961,15 +990,17 @@ public class TopicTest extends AbstractXATestCase
{
fail("no message received! expected: " + i);
}
- else if (message.getLongProperty(_sequenceNumberPropertyName) != i)
+ else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
{
- fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName));
+ fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName)
+ + " expected one from " + expected);
}
}
_xaResource.end(xid5, XAResource.TMSUSPEND);
// abort tx4
_xaResource.prepare(xid4);
_xaResource.rollback(xid4);
+ expected.addAll(xid4msgs);
// consume messages 1-4 with tx5
_xaResource.start(xid5, XAResource.TMRESUME);
for (int i = 1; i <= 4; i++)
@@ -979,13 +1010,15 @@ public class TopicTest extends AbstractXATestCase
{
fail("no message received! expected: " + i);
}
- else if (message.getLongProperty(_sequenceNumberPropertyName) != i)
+ else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
{
- fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName));
+ fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName)
+ + " expected one from " + expected);
}
}
_xaResource.end(xid5, XAResource.TMSUSPEND);
// commit tx5
+
_xaResource.prepare(xid5);
_xaResource.commit(xid5, false);
}
@@ -1602,6 +1635,7 @@ public class TopicTest extends AbstractXATestCase
}
_xaResource.end(xid2, XAResource.TMSUCCESS);
_xaResource.commit(xid2, true);
+ _session.close();
}
catch (Exception e)
{
diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java b/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java
index 2b7c3f2664..d9c259c389 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java
@@ -329,7 +329,11 @@ public class JMXTestUtils
public boolean isManagedObjectExist(String query)
{
return !queryObjects(query).isEmpty();
+ }
+ public int getNumberOfObjects(String query)
+ {
+ return queryObjects(query).size();
}
public <T> T getManagedObject(Class<T> managedClass, ObjectName objectName)
@@ -430,8 +434,7 @@ public class JMXTestUtils
}
/**
- * Returns the Set of ObjectNames returned by the broker for the given query,
- * or null if there is problem while performing the query.
+ * Returns the Set of ObjectNames returned by the broker for the given query.
*/
private Set<ObjectName> queryObjects(String query)
{
@@ -441,8 +444,7 @@ public class JMXTestUtils
}
catch (Exception e)
{
- e.printStackTrace();
- return null;
+ throw new RuntimeException("Error using query: " + query, e);
}
}
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 32c6094adb..c070fb4de0 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
@@ -35,7 +35,8 @@ import org.apache.qpid.server.BrokerOptions;
import org.apache.qpid.server.ProtocolExclusion;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.protocol.AmqpProtocolVersion;
-import org.apache.qpid.server.store.DerbyMessageStore;
+import org.apache.qpid.server.store.MessageStoreConstants;
+import org.apache.qpid.server.store.derby.DerbyMessageStoreFactory;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.util.FileUtils;
import org.apache.qpid.util.LogMonitor;
@@ -63,9 +64,12 @@ import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
@@ -195,6 +199,7 @@ public class QpidBrokerTestCase extends QpidTestCase
return QpidBrokerTestCase._logger;
}
+ @Override
public void runBare() throws Throwable
{
String qname = getClass().getName() + "." + getName();
@@ -243,14 +248,7 @@ public class QpidBrokerTestCase extends QpidTestCase
}
finally
{
- try
- {
- stopBroker();
- }
- catch (Exception e)
- {
- _logger.error("exception stopping broker", e);
- }
+ stopAllBrokers();
// reset properties used in the test
revertSystemProperties();
@@ -634,12 +632,21 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
- public void stopBroker() throws Exception
+ public void stopBroker()
{
stopBroker(0);
}
- public void stopBroker(int port) throws Exception
+ public void stopAllBrokers()
+ {
+ Set<Integer> runningBrokerPorts = new HashSet<Integer>(getBrokerPortNumbers());
+ for (int brokerPortNumber : runningBrokerPorts)
+ {
+ stopBroker(brokerPortNumber);
+ }
+ }
+
+ public void stopBroker(int port)
{
if (isBrokerPresent(port))
{
@@ -651,12 +658,12 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
- public void killBroker() throws Exception
+ public void killBroker()
{
killBroker(0);
}
- public void killBroker(int port) throws Exception
+ public void killBroker(int port)
{
if (isBrokerPresent(port))
{
@@ -668,7 +675,7 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
- public boolean isBrokerPresent(int port) throws Exception
+ public boolean isBrokerPresent(int port)
{
port = getPort(port);
@@ -681,6 +688,11 @@ public class QpidBrokerTestCase extends QpidTestCase
return _brokers.get(port);
}
+ public Set<Integer> getBrokerPortNumbers()
+ {
+ return new HashSet<Integer>(_brokers.keySet());
+ }
+
/**
* Attempt to set the Java Broker to use the BDBMessageStore for persistence
* Falling back to the DerbyMessageStore if
@@ -693,22 +705,22 @@ public class QpidBrokerTestCase extends QpidTestCase
protected void makeVirtualHostPersistent(String virtualhost)
throws ConfigurationException, IOException
{
- Class<?> storeClass = null;
+ Class<?> storeFactoryClass = null;
try
{
// Try and lookup the BDB class
- storeClass = Class.forName("org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
+ storeFactoryClass = Class.forName("org.apache.qpid.server.store.berkeleydb.BDBMessageStoreFactory");
}
catch (ClassNotFoundException e)
{
// No BDB store, we'll use Derby instead.
- storeClass = DerbyMessageStore.class;
+ storeFactoryClass = DerbyMessageStoreFactory.class;
}
- setConfigurationProperty("virtualhosts.virtualhost." + virtualhost + ".store.class",
- storeClass.getName());
- setConfigurationProperty("virtualhosts.virtualhost." + virtualhost + ".store." + DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY,
+ setConfigurationProperty("virtualhosts.virtualhost." + virtualhost + ".store.factoryclass",
+ storeFactoryClass.getName());
+ setConfigurationProperty("virtualhosts.virtualhost." + virtualhost + ".store." + MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY,
"${QPID_WORK}/" + virtualhost);
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java b/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
index 50b1ea7cea..787fc164d5 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
@@ -114,7 +114,7 @@ public class SpawnedBrokerHolder implements BrokerHolder
}
catch (ReflectionUtilsException e)
{
- LOGGER.warn("Could not get pid for process, Broker process shutdown will be ungraceful");
+ LOGGER.warn("Could not get pid for process, Broker process shutdown will be graceful");
}
}
return null;