From 288f8767c3c22b5c30ade4f844d23f498824c415 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Fri, 7 Jul 2006 09:24:38 +0000 Subject: [PATCH] added activemq-jaas to the assembly to fix AMQ-801 git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@419850 13f79535-47bb-0310-9956-ffa450edef68 --- assembly/pom.xml | 2 +- .../usecases/ChangeSentMessageTest.java | 63 --- .../ChangeSessionDeliveryModeTest.java | 62 --- .../usecases/CompositeConsumeTest.java | 70 ---- .../usecases/CompositePublishTest.java | 142 ------- .../usecases/ConsumeQueuePrefetchTest.java | 42 -- .../usecases/ConsumeTopicPrefetchTest.java | 87 ---- .../CreateLotsOfTemporaryQueuesTest.java | 71 ---- .../CreateTemporaryQueueBeforeStartTest.java | 132 ------ .../DurableConsumerCloseAndReconnectTest.java | 172 -------- .../DurableSubscriptionTestSupport.java | 375 ------------------ .../usecases/ExceptionListenerTest.java | 91 ----- .../usecases/JDBCDurableSubscriptionTest.java | 38 -- .../JournalDurableSubscriptionTest.java | 38 -- .../MultiBrokersMultiClientsTest.java | 122 ------ .../MultiBrokersMultiClientsUsingTcpTest.java | 83 ---- .../usecases/ProducerConsumerTestSupport.java | 56 --- ...lishOnDurableTopicConsumedMessageTest.java | 28 -- ...QueueConsumedMessageInTransactionTest.java | 184 --------- .../PublishOnQueueConsumedMessageTest.java | 28 -- ...ueConsumedMessageUsingActivemqXMLTest.java | 113 ------ ...shOnTemporaryQueueConsumedMessageTest.java | 31 -- .../PublishOnTopicConsumedMessageTest.java | 65 --- ...icConsumerMessageUsingActivemqXMLTest.java | 115 ------ .../QueueConsumerCloseAndReconnectTest.java | 26 -- .../usecases/QueueDuplicatesTest.java | 160 -------- .../activemq/usecases/QueueRedeliverTest.java | 30 -- .../usecases/ReliableReconnectTest.java | 180 --------- .../usecases/StartAndStopBrokerTest.java | 78 ---- .../SubscribeClosePublishThenConsumeTest.java | 105 ----- .../apache/activemq/usecases/TestSupport.java | 149 ------- .../usecases/ThreeBrokerQueueNetworkTest.java | 196 --------- .../ThreeBrokerQueueNetworkUsingTcpTest.java | 66 --- .../ThreeBrokerTempQueueNetworkTest.java | 95 ----- .../usecases/ThreeBrokerTopicNetworkTest.java | 239 ----------- .../ThreeBrokerTopicNetworkUsingTcpTest.java | 66 --- .../activemq/usecases/TopicRedeliverTest.java | 223 ----------- .../TransactionRollbackOrderTest.java | 166 -------- .../activemq/usecases/TransactionTest.java | 123 ------ .../usecases/TransientQueueRedeliverTest.java | 33 -- ...sageNotSentToRemoteWhenNoConsumerTest.java | 151 ------- .../usecases/TwoBrokerMulticastQueueTest.java | 269 ------------- .../TwoBrokerQueueClientsReconnectTest.java | 365 ----------------- .../TwoBrokerQueueSendReceiveTest.java | 35 -- ...SendReceiveLotsOfMessagesUsingTcpTest.java | 30 -- .../TwoBrokerTopicSendReceiveTest.java | 78 ---- ...woBrokerTopicSendReceiveUsingHttpTest.java | 43 -- ...SendReceiveUsingJavaConfigurationTest.java | 75 ---- ...TwoBrokerTopicSendReceiveUsingTcpTest.java | 84 ---- ...stDiscoveryBrokerTopicSendReceiveTest.java | 35 -- assembly/src/test/resources/client.keystore | Bin 646 -> 0 bytes .../org/apache/activemq/config/config.xml | 25 -- .../org/apache/activemq/config/example.xml | 115 ------ .../apache/activemq/config/spring-test.xml | 34 -- .../org/apache/activemq/usecases/activemq.xml | 103 ----- .../activemq/usecases/multicast-broker-1.xml | 33 -- .../activemq/usecases/multicast-broker-2.xml | 33 -- .../usecases/multicast-broker-auto.xml | 33 -- .../usecases/receiver-activecluster.xml | 36 -- .../activemq/usecases/receiver-discovery.xml | 35 -- .../activemq/usecases/receiver-http.xml | 33 -- .../activemq/usecases/receiver-zeroconf.xml | 36 -- .../org/apache/activemq/usecases/receiver.xml | 33 -- .../usecases/sender-activecluster.xml | 36 -- .../activemq/usecases/sender-discovery.xml | 33 -- .../apache/activemq/usecases/sender-http.xml | 33 -- .../activemq/usecases/sender-zeroconf.xml | 36 -- .../org/apache/activemq/usecases/sender.xml | 33 -- assembly/src/test/resources/server.keystore | Bin 1352 -> 0 bytes 69 files changed, 1 insertion(+), 6029 deletions(-) delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/CompositeConsumeTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/CompositePublishTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/ConsumeQueuePrefetchTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/ConsumeTopicPrefetchTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/CreateTemporaryQueueBeforeStartTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/JDBCDurableSubscriptionTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/JournalDurableSubscriptionTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/ProducerConsumerTestSupport.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/PublishOnDurableTopicConsumedMessageTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageInTransactionTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageUsingActivemqXMLTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/PublishOnTemporaryQueueConsumedMessageTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumedMessageTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumerMessageUsingActivemqXMLTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/QueueConsumerCloseAndReconnectTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/QueueRedeliverTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/StartAndStopBrokerTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/SubscribeClosePublishThenConsumeTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/TestSupport.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TransactionRollbackOrderTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/TransactionTest.java delete mode 100755 assembly/src/test/java/org/apache/activemq/usecases/TransientQueueRedeliverTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerMulticastQueueTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueSendReceiveTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveLotsOfMessagesUsingTcpTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingHttpTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingJavaConfigurationTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java delete mode 100644 assembly/src/test/java/org/apache/activemq/usecases/TwoMulticastDiscoveryBrokerTopicSendReceiveTest.java delete mode 100644 assembly/src/test/resources/client.keystore delete mode 100755 assembly/src/test/resources/org/apache/activemq/config/config.xml delete mode 100755 assembly/src/test/resources/org/apache/activemq/config/example.xml delete mode 100755 assembly/src/test/resources/org/apache/activemq/config/spring-test.xml delete mode 100644 assembly/src/test/resources/org/apache/activemq/usecases/activemq.xml delete mode 100644 assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-1.xml delete mode 100644 assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-2.xml delete mode 100644 assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-auto.xml delete mode 100755 assembly/src/test/resources/org/apache/activemq/usecases/receiver-activecluster.xml delete mode 100644 assembly/src/test/resources/org/apache/activemq/usecases/receiver-discovery.xml delete mode 100644 assembly/src/test/resources/org/apache/activemq/usecases/receiver-http.xml delete mode 100755 assembly/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml delete mode 100755 assembly/src/test/resources/org/apache/activemq/usecases/receiver.xml delete mode 100755 assembly/src/test/resources/org/apache/activemq/usecases/sender-activecluster.xml delete mode 100644 assembly/src/test/resources/org/apache/activemq/usecases/sender-discovery.xml delete mode 100644 assembly/src/test/resources/org/apache/activemq/usecases/sender-http.xml delete mode 100755 assembly/src/test/resources/org/apache/activemq/usecases/sender-zeroconf.xml delete mode 100755 assembly/src/test/resources/org/apache/activemq/usecases/sender.xml delete mode 100644 assembly/src/test/resources/server.keystore diff --git a/assembly/pom.xml b/assembly/pom.xml index 40b5d883b9..ed675c7a7c 100755 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -282,7 +282,7 @@ createbundle - activemq-core,activemq-console,activeio-core,activemq-optional,backport-util-concurrent,commons-logging,geronimo-jms_1.1_spec,geronimo-j2ee-management_1.0_spec,derby + activemq-core,activemq-console,activeio-core,activemq-jaas,activemq-optional,backport-util-concurrent,commons-logging,geronimo-jms_1.1_spec,geronimo-j2ee-management_1.0_spec,derby diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.java deleted file mode 100755 index be043949bb..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; -import java.util.HashMap; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Session; - -import org.apache.activemq.test.TestSupport; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ChangeSentMessageTest extends TestSupport { - private static final int COUNT = 200; - private static final String VALUE_NAME = "value"; - - /** - * test Object messages can be changed after sending with no side-affects - * @throws Exception - */ - public void testDoChangeSentMessage() throws Exception { - Destination destination = createDestination("test-"+ChangeSentMessageTest.class.getName()); - Connection connection = createConnection(); - connection.start(); - Session consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer consumer = consumerSession.createConsumer(destination); - Session publisherSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = publisherSession.createProducer(destination); - HashMap map = new HashMap(); - ObjectMessage message = publisherSession.createObjectMessage(); - for (int i = 0;i < COUNT;i++) { - map.put(VALUE_NAME, new Integer(i)); - message.setObject(map); - producer.send(message); - assertTrue(message.getObject()==map); - } - for (int i = 0;i < COUNT;i++) { - ObjectMessage msg = (ObjectMessage) consumer.receive(); - HashMap receivedMap = (HashMap) msg.getObject(); - Integer intValue = (Integer) receivedMap.get(VALUE_NAME); - assertTrue(intValue.intValue() == i); - } - } -} \ No newline at end of file diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.java deleted file mode 100755 index b956264a77..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.IllegalStateException; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.Session; - -import org.apache.activemq.test.TestSupport; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ChangeSessionDeliveryModeTest extends TestSupport implements MessageListener { - - /** - * test following condition- which are defined by JMS Spec 1.1: MessageConsumers cannot use a MessageListener and - * receive() from the same session - * - * @throws Exception - */ - public void testDoChangeSessionDeliveryMode() throws Exception { - Destination destination = createDestination("foo.bar"); - Connection connection = createConnection(); - connection.start(); - Session consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer consumer1 = consumerSession.createConsumer(destination); - consumer1.setMessageListener(this); - JMSException jmsEx = null; - MessageConsumer consumer2 = consumerSession.createConsumer(destination); - - try { - consumer2.receive(10); - fail("Did not receive expected exception."); - } - catch (JMSException e) { - assertTrue(e instanceof IllegalStateException); - } - } - - public void onMessage(Message msg) { - } -} \ No newline at end of file diff --git a/assembly/src/test/java/org/apache/activemq/usecases/CompositeConsumeTest.java b/assembly/src/test/java/org/apache/activemq/usecases/CompositeConsumeTest.java deleted file mode 100755 index fdb824ad61..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/CompositeConsumeTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.command.ActiveMQTopic; -import org.apache.activemq.test.JmsTopicSendReceiveWithTwoConnectionsTest; - -import javax.jms.Destination; -import javax.jms.Message; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class CompositeConsumeTest extends JmsTopicSendReceiveWithTwoConnectionsTest { - - public void testSendReceive() throws Exception { - messages.clear(); - - Destination[] destinations = getDestinations(); - int destIdx = 0; - - for (int i = 0; i < data.length; i++) { - Message message = session.createTextMessage(data[i]); - - if (verbose) { - log.info("About to send a message: " + message + " with text: " + data[i]); - } - - producer.send(destinations[destIdx], message); - - if (++destIdx >= destinations.length) { - destIdx = 0; - } - } - - assertMessagesAreReceived(); - } - - /** - * Returns the subscription subject - */ - protected String getSubject() { - return getPrefix() + "FOO.BAR," + getPrefix() + "FOO.X.Y," + getPrefix() + "BAR.>"; - } - - /** - * Returns the destinations on which we publish - */ - protected Destination[] getDestinations() { - return new Destination[]{new ActiveMQTopic(getPrefix() + "FOO.BAR"), new ActiveMQTopic(getPrefix() + "BAR.WHATNOT.XYZ"), new ActiveMQTopic(getPrefix() + "FOO.X.Y")}; - } - - protected String getPrefix() { - return super.getSubject() + "."; - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/CompositePublishTest.java b/assembly/src/test/java/org/apache/activemq/usecases/CompositePublishTest.java deleted file mode 100755 index 55b1a00853..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/CompositePublishTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQTopic; -import org.apache.activemq.test.JmsSendReceiveTestSupport; - -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 java.util.List; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class CompositePublishTest extends JmsSendReceiveTestSupport { - - protected Connection sendConnection; - protected Connection receiveConnection; - protected Session receiveSession; - protected MessageConsumer[] consumers; - protected List[] messageLists; - - protected void setUp() throws Exception { - super.setUp(); - - connectionFactory = createConnectionFactory(); - - sendConnection = createConnection(); - sendConnection.start(); - - receiveConnection = createConnection(); - receiveConnection.start(); - - log.info("Created sendConnection: " + sendConnection); - log.info("Created receiveConnection: " + receiveConnection); - - session = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - receiveSession = receiveConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - log.info("Created sendSession: " + session); - log.info("Created receiveSession: " + receiveSession); - - producer = session.createProducer(null); - - log.info("Created producer: " + producer); - - if (topic) { - consumerDestination = session.createTopic(getConsumerSubject()); - producerDestination = session.createTopic(getProducerSubject()); - } - else { - consumerDestination = session.createQueue(getConsumerSubject()); - producerDestination = session.createQueue(getProducerSubject()); - } - - log.info("Created consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass()); - log.info("Created producer destination: " + producerDestination + " of type: " + producerDestination.getClass()); - - Destination[] destinations = getDestinations(); - consumers = new MessageConsumer[destinations.length]; - messageLists = new List[destinations.length]; - for (int i = 0; i < destinations.length; i++) { - Destination dest = destinations[i]; - messageLists[i] = createConcurrentList(); - consumers[i] = receiveSession.createConsumer(dest); - consumers[i].setMessageListener(createMessageListener(i, messageLists[i])); - } - - - log.info("Started connections"); - } - - protected MessageListener createMessageListener(int i, final List messageList) { - return new MessageListener() { - public void onMessage(Message message) { - consumeMessage(message, messageList); - } - }; - } - - /** - * Returns the subject on which we publish - */ - protected String getSubject() { - return getPrefix() + "FOO.BAR," + getPrefix() + "FOO.X.Y"; - } - - /** - * Returns the destinations to which we consume - */ - protected Destination[] getDestinations() { - return new Destination[]{new ActiveMQTopic(getPrefix() + "FOO.BAR"), new ActiveMQTopic(getPrefix() + "FOO.*"), new ActiveMQTopic(getPrefix() + "FOO.X.Y")}; - } - - protected String getPrefix() { - return super.getSubject() + "."; - } - - protected void assertMessagesAreReceived() throws JMSException { - waitForMessagesToBeDelivered(); - - for (int i = 0, size = messageLists.length; i < size; i++) { - log.info("Message list: " + i + " contains: " + messageLists[i].size() + " message(s)"); - } - - for (int i = 0, size = messageLists.length; i < size; i++) { - assertMessagesReceivedAreValid(messageLists[i]); - } - } - - protected ActiveMQConnectionFactory createConnectionFactory() { - return new ActiveMQConnectionFactory("vm://localhost"); - } - - protected void tearDown() throws Exception { - session.close(); - receiveSession.close(); - - sendConnection.close(); - receiveConnection.close(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ConsumeQueuePrefetchTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ConsumeQueuePrefetchTest.java deleted file mode 100755 index ee620c464a..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ConsumeQueuePrefetchTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import javax.jms.JMSException; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ConsumeQueuePrefetchTest extends ConsumeTopicPrefetchTest { - - /** - * TODO disabled failing test cases until we fix queue dispatching - */ - public void testSendDoublePrefetchSize() throws JMSException { - } - - /** - * TODO disabled failing test cases until we fix queue dispatching - */ - public void testSendPrefetchSizePlusOne() throws JMSException { - } - - protected void setUp() throws Exception { - topic = false; - super.setUp(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ConsumeTopicPrefetchTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ConsumeTopicPrefetchTest.java deleted file mode 100755 index 56df0307a6..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ConsumeTopicPrefetchTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.TextMessage; - -import org.apache.activemq.ActiveMQConnection; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ConsumeTopicPrefetchTest extends ProducerConsumerTestSupport { - - protected int prefetchSize = 100; - protected String[] messageTexts; - protected long consumerTimeout = 10000L; - - public void testSendPrefetchSize() throws JMSException { - testWithMessageCount(prefetchSize); - } - - public void testSendDoublePrefetchSize() throws JMSException { - testWithMessageCount(prefetchSize * 2); - } - - public void testSendPrefetchSizePlusOne() throws JMSException { - testWithMessageCount(prefetchSize + 1); - } - - protected void testWithMessageCount(int messageCount) throws JMSException { - makeMessages(messageCount); - - log.info("About to send and receive: " + messageCount + " on destination: " + destination - + " of type: " + destination.getClass().getName()); - - for (int i = 0; i < messageCount; i++) { - Message message = session.createTextMessage(messageTexts[i]); - producer.send(message); - } - - // lets consume them in two fetch batches - for (int i = 0; i < messageCount; i++) { - consumeMessge(i); - } - } - - protected Connection createConnection() throws Exception { - ActiveMQConnection connection = (ActiveMQConnection) super.createConnection(); - connection.getPrefetchPolicy().setQueuePrefetch(prefetchSize); - connection.getPrefetchPolicy().setTopicPrefetch(prefetchSize); - return connection; - } - - protected void consumeMessge(int i) throws JMSException { - Message message = consumer.receive(consumerTimeout); - assertTrue("Should have received a message by now for message: " + i, message != null); - assertTrue("Should be a TextMessage: " + message, message instanceof TextMessage); - TextMessage textMessage = (TextMessage) message; - assertEquals("Message content", messageTexts[i], textMessage.getText()); - } - - - protected void makeMessages(int messageCount) { - messageTexts = new String[messageCount]; - for (int i = 0; i < messageCount; i++) { - messageTexts[i] = "Message for test: + " + getName() + " = " + i; - } - } - -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java b/assembly/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java deleted file mode 100644 index b6f94353fc..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.EmbeddedBrokerTestSupport; - -import javax.jms.Connection; -import javax.jms.Session; -import javax.jms.TemporaryQueue; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -/** - * - * @version $Revision: 1.1 $ - */ -public class CreateLotsOfTemporaryQueuesTest extends EmbeddedBrokerTestSupport { - - private static int numberToCreate = 500; - private static long sleep = 20; - - - public static void main(String[] args) { - configure(args); - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(CreateLotsOfTemporaryQueuesTest.class); - } - - public void testCreateLotsOfTemporaryQueues() throws Exception { - log.info("Creating " + numberToCreate + " temporary queue(s)"); - - Connection connection = createConnection(); - connection.start(); - Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); - for (int i = 0; i < numberToCreate; i++) { - if (i % 1000 == 0) { - log.info("attempt " + i); - } - TemporaryQueue temporaryQueue = session.createTemporaryQueue(); - temporaryQueue.delete(); - Thread.sleep(sleep ); - } - log.info("Created " + numberToCreate + " temporary queue(s)"); - connection.close(); - } - - public static void configure(String[] args) { - if (args.length > 0) { - numberToCreate = Integer.parseInt(args[0]); - } - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/CreateTemporaryQueueBeforeStartTest.java b/assembly/src/test/java/org/apache/activemq/usecases/CreateTemporaryQueueBeforeStartTest.java deleted file mode 100755 index 086fdb321f..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/CreateTemporaryQueueBeforeStartTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; -import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; - -import javax.jms.Connection; -import javax.jms.Queue; -import javax.jms.QueueConnection; -import javax.jms.QueueReceiver; -import javax.jms.QueueSender; -import javax.jms.QueueSession; -import javax.jms.Session; -import javax.jms.Topic; - -import junit.framework.TestCase; - -/** - * @author Peter Henning - * @version $Revision: 1.1.1.1 $ - */ -public class CreateTemporaryQueueBeforeStartTest extends TestCase { - protected String bindAddress = "tcp://localhost:61621"; - private Connection connection; - private BrokerService broker = new BrokerService(); - - public void testCreateTemporaryQueue() throws Exception { - connection = createConnection(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Queue queue = session.createTemporaryQueue(); - assertTrue("No queue created!", queue != null); - Topic topic = session.createTemporaryTopic(); - assertTrue("No topic created!", topic != null); - } - - public void testTryToReproduceNullPointerBug() throws Exception { - String url = bindAddress; - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url); - QueueConnection queueConnection = factory.createQueueConnection(); - this.connection = queueConnection; - QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - QueueSender sender = session.createSender(null); //Unidentified - Queue receiverQueue = session.createTemporaryQueue(); - QueueReceiver receiver = session.createReceiver(receiverQueue); - queueConnection.start(); - } - - public void testTemporaryQueueConsumer() throws Exception { - final int NUMBER = 20; - final AtomicInteger count = new AtomicInteger(0); - for (int i = 0;i < NUMBER;i++) { - Thread thread = new Thread(new Runnable() { - public void run() { - try { - QueueConnection connection = createConnection(); - QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - Queue queue = session.createTemporaryQueue(); - QueueReceiver consumer = session.createReceiver(queue); - connection.start(); - - - if (count.incrementAndGet() >= NUMBER){ - synchronized(count){ - count.notify(); - } - } - } - catch (Exception ex) { - ex.printStackTrace(); - } - } - }); - thread.start(); - } - int maxWaitTime = 20000; - synchronized (count) { - long waitTime = maxWaitTime; - long start = System.currentTimeMillis(); - while (count.get() < NUMBER) { - if (waitTime <= 0) { - break; - } - else { - count.wait(waitTime); - waitTime = maxWaitTime - (System.currentTimeMillis() - start); - } - } - } - assertTrue("Unexpected count: " + count, count.get() == NUMBER); - } - - protected QueueConnection createConnection() throws Exception { - ActiveMQConnectionFactory factory = createConnectionFactory(); - return factory.createQueueConnection(); - } - - protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { - return new ActiveMQConnectionFactory(bindAddress); - } - - protected void setUp() throws Exception { - broker.setPersistent(false); - broker.addConnector(bindAddress); - broker.start(); - super.setUp(); - } - - protected void tearDown() throws Exception { - if (connection != null) { - connection.close(); - } - broker.stop(); - super.tearDown(); - } -} \ No newline at end of file diff --git a/assembly/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTest.java b/assembly/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTest.java deleted file mode 100755 index aa9cbdc6a5..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTest.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.test.TestSupport; - -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.Topic; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class DurableConsumerCloseAndReconnectTest extends TestSupport { - protected static final long RECEIVE_TIMEOUT = 5000L; - - private Connection connection; - private Session session; - private MessageConsumer consumer; - private MessageProducer producer; - private Destination destination; - - protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { - return new ActiveMQConnectionFactory("vm://localhost?broker.persistent=true"); - } - - public void testCreateDurableConsumerCloseThenReconnect() throws Exception { - // force the server to stay up across both connection tests - Connection dummyConnection = createConnection(); - - consumeMessagesDeliveredWhileConsumerClosed(); - - dummyConnection.close(); - - // now lets try again without one connection open - consumeMessagesDeliveredWhileConsumerClosed(); - } - - protected void consumeMessagesDeliveredWhileConsumerClosed() throws Exception { - makeConsumer(); - closeConsumer(); - - publish(); - - // wait a few moments for the close to really occur - Thread.sleep(1000); - - makeConsumer(); - - Message message = consumer.receive(RECEIVE_TIMEOUT); - assertTrue("Should have received a message!", message != null); - - closeConsumer(); - - log.info("Now lets create the consumer again and because we didn't ack, we should get it again"); - makeConsumer(); - - message = consumer.receive(RECEIVE_TIMEOUT); - assertTrue("Should have received a message!", message != null); - message.acknowledge(); - - closeConsumer(); - - log.info("Now lets create the consumer again and because we didn't ack, we should get it again"); - makeConsumer(); - - message = consumer.receive(2000); - assertTrue("Should have no more messages left!", message == null); - - closeConsumer(); - - log.info("Lets publish one more message now"); - publish(); - - makeConsumer(); - message = consumer.receive(RECEIVE_TIMEOUT); - assertTrue("Should have received a message!", message != null); - message.acknowledge(); - - closeConsumer(); - } - - protected void publish() throws Exception { - connection = createConnection(); - connection.start(); - - session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - destination = createDestination(); - - producer = session.createProducer(destination); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - - producer.send(session.createTextMessage("This is a test")); - - producer.close(); - producer = null; - closeSession(); - } - - protected Destination createDestination() throws JMSException { - if (isTopic()) { - return session.createTopic(getSubject()); - } - else { - return session.createQueue(getSubject()); - } - } - - protected boolean isTopic() { - return true; - } - - protected void closeConsumer() throws JMSException { - consumer.close(); - consumer = null; - closeSession(); - } - - protected void closeSession() throws JMSException { - session.close(); - session = null; - connection.close(); - connection = null; - } - - protected void makeConsumer() throws Exception { - String durableName = getName(); - String clientID = getSubject(); - log.info("Creating a durable subscribe for clientID: " + clientID + " and durable name: " + durableName); - createSession(clientID); - consumer = createConsumer(durableName); - } - - private MessageConsumer createConsumer(String durableName) throws JMSException { - if (destination instanceof Topic) { - return session.createDurableSubscriber((Topic) destination, durableName); - } - else { - return session.createConsumer(destination); - } - } - - protected void createSession(String clientID) throws Exception { - connection = createConnection(); - connection.setClientID(clientID); - connection.start(); - - session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - destination = createDestination(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java b/assembly/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java deleted file mode 100755 index 14364e71a1..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java +++ /dev/null @@ -1,375 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.jms.TopicSubscriber; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.TestSupport; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.store.PersistenceAdapter; - -/** - * @version $Revision: 1.1.1.1 $ - */ -abstract public class DurableSubscriptionTestSupport extends TestSupport { - - private Connection connection; - private Session session; - private TopicSubscriber consumer; - private MessageProducer producer; - private BrokerService broker; - - protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { - return new ActiveMQConnectionFactory("vm://durable-broker"); - } - - protected Connection createConnection() throws Exception { - Connection rc = super.createConnection(); - rc.setClientID(getName()); - return rc; - } - - protected void setUp() throws Exception { - createBroker(); - super.setUp(); - } - protected void tearDown() throws Exception { - super.tearDown(); - destroyBroker(); - } - protected void restartBroker() throws Exception { - destroyBroker(); - createRestartedBroker(); // retain stored messages - } - private void createBroker() throws Exception { - try { - broker = new BrokerService(); - broker.setBrokerName("durable-broker"); - broker.setDeleteAllMessagesOnStartup(true); - broker.setPersistenceAdapter(createPersistenceAdapter()); - broker.setPersistent(true); - broker.start(); - } catch (Exception e) { - e.printStackTrace(); - } - - connection = createConnection(); - } - - private void createRestartedBroker() throws Exception { - try { - broker = new BrokerService(); - broker.setBrokerName("durable-broker"); - broker.setDeleteAllMessagesOnStartup(false); - broker.setPersistenceAdapter(createPersistenceAdapter()); - broker.setPersistent(true); - broker.start(); - - } catch (Exception e) { - e.printStackTrace(); - } - - connection = createConnection(); - } - private void destroyBroker() throws Exception { - if( connection != null ) - connection.close(); - if( broker!=null ) - broker.stop(); - } - - abstract protected PersistenceAdapter createPersistenceAdapter() throws Exception; - - - public void testUnsubscribeSubscription() throws Exception { - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - Topic topic = session.createTopic("TestTopic"); - consumer = session.createDurableSubscriber(topic, "sub1"); - producer = session.createProducer(topic); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - connection.start(); - - // Make sure it works when the durable sub is active. - producer.send(session.createTextMessage("Msg:1")); - assertTextMessageEquals("Msg:1", consumer.receive(5000)); - - // Deactivate the sub. - consumer.close(); - // Send a new message. - producer.send(session.createTextMessage("Msg:2")); - session.unsubscribe("sub1"); - - // Reopen the connection. - connection.close(); - connection = createConnection(); - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - producer = session.createProducer(topic); - connection.start(); - - // Activate the sub. - consumer = session.createDurableSubscriber(topic, "sub1"); - producer.send(session.createTextMessage("Msg:3")); - - // Try to get the message. - assertTextMessageEquals("Msg:3", consumer.receive(5000)); - } - - public void testInactiveDurableSubscriptionTwoConnections() throws Exception { - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - Topic topic = session.createTopic("TestTopic"); - consumer = session.createDurableSubscriber(topic, "sub1"); - producer = session.createProducer(topic); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - connection.start(); - - // Make sure it works when the durable sub is active. - producer.send(session.createTextMessage("Msg:1")); - assertTextMessageEquals("Msg:1", consumer.receive(5000)); - - // Deactivate the sub. - consumer.close(); - - // Send a new message. - producer.send(session.createTextMessage("Msg:2")); - - // Reopen the connection. - connection.close(); - connection = createConnection(); - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - connection.start(); - - // Activate the sub. - consumer = session.createDurableSubscriber(topic, "sub1"); - - // Try to get the message. - assertTextMessageEquals("Msg:2", consumer.receive(5000)); - } - - public void testInactiveDurableSubscriptionBrokerRestart() throws Exception { - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - Topic topic = session.createTopic("TestTopic"); - consumer = session.createDurableSubscriber(topic, "sub1"); - producer = session.createProducer(topic); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - connection.start(); - - // Make sure it works when the durable sub is active. - producer.send(session.createTextMessage("Msg:1")); - assertTextMessageEquals("Msg:1", consumer.receive(5000)); - - // Deactivate the sub. - consumer.close(); - - // Send a new message. - producer.send(session.createTextMessage("Msg:2")); - - // Reopen the connection. - restartBroker(); - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - connection.start(); - - // Activate the sub. - consumer = session.createDurableSubscriber(topic, "sub1"); - - // Try to get the message. - assertTextMessageEquals("Msg:2", consumer.receive(5000)); - assertNull(consumer.receive(5000)); - } - - public void testDurableSubscriptionPersistsPastBrokerRestart() throws Exception { - - // Create the durable sub. - connection.start(); - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - - // Ensure that consumer will receive messages sent before it was created - Topic topic = session.createTopic("TestTopic?consumer.retroactive=true"); - consumer = session.createDurableSubscriber(topic, "sub1"); - - // Restart the broker. - restartBroker(); - - // Reconnection - connection.start(); - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - producer = session.createProducer(topic); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - - // Make sure it works when the durable sub is active. - producer.send(session.createTextMessage("Msg:1")); - - // Activate the sub. - consumer = session.createDurableSubscriber(topic, "sub1"); - - // Send a new message. - producer.send(session.createTextMessage("Msg:2")); - - - // Try to get the message. - assertTextMessageEquals("Msg:1", consumer.receive(5000)); - assertTextMessageEquals("Msg:2", consumer.receive(5000)); - - assertNull(consumer.receive(5000)); - } - - public void testInactiveDurableSubscriptionOneConnection() throws Exception { - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - Topic topic = session.createTopic("TestTopic"); - consumer = session.createDurableSubscriber(topic, "sub1"); - producer = session.createProducer(topic); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - connection.start(); - - // Make sure it works when the durable sub is active. - producer.send(session.createTextMessage("Msg:1")); - assertTextMessageEquals("Msg:1", consumer.receive(5000)); - - // Deactivate the sub. - consumer.close(); - - // Send a new message. - producer.send(session.createTextMessage("Msg:2")); - - // Activate the sub. - consumer = session.createDurableSubscriber(topic, "sub1"); - - // Try to get the message. - assertTextMessageEquals("Msg:2", consumer.receive(5000)); - } - - public void xtestSelectorChange() throws Exception { - session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - Topic topic = session.createTopic("TestTopic"); - consumer = session.createDurableSubscriber(topic, "sub1", "color='red'", false); - producer = session.createProducer(topic); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - connection.start(); - - // Make sure it works when the durable sub is active. - TextMessage msg = session.createTextMessage(); - msg.setText("Msg:1"); - msg.setStringProperty("color", "blue"); - producer.send(msg); - msg.setText("Msg:2"); - msg.setStringProperty("color", "red"); - producer.send(msg); - - assertTextMessageEquals("Msg:2", consumer.receive(5000)); - - // Change the subscription - consumer.close(); - consumer = session.createDurableSubscriber(topic, "sub1", "color='blue'", false); - - // Send a new message. - msg.setText("Msg:3"); - msg.setStringProperty("color", "red"); - producer.send(msg); - msg.setText("Msg:4"); - msg.setStringProperty("color", "blue"); - producer.send(msg); - - // Try to get the message. - assertTextMessageEquals("Msg:4", consumer.receive(5000)); - } - - - public void testDurableSubWorksInNewSession() throws JMSException { - - // Create the consumer. - connection.start(); - Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - Topic topic = session.createTopic("topic-"+getName()); - MessageConsumer consumer = session.createDurableSubscriber(topic, "sub1"); - // Drain any messages that may allready be in the sub - while( consumer.receive(1000)!=null ) - ; - - // See if the durable sub works in a new session. - session.close(); - session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - // Send a Message that should be added to the durable sub. - MessageProducer producer = createProducer(session, topic); - producer.send(session.createTextMessage("Message 1")); - - // Activate the durable sub now. And receive the message. - consumer = session.createDurableSubscriber(topic, "sub1"); - Message msg = consumer.receive(1000); - assertNotNull(msg); - assertEquals( "Message 1", ((TextMessage)msg).getText() ); - - } - - - public void testDurableSubWorksInNewConnection() throws Exception { - - // Create the consumer. - connection.start(); - Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - Topic topic = session.createTopic("topic-"+getName()); - MessageConsumer consumer = session.createDurableSubscriber(topic, "sub1"); - // Drain any messages that may allready be in the sub - while( consumer.receive(1000)!=null ) - ; - - // See if the durable sub works in a new connection. - // The embeded broker shutsdown when his connections are closed. - // So we open the new connection before the old one is closed. - connection.close(); - connection = createConnection(); - connection.start(); - session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - // Send a Message that should be added to the durable sub. - MessageProducer producer = createProducer(session, topic); - producer.send(session.createTextMessage("Message 1")); - - // Activate the durable sub now. And receive the message. - consumer = session.createDurableSubscriber(topic, "sub1"); - Message msg = consumer.receive(1000); - assertNotNull(msg); - assertEquals( "Message 1", ((TextMessage)msg).getText() ); - - } - - private MessageProducer createProducer(Session session, Destination queue) throws JMSException { - MessageProducer producer = session.createProducer(queue); - producer.setDeliveryMode(getDeliveryMode()); - return producer; - } - - protected int getDeliveryMode() { - return DeliveryMode.PERSISTENT; - } - private void assertTextMessageEquals(String string, Message message) throws JMSException { - assertNotNull("Message was null", message); - assertTrue("Message is not a TextMessage", message instanceof TextMessage); - assertEquals(string, ((TextMessage)message).getText()); - } - -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java deleted file mode 100755 index 55578f2e28..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import javax.jms.ExceptionListener; -import javax.jms.JMSException; - -import junit.framework.TestCase; - -/** - * @author Oliver Belikan - * @version $Revision: 1.1.1.1 $ - */ -public class ExceptionListenerTest extends TestCase implements ExceptionListener { - boolean isException = false; - - - public ExceptionListenerTest(String arg) { - super(arg); - } - - - public void testOnException() throws Exception { - /* TODO not sure yet if this is a valid test - - System.setProperty("activemq.persistenceAdapter", - "org.apache.activemq.store.vm.VMPersistenceAdapter"); - // configuration of container and all protocolls - BrokerContainerImpl container = new - BrokerContainerImpl("DefaultBroker"); - BrokerConnectorImpl connector = new - BrokerConnectorImpl(container, - "vm://localhost", new DefaultWireFormat()); - container.start(); - - ActiveMQConnectionFactory factory = new - ActiveMQConnectionFactory("vm://localhost"); - factory.start(); - - Connection connection = factory.createConnection(); - connection.setExceptionListener(this); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = session.createTopic(getClass().getName()); - MessageProducer producer = session.createProducer(destination); - - try { - Thread.currentThread().sleep(1000); - } - catch (Exception e) { - } - - container.stop(); - - // now lets try send - try { - producer.send(session.createTextMessage("This will never get anywhere")); - } - catch (JMSException e) { - log.info("Caught: " + e); - } - - try { - Thread.currentThread().sleep(1000); - } - catch (Exception e) { - } - - assertTrue("Should have received an exception", isException); - */ - } - - - public void onException(JMSException e) { - isException = true; - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/JDBCDurableSubscriptionTest.java b/assembly/src/test/java/org/apache/activemq/usecases/JDBCDurableSubscriptionTest.java deleted file mode 100755 index 9ba3d168cc..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/JDBCDurableSubscriptionTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import java.io.File; -import java.io.IOException; - -import org.apache.activemq.store.DefaultPersistenceAdapterFactory; -import org.apache.activemq.store.PersistenceAdapter; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class JDBCDurableSubscriptionTest extends DurableSubscriptionTestSupport { - - protected PersistenceAdapter createPersistenceAdapter() throws IOException { - File dataDir = new File("target/test-data/durableJDBC"); - DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory(); - factory.setDataDirectory(dataDir); - factory.setUseJournal(false); - return factory.createPersistenceAdapter(); - } - -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/JournalDurableSubscriptionTest.java b/assembly/src/test/java/org/apache/activemq/usecases/JournalDurableSubscriptionTest.java deleted file mode 100755 index 35762e689e..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/JournalDurableSubscriptionTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import java.io.File; -import java.io.IOException; - -import org.apache.activemq.store.DefaultPersistenceAdapterFactory; -import org.apache.activemq.store.PersistenceAdapter; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class JournalDurableSubscriptionTest extends DurableSubscriptionTestSupport { - - protected PersistenceAdapter createPersistenceAdapter() throws IOException { - File dataDir = new File("target/test-data/durableJournal"); - DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory(); - factory.setDataDirectory(dataDir); - factory.setUseJournal(true); - factory.setJournalLogFileSize(1024*64); - return factory.createPersistenceAdapter(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java b/assembly/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java deleted file mode 100644 index b96987a61a..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.util.MessageIdList; -import org.apache.activemq.JmsMultipleBrokersTestSupport; - -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import java.util.Map; -import java.util.HashMap; -import java.net.URI; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class MultiBrokersMultiClientsTest extends JmsMultipleBrokersTestSupport { - public static final int BROKER_COUNT = 2; // number of brokers to network - public static final int CONSUMER_COUNT = 3; // consumers per broker - public static final int PRODUCER_COUNT = 3; // producers per broker - public static final int MESSAGE_COUNT = 10; // messages per producer - - protected Map consumerMap; - - public void testTopicAllConnected() throws Exception { - bridgeAllBrokers(); - startAllBrokers(); - - - // Setup topic destination - Destination dest = createDestination("TEST.FOO", true); - - // Setup consumers - for (int i=1; i<=BROKER_COUNT; i++) { - for (int j=0; j= data.length) { - synchronized (lock) { - lock.notifyAll(); - } - } - - } - - - protected List createConcurrentList() { - return Collections.synchronizedList(new ArrayList()); - } - - - protected void waitForMessagesToBeDelivered() { - long maxWaitTime = 5000; - long waitTime = maxWaitTime; - long start = (maxWaitTime <= 0) ? 0 : System.currentTimeMillis(); - - synchronized (lock) { - while (messages.size() <= data.length && waitTime >= 0) { - try { - lock.wait(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - waitTime = maxWaitTime - (System.currentTimeMillis() - start); - } - } - } - - - protected static void recursiveDelete(File file) { - if( file.isDirectory() ) { - File[] files = file.listFiles(); - for (int i = 0; i < files.length; i++) { - recursiveDelete(files[i]); - } - } - file.delete(); - } - - protected void tearDown() throws Exception { - if (connection != null) { - connection.close(); - } - - super.tearDown(); - } -} \ No newline at end of file diff --git a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageTest.java b/assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageTest.java deleted file mode 100755 index 8e63d573b7..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageTest.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class PublishOnQueueConsumedMessageTest extends PublishOnTopicConsumedMessageTest { - - protected void setUp() throws Exception { - topic = false; - super.setUp(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageUsingActivemqXMLTest.java b/assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageUsingActivemqXMLTest.java deleted file mode 100644 index 40f0739109..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageUsingActivemqXMLTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.xbean.BrokerFactoryBean; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -import java.io.File; - -/** - * - * Test Publish/Consume queue using the release activemq.xml configuration file - * - * @version $Revision: 1.2 $ - */ -public class PublishOnQueueConsumedMessageUsingActivemqXMLTest extends PublishOnTopicConsumedMessageTest { - protected static final String JOURNAL_ROOT = "../data/"; - BrokerService broker; - - - - /** - * Use the transportConnector uri configured on the activemq.xml - * - * @return ActiveMQConnectionFactory - * @throws Exception - */ - protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { - return new ActiveMQConnectionFactory("tcp://localhost:61616"); - } - - - /** - * Sets up a test where the producer and consumer have their own connection. - * - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - ; - File journalFile = new File(JOURNAL_ROOT); - recursiveDelete(journalFile); - // Create broker from resource - System.out.print("Creating broker... "); - broker = createBroker("org/apache/activemq/usecases/activemq.xml"); - log.info("Success"); - super.setUp(); - - } - - - - /* - * Stops the Broker - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - log.info("Closing Broker"); - if (broker != null) { - broker.stop(); - } - log.info("Broker closed..."); - - - } - - - /* - * clean up the journal - */ - - protected static void recursiveDelete(File file) { - if( file.isDirectory() ) { - File[] files = file.listFiles(); - for (int i = 0; i < files.length; i++) { - recursiveDelete(files[i]); - } - } - file.delete(); - } - - protected BrokerService createBroker(String resource) throws Exception { - return createBroker(new ClassPathResource(resource)); - } - - protected BrokerService createBroker(Resource resource) throws Exception { - BrokerFactoryBean factory = new BrokerFactoryBean(resource); - factory.afterPropertiesSet(); - - BrokerService broker = factory.getBroker(); - - //assertTrue("Should have a broker!", broker != null); - - - return broker; - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTemporaryQueueConsumedMessageTest.java b/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTemporaryQueueConsumedMessageTest.java deleted file mode 100755 index ee2c1fb652..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTemporaryQueueConsumedMessageTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import javax.jms.DeliveryMode; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class PublishOnTemporaryQueueConsumedMessageTest extends PublishOnTopicConsumedMessageTest { - - protected void setUp() throws Exception { - topic = false; - deliveryMode = DeliveryMode.NON_PERSISTENT; - super.setUp(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumedMessageTest.java b/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumedMessageTest.java deleted file mode 100755 index f4d9baa3af..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumedMessageTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.test.JmsTopicSendReceiveWithTwoConnectionsTest; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageProducer; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class PublishOnTopicConsumedMessageTest extends JmsTopicSendReceiveWithTwoConnectionsTest { - private MessageProducer replyProducer; - - - public synchronized void onMessage(Message message) { - - // lets resend the message somewhere else - try { - Message msgCopy = (Message)((org.apache.activemq.command.Message)message).copy(); - replyProducer.send(msgCopy); - - //log.info("Sending reply: " + message); - super.onMessage(message); - } - catch (JMSException e) { - log.info("Failed to send message: " + e); - e.printStackTrace(); - } - } - - protected void setUp() throws Exception { - super.setUp(); - - Destination replyDestination = null; - - if (topic) { - replyDestination = receiveSession.createTopic("REPLY." + getSubject()); - } - else { - replyDestination = receiveSession.createQueue("REPLY." + getSubject()); - } - - replyProducer = receiveSession.createProducer(replyDestination); - log.info("Created replyProducer: " + replyProducer); - - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumerMessageUsingActivemqXMLTest.java b/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumerMessageUsingActivemqXMLTest.java deleted file mode 100644 index 248e4b89fb..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumerMessageUsingActivemqXMLTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.xbean.BrokerFactoryBean; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import java.io.File; - -/** - * - * Test Publish/Consume topic using the release activemq.xml configuration file - * - * @version $Revision: 1.2 $ - */ -public class PublishOnTopicConsumerMessageUsingActivemqXMLTest extends PublishOnTopicConsumedMessageTest { - protected static final String JOURNAL_ROOT = "../data/"; - BrokerService broker; - - - - /** - * Use the transportConnector uri configured on the activemq.xml - * - * @return ActiveMQConnectionFactory - * @throws Exception - */ - protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { - return new ActiveMQConnectionFactory("tcp://localhost:61616"); - } - - - /** - * Sets up a test where the producer and consumer have their own connection. - * - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - ; - File journalFile = new File(JOURNAL_ROOT); - recursiveDelete(journalFile); - // Create broker from resource - System.out.print("Creating broker... "); - broker = createBroker("org/apache/activemq/usecases/activemq.xml"); - log.info("Success"); - super.setUp(); - - } - - - - /* - * Stops the Broker - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - log.info("Closing Broker"); - if (broker != null) { - broker.stop(); - } - log.info("Broker closed..."); - - - } - - - - - - /* - * clean up the journal - */ - - protected static void recursiveDelete(File file) { - if( file.isDirectory() ) { - File[] files = file.listFiles(); - for (int i = 0; i < files.length; i++) { - recursiveDelete(files[i]); - } - } - file.delete(); - } - - protected BrokerService createBroker(String resource) throws Exception { - return createBroker(new ClassPathResource(resource)); - } - - protected BrokerService createBroker(Resource resource) throws Exception { - BrokerFactoryBean factory = new BrokerFactoryBean(resource); - factory.afterPropertiesSet(); - - BrokerService broker = factory.getBroker(); - - //assertTrue("Should have a broker!", broker != null); - - - return broker; - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/QueueConsumerCloseAndReconnectTest.java b/assembly/src/test/java/org/apache/activemq/usecases/QueueConsumerCloseAndReconnectTest.java deleted file mode 100755 index c5fc952183..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/QueueConsumerCloseAndReconnectTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class QueueConsumerCloseAndReconnectTest extends DurableConsumerCloseAndReconnectTest { - protected boolean isTopic() { - return false; - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java b/assembly/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java deleted file mode 100755 index e1a1772a40..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -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.TextMessage; - -import junit.framework.TestCase; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class QueueDuplicatesTest extends TestCase { - - private static final Log log = LogFactory.getLog(QueueDuplicatesTest.class); - - private static DateFormat formatter = new SimpleDateFormat("HH:mm:ss SSS"); - private String brokerUrl; - private String subject; - private Connection brokerConnection; - - public QueueDuplicatesTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - String peerUrl = "peer://localhost:6099"; - - subject = this.getClass().getName(); - - ActiveMQConnectionFactory fac = createFactory(peerUrl); - brokerConnection = fac.createConnection(); - brokerConnection.start(); - } - - protected void tearDown() throws Exception { - if (brokerConnection != null) { - brokerConnection.close(); - } - } - - public void testDuplicates() { - try { - // Get Session - Session session = createSession(brokerConnection); - // create consumer - Destination dest = session.createQueue(subject); - MessageConsumer consumer = session.createConsumer(dest); - // subscribe to queue - consumer.setMessageListener(new SimpleConsumer()); - // create producer - Thread sendingThread = new SendingThread(brokerUrl, subject); - // start producer - sendingThread.start(); - // wait about 5 seconds - Thread.sleep(5000); - // unsubscribe consumer - consumer.close(); - // wait another 5 seconds - Thread.sleep(5000); - // create new consumer - consumer = session.createConsumer(dest); - // subscribe to queue - consumer.setMessageListener(new SimpleConsumer()); - // sleep a little while longer - Thread.sleep(15000); - session.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - Session createSession(Connection peerConnection) throws JMSException { - // Connect using peer to peer connection - Session session = peerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - return session; - } - - private ActiveMQConnectionFactory createFactory(String brokerUrl) { - ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(); - cf.setBrokerURL(brokerUrl); - - return cf; - } - private class SendingThread extends Thread { - private String brokerUrl; - private String subject; - - SendingThread(String brokerUrl, String subject) { - this.brokerUrl = brokerUrl; - this.subject = subject; - setDaemon(false); - } - - public void run() { - try { - Session session = createSession(brokerConnection); - Destination dest = session.createQueue(subject); - MessageProducer producer = session.createProducer(dest); - producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); - for (int i = 0;i < 20;i++) { - String txt = "Text Message: " + i; - TextMessage msg = session.createTextMessage(txt); - producer.send(msg); - log.info(formatter.format(new Date()) + " Sent ==> " + msg + " to " + subject); - Thread.sleep(1000); - } - session.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - } - private static class SimpleConsumer implements MessageListener { - private Map msgs = new HashMap(); - - public void onMessage(Message message) { - log.info(formatter.format(new Date()) + " SimpleConsumer Message Received: " + message); - try { - String id = message.getJMSMessageID(); - assertNull("Message is duplicate: " + id, msgs.get(id)); - msgs.put(id, message); - } - catch (Exception e) { - e.printStackTrace(); - } - } - } -} \ No newline at end of file diff --git a/assembly/src/test/java/org/apache/activemq/usecases/QueueRedeliverTest.java b/assembly/src/test/java/org/apache/activemq/usecases/QueueRedeliverTest.java deleted file mode 100755 index 2310027d5e..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/QueueRedeliverTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class QueueRedeliverTest extends TopicRedeliverTest { - - protected void setUp() throws Exception{ - super.setUp(); - topic = false; - } - -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java deleted file mode 100755 index b6332ad38b..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; -import java.util.HashMap; -import java.net.URI; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.QueueConnection; -import javax.jms.QueueReceiver; -import javax.jms.QueueSender; -import javax.jms.QueueSession; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.BrokerFactory; -import org.apache.activemq.broker.Broker; -import org.apache.activemq.test.TestSupport; -import org.apache.activemq.util.IdGenerator; -import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean; -import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ReliableReconnectTest extends TestSupport { - private static final int RECEIVE_TIMEOUT = 10000; - protected static final int MESSAGE_COUNT = 100; - protected static final String DEFAULT_BROKER_URL = "vm://localhost"; - private IdGenerator idGen = new IdGenerator(); - protected int deliveryMode = DeliveryMode.PERSISTENT; - protected String consumerClientId; - protected Destination destination; - protected AtomicBoolean closeBroker = new AtomicBoolean(false); - protected AtomicInteger messagesReceived = new AtomicInteger(0); - protected BrokerService broker; - protected int firstBatch = MESSAGE_COUNT/10; - - public ReliableReconnectTest() { - } - - public ReliableReconnectTest(String n) { - super(n); - } - - protected void setUp() throws Exception { - consumerClientId = idGen.generateId(); - super.setUp(); - topic = true; - destination = createDestination(getClass().getName()); - } - - public ActiveMQConnectionFactory getConnectionFactory() throws Exception { - String url = "failover://" + DEFAULT_BROKER_URL; - return new ActiveMQConnectionFactory(url); - } - - protected void startBroker() throws JMSException { - try { - broker = BrokerFactory.createBroker(new URI("broker://()/localhost")); - broker.addConnector(DEFAULT_BROKER_URL); - broker.start(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - protected Connection createConsumerConnection() throws Exception { - Connection consumerConnection = getConnectionFactory().createConnection(); - consumerConnection.setClientID(consumerClientId); - consumerConnection.start(); - return consumerConnection; - } - - protected MessageConsumer createConsumer(Connection con) throws Exception { - Session s = con.createSession(false, Session.AUTO_ACKNOWLEDGE); - return s.createDurableSubscriber((Topic) destination, "TestFred"); - } - - protected void spawnConsumer() { - Thread thread = new Thread(new Runnable() { - public void run() { - try { - Connection consumerConnection = createConsumerConnection(); - MessageConsumer consumer = createConsumer(consumerConnection); - //consume some messages - - for (int i = 0;i < firstBatch;i++) { - Message msg = consumer.receive(RECEIVE_TIMEOUT); - if (msg != null) { - //log.info("GOT: " + msg); - messagesReceived.incrementAndGet(); - } - } - synchronized (closeBroker) { - closeBroker.set(true); - closeBroker.notify(); - } - Thread.sleep(2000); - for (int i = firstBatch;i < MESSAGE_COUNT;i++) { - Message msg = consumer.receive(RECEIVE_TIMEOUT); - //log.info("GOT: " + msg); - if (msg != null) { - messagesReceived.incrementAndGet(); - } - } - consumerConnection.close(); - synchronized (messagesReceived) { - messagesReceived.notify(); - } - } - catch (Throwable e) { - e.printStackTrace(); - } - } - }); - thread.start(); - } - - public void testReconnect() throws Exception { - startBroker(); - //register an interest as a durable subscriber - Connection consumerConnection = createConsumerConnection(); - createConsumer(consumerConnection); - consumerConnection.close(); - //send some messages ... - Connection connection = createConnection(); - connection.setClientID(idGen.generateId()); - connection.start(); - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - TextMessage msg = producerSession.createTextMessage(); - for (int i = 0;i < MESSAGE_COUNT;i++) { - msg.setText("msg: " + i); - producer.send(msg); - } - connection.close(); - spawnConsumer(); - synchronized (closeBroker) { - if (!closeBroker.get()) { - closeBroker.wait(); - } - } - System.err.println("Stopping broker"); - broker.stop(); - startBroker(); - System.err.println("Started Broker again"); - synchronized (messagesReceived) { - if (messagesReceived.get() < MESSAGE_COUNT) { - messagesReceived.wait(60000); - } - } - //assertTrue(messagesReceived.get() == MESSAGE_COUNT); - int count = messagesReceived.get(); - assertTrue("Not enough messages received: " + count, count > firstBatch); - } -} \ No newline at end of file diff --git a/assembly/src/test/java/org/apache/activemq/usecases/StartAndStopBrokerTest.java b/assembly/src/test/java/org/apache/activemq/usecases/StartAndStopBrokerTest.java deleted file mode 100755 index 8e2ca838e2..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/StartAndStopBrokerTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import junit.framework.TestCase; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.BrokerFactory; -import org.apache.activemq.broker.TransportConnector; - -import javax.jms.JMSException; -import java.net.URI; - -/** - * @author Oliver Belikan - * @version $Revision: 1.1.1.1 $ - */ -public class StartAndStopBrokerTest extends TestCase { - public void testStartupShutdown() throws Exception { - // This systemproperty is used if we dont want to - // have persistence messages as a default - System.setProperty("activemq.persistenceAdapter", - "org.apache.activemq.store.vm.VMPersistenceAdapter"); - - // configuration of container and all protocolls - BrokerService broker = createBroker(); - - // start a client - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:9100"); - factory.createConnection(); - - // stop activemq broker - broker.stop(); - - // start activemq broker again - broker = createBroker(); - - // start a client again - factory = new ActiveMQConnectionFactory("tcp://localhost:9100"); - factory.createConnection(); - - // stop activemq broker - broker.stop(); - - } - - protected BrokerService createBroker() throws JMSException { - BrokerService broker = null; - - try { - broker = BrokerFactory.createBroker(new URI("broker://()/localhost")); - broker.setBrokerName("DefaultBroker"); - broker.addConnector("tcp://localhost:9100"); - broker.setUseShutdownHook(false); - - broker.start(); - } catch (Exception e) { - e.printStackTrace(); - } - - return broker; - } - -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/SubscribeClosePublishThenConsumeTest.java b/assembly/src/test/java/org/apache/activemq/usecases/SubscribeClosePublishThenConsumeTest.java deleted file mode 100755 index f6851e13fd..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/SubscribeClosePublishThenConsumeTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.test.TestSupport; - -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.jms.TopicSubscriber; - -/** - * @author Paul Smith - * @version $Revision: 1.1.1.1 $ - */ -public class SubscribeClosePublishThenConsumeTest extends TestSupport { - - public void testDurableTopic() throws Exception { - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://locahost"); - - String topicName = "TestTopic"; - String clientID = getName(); - String subscriberName = "MySubscriber:"+System.currentTimeMillis(); - - Connection connection = connectionFactory.createConnection(); - connection.setClientID(clientID); - - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Topic topic = session.createTopic(topicName); - - // this should register a durable subscriber, we then close it to - // test that we get messages from the producer later on - TopicSubscriber subscriber = session.createDurableSubscriber(topic, subscriberName); - connection.start(); - - topic = null; - subscriber.close(); - subscriber = null; - session.close(); - session = null; - - // Create the new connection before closing to avoid the broker shutting down. - // now create a new Connection, Session & Producer, send some messages & then close - Connection t = connectionFactory.createConnection(); - connection.close(); - connection = t; - - session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - topic = session.createTopic(topicName); - MessageProducer producer = session.createProducer(topic); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - TextMessage textMessage = session.createTextMessage("Hello World"); - producer.send(textMessage); - textMessage = null; - - topic = null; - session.close(); - session = null; - - // Now (re)register the Durable subscriber, setup a listener and wait for messages that should - // have been published by the previous producer - t = connectionFactory.createConnection(); - connection.close(); - connection = t; - - connection.setClientID(clientID); - session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - topic = session.createTopic(topicName); - - subscriber = session.createDurableSubscriber(topic, subscriberName); - connection.start(); - - log.info("Started connection - now about to try receive the textMessage"); - - long time = System.currentTimeMillis(); - Message message = subscriber.receive(15000L); - long elapsed = System.currentTimeMillis() - time; - - log.info("Waited for: " + elapsed + " millis"); - - assertNotNull("Should have received the message we published by now", message); - assertTrue("should be text textMessage", message instanceof TextMessage); - textMessage = (TextMessage) message; - assertEquals("Hello World", textMessage.getText()); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/TestSupport.java b/assembly/src/test/java/org/apache/activemq/usecases/TestSupport.java deleted file mode 100755 index d7ba1ad802..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/TestSupport.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQMessage; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.command.ActiveMQTopic; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.TextMessage; - -import junit.framework.TestCase; - - -/** - * Useful base class for unit test cases - * - * @version $Revision: 1.1.1.1 $ - */ -public class TestSupport extends TestCase { - protected Log log = LogFactory.getLog(getClass()); - protected ActiveMQConnectionFactory connectionFactory; - protected boolean topic = true; - - public TestSupport() { - super(); - } - - public TestSupport(String name) { - super(name); - } - - protected ActiveMQMessage createMessage() { - return new ActiveMQMessage(); - } - - protected Destination createDestination(String subject) { - if (topic) { - return new ActiveMQTopic(subject); - } - else { - return new ActiveMQQueue(subject); - } - } - - protected void assertTextMessagesEqual(Message[] firstSet, Message[] secondSet) throws JMSException { - assertTextMessagesEqual("", firstSet, secondSet); - } - /** - * @param messsage - * @param firstSet - * @param secondSet - */ - protected void assertTextMessagesEqual(String messsage, Message[] firstSet, Message[] secondSet) throws JMSException { - assertEquals("Message count does not match: " + messsage, firstSet.length, secondSet.length); - for (int i = 0; i < secondSet.length; i++) { - TextMessage m1 = (TextMessage) firstSet[i]; - TextMessage m2 = (TextMessage) secondSet[i]; - assertTextMessageEqual("Message " + (i + 1) + " did not match : ", m1,m2); - } - } - - protected void assertEquals(TextMessage m1, TextMessage m2) throws JMSException { - assertEquals("", m1, m2); - } - - /** - * @param message - * @param firstSet - * @param secondSet - */ - protected void assertTextMessageEqual(String message, TextMessage m1, TextMessage m2) throws JMSException { - assertFalse(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1 == null ^ m2 == null); - if( m1 == null ) - return; - assertEquals(message, m1.getText(), m2.getText()); - } - - protected void assertEquals(Message m1, Message m2) throws JMSException { - assertEquals("", m1, m2); - } - /** - * @param message - * @param firstSet - * @param secondSet - */ - protected void assertEquals(String message, Message m1, Message m2) throws JMSException { - assertFalse(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1 == null ^ m2 == null); - if( m1 == null ) - return; - assertTrue(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1.getClass()==m2.getClass()); - if( m1 instanceof TextMessage ) { - assertTextMessageEqual(message, (TextMessage)m1, (TextMessage)m2); - } else { - assertEquals(message, m1, m2); - } - } - - protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { - return new ActiveMQConnectionFactory("vm://localhost"); - } - - /** - * Factory method to create a new connection - */ - protected Connection createConnection() throws Exception { - return getConnectionFactory().createConnection(); - } - - public ActiveMQConnectionFactory getConnectionFactory() throws Exception { - if (connectionFactory == null) { - connectionFactory = createConnectionFactory(); - assertTrue("Should have created a connection factory!", connectionFactory != null); - } - return connectionFactory; - } - - protected String getConsumerSubject() { - return getSubject(); - } - - protected String getProducerSubject() { - return getSubject(); - } - - protected String getSubject() { - return getClass().getName() + "." + getName(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java deleted file mode 100644 index 13eee01644..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.JmsMultipleBrokersTestSupport; -import org.apache.activemq.util.MessageIdList; - -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import java.net.URI; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ThreeBrokerQueueNetworkTest extends JmsMultipleBrokersTestSupport { - protected static final int MESSAGE_COUNT = 100; - - /** - * BrokerA -> BrokerB -> BrokerC - */ - public void test_AB_BC_BrokerNetwork() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerA", "BrokerB"); - bridgeBrokers("BrokerB", "BrokerC"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", false); - - // Setup consumers - MessageConsumer clientC = createConsumer("BrokerC", dest); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - - // Let's try to wait for any messages. Should be none. - Thread.sleep(1000); - - // Get message count - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - assertEquals(0, msgsC.getMessageCount()); - } - - /** - * BrokerA <- BrokerB -> BrokerC - */ - public void test_BA_BC_BrokerNetwork() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerB", "BrokerA"); - bridgeBrokers("BrokerB", "BrokerC"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", false); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientC = createConsumer("BrokerC", dest); - Thread.sleep(2000); //et subscriptions get propagated - // Send messages - sendMessages("BrokerB", dest, MESSAGE_COUNT); - - // Let's try to wait for any messages. - Thread.sleep(1000); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - - // Total received should be 100 - assertEquals(MESSAGE_COUNT, msgsA.getMessageCount() + msgsC.getMessageCount()); - } - - /** - * BrokerA -> BrokerB <- BrokerC - */ - public void test_AB_CB_BrokerNetwork() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerA", "BrokerB"); - bridgeBrokers("BrokerC", "BrokerB"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", false); - - // Setup consumers - MessageConsumer clientB = createConsumer("BrokerB", dest); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - sendMessages("BrokerC", dest, MESSAGE_COUNT); - - // Get message count - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - - msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 2); - - assertEquals(MESSAGE_COUNT * 2, msgsB.getMessageCount()); - } - - /** - * BrokerA <-> BrokerB <-> BrokerC - */ - public void testAllConnectedBrokerNetwork() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerA", "BrokerB"); - bridgeBrokers("BrokerB", "BrokerA"); - bridgeBrokers("BrokerB", "BrokerC"); - bridgeBrokers("BrokerC", "BrokerB"); - bridgeBrokers("BrokerA", "BrokerC"); - bridgeBrokers("BrokerC", "BrokerA"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", false); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientB = createConsumer("BrokerB", dest); - MessageConsumer clientC = createConsumer("BrokerC", dest); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - sendMessages("BrokerB", dest, MESSAGE_COUNT); - sendMessages("BrokerC", dest, MESSAGE_COUNT); - - // Let's try to wait for any messages. - Thread.sleep(1000); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - - assertEquals(MESSAGE_COUNT * 3, msgsA.getMessageCount() + msgsB.getMessageCount() + msgsC.getMessageCount()); - } - - /** - * BrokerA <-> BrokerB <-> BrokerC - */ - public void testAllConnectedUsingMulticast() throws Exception { - // Setup broker networks - bridgeAllBrokers(); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", false); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientB = createConsumer("BrokerB", dest); - MessageConsumer clientC = createConsumer("BrokerC", dest); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - sendMessages("BrokerB", dest, MESSAGE_COUNT); - sendMessages("BrokerC", dest, MESSAGE_COUNT); - - // Let's try to wait for any messages. - Thread.sleep(1000); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - - assertEquals(MESSAGE_COUNT * 3, msgsA.getMessageCount() + msgsB.getMessageCount() + msgsC.getMessageCount()); - } - - public void setUp() throws Exception { - super.setAutoFail(true); - super.setUp(); - createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=false")); - createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=false")); - createBroker(new URI("broker:(tcp://localhost:61618)/BrokerC?persistent=false&useJmx=false")); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java deleted file mode 100644 index 9333fc80d0..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.TransportConnector; -import org.apache.activemq.network.DemandForwardingBridge; -import org.apache.activemq.transport.TransportFactory; - -import java.util.List; -import java.util.ArrayList; -import java.net.URI; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ThreeBrokerQueueNetworkUsingTcpTest extends ThreeBrokerQueueNetworkTest { - protected List bridges; - - protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception { - List remoteTransports = remoteBroker.getTransportConnectors(); - List localTransports = localBroker.getTransportConnectors(); - - URI remoteURI, localURI; - if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) { - remoteURI = ((TransportConnector)remoteTransports.get(0)).getConnectUri(); - localURI = ((TransportConnector)localTransports.get(0)).getConnectUri(); - - // Ensure that we are connecting using tcp - if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) { - DemandForwardingBridge bridge = new DemandForwardingBridge(TransportFactory.connect(localURI), - TransportFactory.connect(remoteURI)); - bridge.setLocalBrokerName(localBroker.getBrokerName()); - bridges.add(bridge); - - bridge.start(); - } else { - throw new Exception("Remote broker or local broker is not using tcp connectors"); - } - } else { - throw new Exception("Remote broker or local broker has no registered connectors."); - } - - MAX_SETUP_TIME = 2000; - } - - public void setUp() throws Exception { - super.setUp(); - - bridges = new ArrayList(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java deleted file mode 100644 index 74b87341bd..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import java.net.URI; -import java.util.Iterator; -import javax.jms.Connection; -import javax.jms.Session; -import javax.jms.TemporaryQueue; -import org.apache.activemq.JmsMultipleBrokersTestSupport; -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ThreeBrokerTempQueueNetworkTest extends JmsMultipleBrokersTestSupport{ - protected static final int MESSAGE_COUNT=100; - - /** - * BrokerA -> BrokerB -> BrokerC - */ - public void testTempQueueCleanup() throws Exception{ - // Setup broker networks - bridgeBrokers("BrokerA","BrokerB",false,2); - bridgeBrokers("BrokerB","BrokerC",false,2); - startAllBrokers(); - BrokerItem brokerItem=(BrokerItem) brokers.get("BrokerC"); - Connection conn=brokerItem.createConnection(); - conn.start(); - Session sess=conn.createSession(false,Session.AUTO_ACKNOWLEDGE); - TemporaryQueue tempQ=sess.createTemporaryQueue(); - Thread.sleep(5000); - for(Iterator i=brokers.values().iterator();i.hasNext();){ - BrokerItem bi=(BrokerItem) i.next(); - assertEquals("No queues on broker "+bi.broker.getBrokerName(),1,bi.broker.getAdminView() - .getTemporaryQueues().length); - } - tempQ.delete(); - Thread.sleep(2000); - for(Iterator i=brokers.values().iterator();i.hasNext();){ - BrokerItem bi=(BrokerItem) i.next(); - assertEquals("Temp queue left behind on broker "+bi.broker.getBrokerName(),0,bi.broker.getAdminView() - .getTemporaryQueues().length); - } - } - - // this actually uses 4 brokers ... - public void testTempQueueRecovery() throws Exception{ - // Setup broker networks - bridgeBrokers("BrokerA","BrokerB",false,3); - bridgeBrokers("BrokerB","BrokerC",false,3); - startAllBrokers(); - BrokerItem brokerItem=(BrokerItem) brokers.get("BrokerC"); - Connection conn=brokerItem.createConnection(); - conn.start(); - Session sess=conn.createSession(false,Session.AUTO_ACKNOWLEDGE); - TemporaryQueue tempQ=sess.createTemporaryQueue(); - Thread.sleep(5000); - for(Iterator i=brokers.values().iterator();i.hasNext();){ - BrokerItem bi=(BrokerItem) i.next(); - assertEquals("No queues on broker "+bi.broker.getBrokerName(),1,bi.broker.getAdminView() - .getTemporaryQueues().length); - } - createBroker(new URI("broker:(tcp://localhost:61619)/BrokerD?persistent=false&useJmx=true")); - bridgeBrokers("BrokerD","BrokerA",false,3); - BrokerItem newBroker=(BrokerItem) brokers.get("BrokerD"); - newBroker.broker.start(); - Thread.sleep(1000); - assertEquals("No queues on broker D",1,newBroker.broker.getAdminView().getTemporaryQueues().length); - tempQ.delete(); - Thread.sleep(2000); - for(Iterator i=brokers.values().iterator();i.hasNext();){ - BrokerItem bi=(BrokerItem) i.next(); - assertEquals("Temp queue left behind on broker "+bi.broker.getBrokerName(),0,bi.broker.getAdminView() - .getTemporaryQueues().length); - } - } - - public void setUp() throws Exception{ - super.setAutoFail(true); - super.setUp(); - createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=true")); - createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=true")); - createBroker(new URI("broker:(tcp://localhost:61618)/BrokerC?persistent=false&useJmx=true")); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java deleted file mode 100644 index 6236cd8691..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.util.MessageIdList; -import org.apache.activemq.JmsMultipleBrokersTestSupport; - -import javax.jms.MessageConsumer; -import javax.jms.Destination; -import java.net.URI; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ThreeBrokerTopicNetworkTest extends JmsMultipleBrokersTestSupport { - protected static final int MESSAGE_COUNT = 100; - - /** - * BrokerA -> BrokerB -> BrokerC - */ - public void test_AB_BC_BrokerNetwork() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerA", "BrokerB"); - bridgeBrokers("BrokerB", "BrokerC"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", true); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientB = createConsumer("BrokerB", dest); - MessageConsumer clientC = createConsumer("BrokerC", dest); - -// let consumers propogate around the network - Thread.sleep(2000); - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - sendMessages("BrokerB", dest, MESSAGE_COUNT); - sendMessages("BrokerC", dest, MESSAGE_COUNT); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - - msgsA.waitForMessagesToArrive(MESSAGE_COUNT); - msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 2); - msgsC.waitForMessagesToArrive(MESSAGE_COUNT * 2); - - assertEquals(MESSAGE_COUNT, msgsA.getMessageCount()); - assertEquals(MESSAGE_COUNT * 2, msgsB.getMessageCount()); - assertEquals(MESSAGE_COUNT * 2, msgsC.getMessageCount()); - } - - /** - * BrokerA <- BrokerB -> BrokerC - */ - public void test_BA_BC_BrokerNetwork() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerB", "BrokerA"); - bridgeBrokers("BrokerB", "BrokerC"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", true); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientB = createConsumer("BrokerB", dest); - MessageConsumer clientC = createConsumer("BrokerC", dest); - -// let consumers propogate around the network - Thread.sleep(2000); - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - sendMessages("BrokerB", dest, MESSAGE_COUNT); - sendMessages("BrokerC", dest, MESSAGE_COUNT); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - - msgsA.waitForMessagesToArrive(MESSAGE_COUNT * 2); - msgsB.waitForMessagesToArrive(MESSAGE_COUNT); - msgsC.waitForMessagesToArrive(MESSAGE_COUNT * 2); - - assertEquals(MESSAGE_COUNT * 2, msgsA.getMessageCount()); - assertEquals(MESSAGE_COUNT, msgsB.getMessageCount()); - assertEquals(MESSAGE_COUNT * 2, msgsC.getMessageCount()); - } - - /** - * BrokerA -> BrokerB <- BrokerC - */ - public void test_AB_CB_BrokerNetwork() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerA", "BrokerB"); - bridgeBrokers("BrokerC", "BrokerB"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", true); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientB = createConsumer("BrokerB", dest); - MessageConsumer clientC = createConsumer("BrokerC", dest); - -// let consumers propogate around the network - Thread.sleep(2000); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - sendMessages("BrokerB", dest, MESSAGE_COUNT); - sendMessages("BrokerC", dest, MESSAGE_COUNT); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - - msgsA.waitForMessagesToArrive(MESSAGE_COUNT); - msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 3); - msgsC.waitForMessagesToArrive(MESSAGE_COUNT); - - assertEquals(MESSAGE_COUNT, msgsA.getMessageCount()); - assertEquals(MESSAGE_COUNT * 3, msgsB.getMessageCount()); - assertEquals(MESSAGE_COUNT, msgsC.getMessageCount()); - } - - /** - * BrokerA <-> BrokerB <-> BrokerC - */ - public void testAllConnectedBrokerNetwork() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerA", "BrokerB"); - bridgeBrokers("BrokerB", "BrokerA"); - bridgeBrokers("BrokerB", "BrokerC"); - bridgeBrokers("BrokerC", "BrokerB"); - bridgeBrokers("BrokerA", "BrokerC"); - bridgeBrokers("BrokerC", "BrokerA"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", true); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientB = createConsumer("BrokerB", dest); - MessageConsumer clientC = createConsumer("BrokerC", dest); - //let consumers propogate around the network - Thread.sleep(2000); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - sendMessages("BrokerB", dest, MESSAGE_COUNT); - sendMessages("BrokerC", dest, MESSAGE_COUNT); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - - msgsA.waitForMessagesToArrive(MESSAGE_COUNT * 3); - msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 3); - msgsC.waitForMessagesToArrive(MESSAGE_COUNT * 3); - - assertEquals(MESSAGE_COUNT * 3, msgsA.getMessageCount()); - assertEquals(MESSAGE_COUNT * 3, msgsB.getMessageCount()); - assertEquals(MESSAGE_COUNT * 3, msgsC.getMessageCount()); - } - - /** - * BrokerA <-> BrokerB <-> BrokerC - */ - public void testAllConnectedUsingMulticast() throws Exception { - // Setup broker networks - bridgeAllBrokers(); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", true); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientB = createConsumer("BrokerB", dest); - MessageConsumer clientC = createConsumer("BrokerC", dest); - - //let consumers propogate around the network - Thread.sleep(2000); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - sendMessages("BrokerB", dest, MESSAGE_COUNT); - sendMessages("BrokerC", dest, MESSAGE_COUNT); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - - msgsA.waitForMessagesToArrive(MESSAGE_COUNT * 3); - msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 3); - msgsC.waitForMessagesToArrive(MESSAGE_COUNT * 3); - - assertEquals(MESSAGE_COUNT * 3, msgsA.getMessageCount()); - assertEquals(MESSAGE_COUNT * 3, msgsB.getMessageCount()); - assertEquals(MESSAGE_COUNT * 3, msgsC.getMessageCount()); - } - - public void setUp() throws Exception { - super.setAutoFail(true); - super.setUp(); - createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=false")); - createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=false")); - createBroker(new URI("broker:(tcp://localhost:61618)/BrokerC?persistent=false&useJmx=false")); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java b/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java deleted file mode 100644 index aac2f6ab31..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.TransportConnector; -import org.apache.activemq.network.DemandForwardingBridge; -import org.apache.activemq.transport.TransportFactory; - -import java.util.List; -import java.util.ArrayList; -import java.net.URI; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class ThreeBrokerTopicNetworkUsingTcpTest extends ThreeBrokerTopicNetworkTest { - protected List bridges; - - protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception { - List remoteTransports = remoteBroker.getTransportConnectors(); - List localTransports = localBroker.getTransportConnectors(); - - URI remoteURI, localURI; - if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) { - remoteURI = ((TransportConnector)remoteTransports.get(0)).getConnectUri(); - localURI = ((TransportConnector)localTransports.get(0)).getConnectUri(); - - // Ensure that we are connecting using tcp - if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) { - DemandForwardingBridge bridge = new DemandForwardingBridge(TransportFactory.connect(localURI), - TransportFactory.connect(remoteURI)); - bridge.setLocalBrokerName(localBroker.getBrokerName()); - bridges.add(bridge); - - bridge.start(); - } else { - throw new Exception("Remote broker or local broker is not using tcp connectors"); - } - } else { - throw new Exception("Remote broker or local broker has no registered connectors."); - } - - MAX_SETUP_TIME = 2000; - } - - public void setUp() throws Exception { - super.setUp(); - - bridges = new ArrayList(); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java b/assembly/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java deleted file mode 100755 index d892864ae1..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; - -import org.apache.activemq.test.TestSupport; -import org.apache.activemq.util.IdGenerator; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class TopicRedeliverTest extends TestSupport { - - private static final int RECEIVE_TIMEOUT = 10000; - private IdGenerator idGen = new IdGenerator(); - protected int deliveryMode = DeliveryMode.PERSISTENT; - public TopicRedeliverTest(){ - } - - public TopicRedeliverTest(String n){ - super(n); - } - - protected void setup() throws Exception{ - super.setUp(); - topic = true; - } - - - /** - * test messages are acknowledged and recovered properly - * @throws Exception - */ - public void testClientAcknowledge() throws Exception { - Destination destination = createDestination(getClass().getName()); - Connection connection = createConnection(); - connection.setClientID(idGen.generateId()); - connection.start(); - Session consumerSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - MessageConsumer consumer = consumerSession.createConsumer(destination); - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - producer.setDeliveryMode(deliveryMode); - - //send some messages - - TextMessage sent1 = producerSession.createTextMessage(); - sent1.setText("msg1"); - producer.send(sent1); - - TextMessage sent2 = producerSession.createTextMessage(); - sent1.setText("msg2"); - producer.send(sent2); - - TextMessage sent3 = producerSession.createTextMessage(); - sent1.setText("msg3"); - producer.send(sent3); - - Message rec1 = consumer.receive(RECEIVE_TIMEOUT); - Message rec2 = consumer.receive(RECEIVE_TIMEOUT); - Message rec3 = consumer.receive(RECEIVE_TIMEOUT); - - //ack rec2 - rec2.acknowledge(); - - TextMessage sent4 = producerSession.createTextMessage(); - sent4.setText("msg4"); - producer.send(sent4); - - Message rec4 = consumer.receive(RECEIVE_TIMEOUT); - assertTrue(rec4.equals(sent4)); - consumerSession.recover(); - rec4 = consumer.receive(RECEIVE_TIMEOUT); - assertTrue(rec4.equals(sent4)); - assertTrue(rec4.getJMSRedelivered()); - rec4.acknowledge(); - connection.close(); - - } - - /** - * Test redelivered flag is set on rollbacked transactions - * @throws Exception - */ - public void testRedilveredFlagSetOnRollback() throws Exception { - Destination destination = createDestination(getClass().getName()); - Connection connection = createConnection(); - connection.setClientID(idGen.generateId()); - connection.start(); - Session consumerSession = connection.createSession(true, Session.CLIENT_ACKNOWLEDGE); - MessageConsumer consumer = null; - if (topic){ - consumer = consumerSession.createDurableSubscriber((Topic)destination, "TESTRED"); - }else{ - consumer = consumerSession.createConsumer(destination); - } - Session producerSession = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - producer.setDeliveryMode(deliveryMode); - - TextMessage sentMsg = producerSession.createTextMessage(); - sentMsg.setText("msg1"); - producer.send(sentMsg); - producerSession.commit(); - - Message recMsg = consumer.receive(RECEIVE_TIMEOUT); - assertTrue(recMsg.getJMSRedelivered() == false); - recMsg = consumer.receive(RECEIVE_TIMEOUT); - consumerSession.rollback(); - recMsg = consumer.receive(RECEIVE_TIMEOUT); - assertTrue(recMsg.getJMSRedelivered()); - consumerSession.commit(); - assertTrue(recMsg.equals(sentMsg)); - assertTrue(recMsg.getJMSRedelivered()); - connection.close(); - } - - - /** - * Check a session is rollbacked on a Session close(); - * @throws Exception - */ - - public void XtestTransactionRollbackOnSessionClose() throws Exception { - Destination destination = createDestination(getClass().getName()); - Connection connection = createConnection(); - connection.setClientID(idGen.generateId()); - connection.start(); - Session consumerSession = connection.createSession(true, Session.CLIENT_ACKNOWLEDGE); - MessageConsumer consumer = null; - if (topic){ - consumer = consumerSession.createDurableSubscriber((Topic)destination, "TESTRED"); - }else{ - consumer = consumerSession.createConsumer(destination); - } - Session producerSession = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - producer.setDeliveryMode(deliveryMode); - - TextMessage sentMsg = producerSession.createTextMessage(); - sentMsg.setText("msg1"); - producer.send(sentMsg); - - producerSession.commit(); - - Message recMsg = consumer.receive(RECEIVE_TIMEOUT); - assertTrue(recMsg.getJMSRedelivered() == false); - consumerSession.close(); - consumerSession = connection.createSession(true, Session.CLIENT_ACKNOWLEDGE); - consumer = consumerSession.createConsumer(destination); - - recMsg = consumer.receive(RECEIVE_TIMEOUT); - consumerSession.commit(); - assertTrue(recMsg.equals(sentMsg)); - connection.close(); - } - - /** - * check messages are actuallly sent on a tx rollback - * @throws Exception - */ - - public void testTransactionRollbackOnSend() throws Exception { - Destination destination = createDestination(getClass().getName()); - Connection connection = createConnection(); - connection.setClientID(idGen.generateId()); - connection.start(); - Session consumerSession = connection.createSession(true, Session.CLIENT_ACKNOWLEDGE); - MessageConsumer consumer = consumerSession.createConsumer(destination); - Session producerSession = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - producer.setDeliveryMode(deliveryMode); - - TextMessage sentMsg = producerSession.createTextMessage(); - sentMsg.setText("msg1"); - producer.send(sentMsg); - producerSession.commit(); - - Message recMsg = consumer.receive(RECEIVE_TIMEOUT); - consumerSession.commit(); - assertTrue(recMsg.equals(sentMsg)); - - sentMsg = producerSession.createTextMessage(); - sentMsg.setText("msg2"); - producer.send(sentMsg); - producerSession.rollback(); - - sentMsg = producerSession.createTextMessage(); - sentMsg.setText("msg3"); - producer.send(sentMsg); - producerSession.commit(); - - recMsg = consumer.receive(RECEIVE_TIMEOUT); - assertTrue(recMsg.equals(sentMsg)); - consumerSession.commit(); - - connection.close(); - } - -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/TransactionRollbackOrderTest.java b/assembly/src/test/java/org/apache/activemq/usecases/TransactionRollbackOrderTest.java deleted file mode 100644 index 54102bafdf..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/TransactionRollbackOrderTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import java.util.ArrayList; -import java.util.List; - -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.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - -import junit.framework.TestCase; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch; - - -/** - * Test case for AMQ-268 - * - * @author Paul Smith - * @version $Revision: 1.1 $ - */ -public final class TransactionRollbackOrderTest extends TestCase { - private static final Log log = LogFactory.getLog(TransactionRollbackOrderTest.class); - - private volatile String receivedText; - - private Session producerSession; - private Session consumerSession; - private Destination queue; - - private MessageProducer producer; - private MessageConsumer consumer; - private Connection connection; - private CountDownLatch latch = new CountDownLatch(1); - private int NUM_MESSAGES = 5; - private List msgSent = new ArrayList(); - private List msgCommitted = new ArrayList(); - private List msgRolledBack = new ArrayList(); - private List msgRedelivered = new ArrayList(); - - public void testTransaction() throws Exception { - - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); - - connection = factory.createConnection(); - queue = new ActiveMQQueue(getClass().getName() + "." + getName()); - - producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - consumerSession = connection.createSession(true, 0); - - producer = producerSession.createProducer(queue); - - consumer = consumerSession.createConsumer(queue); - consumer.setMessageListener(new MessageListener() { - - int msgCount = 0; - int msgCommittedCount = 0; - - public void onMessage(Message m) { - try { - msgCount++; - TextMessage tm = (TextMessage) m; - receivedText = tm.getText(); - - if (tm.getJMSRedelivered()) { - msgRedelivered.add(receivedText); - } - - log.info("consumer received message: " + receivedText + (tm.getJMSRedelivered() ? " ** Redelivered **" : "")); - if (msgCount == 3) { - msgRolledBack.add(receivedText); - consumerSession.rollback(); - log.info("[msg: " + receivedText + "] ** rolled back **"); - } - else { - msgCommittedCount++; - msgCommitted.add(receivedText); - consumerSession.commit(); - log.info("[msg: " + receivedText + "] committed transaction "); - } - if (msgCommittedCount == NUM_MESSAGES) { - latch.countDown(); - } - } - catch (JMSException e) { - try { - consumerSession.rollback(); - log.info("rolled back transaction"); - } - catch (JMSException e1) { - log.info(e1); - e1.printStackTrace(); - } - log.info(e); - e.printStackTrace(); - } - } - }); - connection.start(); - - TextMessage tm = null; - try { - for (int i = 1; i <= NUM_MESSAGES; i++) { - tm = producerSession.createTextMessage(); - tm.setText("Hello " + i); - msgSent.add(tm.getText()); - producer.send(tm); - log.info("producer sent message: " + tm.getText()); - } - } - catch (JMSException e) { - e.printStackTrace(); - } - - log.info("Waiting for latch"); - latch.await(); - - assertEquals(1, msgRolledBack.size()); - assertEquals(1, msgRedelivered.size()); - - log.info("msg RolledBack = " + msgRolledBack.get(0)); - log.info("msg Redelivered = " + msgRedelivered.get(0)); - - assertEquals(msgRolledBack.get(0), msgRedelivered.get(0)); - - assertEquals(NUM_MESSAGES, msgSent.size()); - assertEquals(NUM_MESSAGES, msgCommitted.size()); - - assertEquals(msgSent, msgCommitted); - - } - - protected void tearDown() throws Exception { - if (connection != null) { - log.info("Closing the connection"); - connection.close(); - } - super.tearDown(); - } -} \ No newline at end of file diff --git a/assembly/src/test/java/org/apache/activemq/usecases/TransactionTest.java b/assembly/src/test/java/org/apache/activemq/usecases/TransactionTest.java deleted file mode 100755 index a54c000f8d..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/TransactionTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import java.util.Date; - -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.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - -import junit.framework.TestCase; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch; - -/** - * @author pragmasoft - * @version $Revision: 1.1.1.1 $ - */ -public final class TransactionTest extends TestCase { - - private static final Log log = LogFactory.getLog(TransactionTest.class); - - private volatile String receivedText; - - private Session producerSession; - private Session consumerSession; - private Destination queue; - - private MessageProducer producer; - private MessageConsumer consumer; - private Connection connection; - private CountDownLatch latch = new CountDownLatch(1); - - public void testTransaction() throws Exception { - - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost"); - connection = factory.createConnection(); - queue = new ActiveMQQueue(getClass().getName() + "." + getName()); - - producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - consumerSession = connection.createSession(true, 0); - - producer = producerSession.createProducer(queue); - - consumer = consumerSession.createConsumer(queue); - consumer.setMessageListener(new MessageListener() { - - public void onMessage(Message m) { - try { - TextMessage tm = (TextMessage) m; - receivedText = tm.getText(); - latch.countDown(); - - log.info("consumer received message :" + receivedText); - consumerSession.commit(); - log.info("committed transaction"); - } - catch (JMSException e) { - try { - consumerSession.rollback(); - log.info("rolled back transaction"); - } - catch (JMSException e1) { - log.info(e1); - e1.printStackTrace(); - } - log.info(e); - e.printStackTrace(); - } - } - }); - - connection.start(); - - TextMessage tm = null; - try { - tm = producerSession.createTextMessage(); - tm.setText("Hello, " + new Date()); - producer.send(tm); - log.info("producer sent message :" + tm.getText()); - } - catch (JMSException e) { - e.printStackTrace(); - } - - log.info("Waiting for latch"); - latch.await(); - - log.info("test completed, destination=" + receivedText); - } - - protected void tearDown() throws Exception { - if (connection != null) { - connection.close(); - } - super.tearDown(); - } -} \ No newline at end of file diff --git a/assembly/src/test/java/org/apache/activemq/usecases/TransientQueueRedeliverTest.java b/assembly/src/test/java/org/apache/activemq/usecases/TransientQueueRedeliverTest.java deleted file mode 100755 index cd8ff5bbb1..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/TransientQueueRedeliverTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import javax.jms.DeliveryMode; - - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class TransientQueueRedeliverTest extends TopicRedeliverTest { - - protected void setUp() throws Exception{ - super.setUp(); - topic = false; - deliveryMode = DeliveryMode.NON_PERSISTENT; - } - -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java b/assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java deleted file mode 100644 index 9756abdbad..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.TransportConnector; -import org.apache.activemq.network.DemandForwardingBridge; -import org.apache.activemq.transport.TransportFactory; -import org.apache.activemq.JmsMultipleBrokersTestSupport; -import org.apache.activemq.command.Command; -import org.apache.activemq.util.MessageIdList; - -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import java.util.List; -import java.util.ArrayList; -import java.net.URI; - -import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger; - -/** - * @version $Revision: 1.1.1.1 $ - */ -public class TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest extends JmsMultipleBrokersTestSupport { - protected static final int MESSAGE_COUNT = 10; - - protected List bridges; - protected AtomicInteger msgDispatchCount; - - /** - * BrokerA -> BrokerB - */ - public void testRemoteBrokerHasConsumer() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerA", "BrokerB"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", true); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - MessageConsumer clientB = createConsumer("BrokerB", dest); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); - - msgsA.waitForMessagesToArrive(MESSAGE_COUNT); - msgsB.waitForMessagesToArrive(MESSAGE_COUNT); - - assertEquals(MESSAGE_COUNT, msgsA.getMessageCount()); - assertEquals(MESSAGE_COUNT, msgsB.getMessageCount()); - - // Check that 10 message dispatch commands are send over the network - assertEquals(MESSAGE_COUNT, msgDispatchCount.get()); - } - - /** - * BrokerA -> BrokerB - */ - public void testRemoteBrokerHasNoConsumer() throws Exception { - // Setup broker networks - bridgeBrokers("BrokerA", "BrokerB"); - - startAllBrokers(); - - // Setup destination - Destination dest = createDestination("TEST.FOO", true); - - // Setup consumers - MessageConsumer clientA = createConsumer("BrokerA", dest); - - // Send messages - sendMessages("BrokerA", dest, MESSAGE_COUNT); - - // Get message count - MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); - - msgsA.waitForMessagesToArrive(MESSAGE_COUNT); - - assertEquals(MESSAGE_COUNT, msgsA.getMessageCount()); - - // Check that no message dispatch commands are send over the network - assertEquals(0, msgDispatchCount.get()); - } - - protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception { - List remoteTransports = remoteBroker.getTransportConnectors(); - List localTransports = localBroker.getTransportConnectors(); - - URI remoteURI, localURI; - if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) { - remoteURI = ((TransportConnector)remoteTransports.get(0)).getConnectUri(); - localURI = ((TransportConnector)localTransports.get(0)).getConnectUri(); - - // Ensure that we are connecting using tcp - if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) { - DemandForwardingBridge bridge = new DemandForwardingBridge(TransportFactory.connect(localURI), - TransportFactory.connect(remoteURI)) { - protected void serviceLocalCommand(Command command) { - if (command.isMessageDispatch()) { - // Keep track of the number of message dispatches through the bridge - msgDispatchCount.incrementAndGet(); - } - - super.serviceLocalCommand(command); - } - }; - bridge.setLocalBrokerName(localBroker.getBrokerName()); - bridges.add(bridge); - - bridge.start(); - } else { - throw new Exception("Remote broker or local broker is not using tcp connectors"); - } - } else { - throw new Exception("Remote broker or local broker has no registered connectors."); - } - - MAX_SETUP_TIME = 2000; - } - - public void setUp() throws Exception { - super.setAutoFail(true); - super.setUp(); - createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=false")); - createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=false")); - - bridges = new ArrayList(); - msgDispatchCount = new AtomicInteger(0); - } -} diff --git a/assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerMulticastQueueTest.java b/assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerMulticastQueueTest.java deleted file mode 100644 index 2401028e32..0000000000 --- a/assembly/src/test/java/org/apache/activemq/usecases/TwoBrokerMulticastQueueTest.java +++ /dev/null @@ -1,269 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * Licensed 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.activemq.usecases; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.CombinationTestSupport; -import org.apache.activemq.util.MessageIdList; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.xbean.XBeanBrokerFactory; - -import java.net.URI; -import java.util.Arrays; - -import junit.framework.Test; - -import javax.jms.Destination; -import javax.jms.ConnectionFactory; -import javax.jms.Connection; -import javax.jms.Session; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.TextMessage; - -public class TwoBrokerMulticastQueueTest extends CombinationTestSupport { - - public static Test suite() { - return suite(TwoBrokerMulticastQueueTest.class); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static final int MESSAGE_COUNT = 100; - public static final int BROKER_COUNT = 2; - public static final int CONSUMER_COUNT = 20; - - private BrokerService[] brokers; - public String sendUri, recvUri; - - public void setUp() throws Exception { - super.setAutoFail(true); - super.setUp(); - } - - public void tearDown() throws Exception { - for (int i=0; i 0) { - Thread.sleep(waitTime); - } else { - list.waitForMessagesToArrive(MESSAGE_COUNT); - } - - conn.close(); - - return list.getMessageCount(); - } - - protected void sendMessages(Connection conn, Destination dest, int count) throws JMSException { - conn.start(); - Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer prod = sess.createProducer(dest); - - for (int i=0; i|_yE zckq1;`86 z0{zwibw~M`AHUpNxJ_}@da-r?Bed2(Y~T9HB+%=iq@KF}f0dcK+KXNu>8n^aA?$|n z+joH*yf#l|VrFDuM0Or9nwWv^3OXgRzs_T0D9g-xZK - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/config/example.xml b/assembly/src/test/resources/org/apache/activemq/config/example.xml deleted file mode 100755 index f059f2562e..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/config/example.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ssl://localhost:61634 - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/config/spring-test.xml b/assembly/src/test/resources/org/apache/activemq/config/spring-test.xml deleted file mode 100755 index 624eb75e4e..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/config/spring-test.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - vm://localhost - - - - \ No newline at end of file diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/activemq.xml b/assembly/src/test/resources/org/apache/activemq/usecases/activemq.xml deleted file mode 100644 index 2420f74fcd..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/activemq.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-1.xml b/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-1.xml deleted file mode 100644 index 449f5e0e06..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-1.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-2.xml b/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-2.xml deleted file mode 100644 index 437764bf81..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-2.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-auto.xml b/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-auto.xml deleted file mode 100644 index cf67b30271..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/multicast-broker-auto.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/receiver-activecluster.xml b/assembly/src/test/resources/org/apache/activemq/usecases/receiver-activecluster.xml deleted file mode 100755 index 3805f82d1b..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/receiver-activecluster.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/receiver-discovery.xml b/assembly/src/test/resources/org/apache/activemq/usecases/receiver-discovery.xml deleted file mode 100644 index 209cb0ecf3..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/receiver-discovery.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/receiver-http.xml b/assembly/src/test/resources/org/apache/activemq/usecases/receiver-http.xml deleted file mode 100644 index 25adb6aafb..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/receiver-http.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml b/assembly/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml deleted file mode 100755 index 45e3830cc2..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/receiver.xml b/assembly/src/test/resources/org/apache/activemq/usecases/receiver.xml deleted file mode 100755 index af896a5754..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/receiver.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/sender-activecluster.xml b/assembly/src/test/resources/org/apache/activemq/usecases/sender-activecluster.xml deleted file mode 100755 index 614a9ad5b1..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/sender-activecluster.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/sender-discovery.xml b/assembly/src/test/resources/org/apache/activemq/usecases/sender-discovery.xml deleted file mode 100644 index 9e0fef1ec6..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/sender-discovery.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/sender-http.xml b/assembly/src/test/resources/org/apache/activemq/usecases/sender-http.xml deleted file mode 100644 index cc98615eb6..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/sender-http.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/sender-zeroconf.xml b/assembly/src/test/resources/org/apache/activemq/usecases/sender-zeroconf.xml deleted file mode 100755 index 21b49d3277..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/sender-zeroconf.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/org/apache/activemq/usecases/sender.xml b/assembly/src/test/resources/org/apache/activemq/usecases/sender.xml deleted file mode 100755 index d17e168cc7..0000000000 --- a/assembly/src/test/resources/org/apache/activemq/usecases/sender.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/assembly/src/test/resources/server.keystore b/assembly/src/test/resources/server.keystore deleted file mode 100644 index d9223d80a8c5fa04f74d1bb3a5dbd5f276b0588d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1352 zcmezO_TO6u1_mY|W&~r_+{*0KN+6H%)?C4_K$%?zO-$Pi_}I9#*%(FMm&j5sG8&3c>mxJ-N&=!PFfUy=YBTV?L5*%n`1$thICwE51<`Q;3W*JCt1QcfRJxXpZ|boa`L zt|*p=AN+Pz6f`-UaZb`**Am+#qa40yQe*gWf8z@EH9Nk)-u?B3l=8WRTU<@oTi0xl zvz3?hC{<6~86j~@L3_?=?}>-5R;V0I&d&e*OhoBV^^0>HCeOFM`+aT_ORI`qvLeUF z6Jh21*47ADXecd6jbXM{;n>xtbHqkyNtr|>$Ca$f`NmaO%Qx8`e^ZqHM>2NeLfg#L zjv&!ncY>I_MO7QxbNG%WyY}eSJy_7iA@|R@R^#fV=To){>Ps>(v8i&dsIGYNUQB%X z;nSj14^G~vy(lxHoPE*DRWmPII|WaXUUhzR_0;<-vlBJ{%}hVAPk(v)g&(nNwwx9Y z&xzT-C3M4`y6chs*}pV41Zyk*x@I?fao*dhW}8nOJA6EKkFKk#%^}a9*PIWoVh?y^ zasAc+8hyU?giI%Qjxff1}+*4l6JY4?qzw~|6BiAJV+d#~?VzNy@z=fA9%_$sBJA?d{l`j7-2p=WAf2~5Zyz=Z5# z(8RcwiN%R&`ve1CHcqWJkGAi;jEpR-3ld~g?!!FF^ z<7g;qAPiE*CCrnUT#{Lqnp>!sUz83L=0+11G7tc%W)|km$xlwq$;dA*F_07IH83?W zGB7qWHZe6ahyrs>4NRb1dOD?XK5{q!b2f8hFM~m2CsSi1!^Rnt$_|$w&A+HS-TvR{ zhPygtN!GSM(|7QF4f~jUwm|6n#wV#dlUpr|%9y_xNu87^nJJUb_2|3ap<7Q@W{H&j z^xyZ@^SHD7@&f(V0Ch+CnIFI0TewYe)q1gY|0A^4KWyLn$t2M0proF<|9_R4y4s6g z9_g!CHX-bW@!NNS8@x78WnyMzU_^EvFq)Ww?g~03vA@n^V<^kadTpt$kjp1S)k}W= zJf)!_P^=_-tyni9Rbu%ntI6Mc5`2z|xgUGm#bbZst=Za#O-ZXiUQ2!&6}DgNJmc@+ zMHf7qCn^i<^O${GK0Z%NplwZ}tzn0_%(b}tg8OZ}f4wrfl4>`@e#=8S*>Z-TcB(=L hd*8XL$DW*VWs{eP@