Repository: activemq-artemis Updated Branches: refs/heads/2.6.x cfd368681 -> 0cd3fac1e
ARTEMIS-2139 JMSReplyTo compatibility with old clients Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/0cd3fac1 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/0cd3fac1 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/0cd3fac1 Branch: refs/heads/2.6.x Commit: 0cd3fac1e25ce280bed15168b241764578a6b350 Parents: cfd3686 Author: Justin Bertram <jbert...@apache.org> Authored: Fri Nov 2 08:32:27 2018 -0500 Committer: Justin Bertram <jbert...@apache.org> Committed: Fri Nov 2 10:57:08 2018 -0500 ---------------------------------------------------------------------- .../jms/client/ActiveMQTemporaryTopic.java | 5 + .../core/ServerSessionPacketHandler.java | 9 +- .../jmsReplyToQueue/artemisServer.groovy | 53 ++++++++ .../jmsReplyToQueue/receiveMessages.groovy | 51 ++++++++ .../jmsReplyToQueue/sendMessagesAddress.groovy | 50 ++++++++ .../jmsReplyToTempQueue/artemisServer.groovy | 49 ++++++++ .../jmsReplyToTempQueue/receiveMessages.groovy | 51 ++++++++ .../sendMessagesAddress.groovy | 50 ++++++++ .../jmsReplyToTempTopic/artemisServer.groovy | 52 ++++++++ .../jmsReplyToTempTopic/receiveMessages.groovy | 51 ++++++++ .../sendMessagesAddress.groovy | 50 ++++++++ .../jmsReplyToTopic/artemisServer.groovy | 49 ++++++++ .../jmsReplyToTopic/receiveMessages.groovy | 51 ++++++++ .../jmsReplyToTopic/sendMessagesAddress.groovy | 50 ++++++++ .../compatibility/JmsReplyToQueueTest.java | 123 +++++++++++++++++++ .../compatibility/JmsReplyToTempQueueTest.java | 123 +++++++++++++++++++ .../compatibility/JmsReplyToTempTopicTest.java | 123 +++++++++++++++++++ .../compatibility/JmsReplyToTopicTest.java | 123 +++++++++++++++++++ .../integration/openwire/OpenWireTestBase.java | 1 - 19 files changed, 1112 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTemporaryTopic.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTemporaryTopic.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTemporaryTopic.java index 457663d..0fb4eb1 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTemporaryTopic.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTemporaryTopic.java @@ -40,6 +40,11 @@ public class ActiveMQTemporaryTopic extends ActiveMQTopic implements TemporaryTo // Public -------------------------------------------------------- @Override + public String toString() { + return "ActiveMQTemporaryTopic[" + getAddress() + "]"; + } + + @Override public boolean equals(final Object o) { if (this == o) { return true; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java index 37564b5..1fbc5e8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java @@ -349,7 +349,7 @@ public class ServerSessionPacketHandler implements ChannelHandler { case CREATE_QUEUE: { CreateQueueMessage request = (CreateQueueMessage) packet; requiresResponse = request.isRequiresResponse(); - session.createQueue(request.getAddress(), request.getQueueName(), RoutingType.MULTICAST, request.getFilterString(), request.isTemporary(), request.isDurable()); + session.createQueue(request.getAddress(), request.getQueueName(), getRoutingTypeFromAddress(request.getAddress()), request.getFilterString(), request.isTemporary(), request.isDurable()); if (requiresResponse) { response = new NullResponseMessage(); } @@ -633,6 +633,13 @@ public class ServerSessionPacketHandler implements ChannelHandler { } } + private RoutingType getRoutingTypeFromAddress(SimpleString address) { + if (address.startsWith(PacketImpl.OLD_QUEUE_PREFIX) || address.startsWith(PacketImpl.OLD_TEMP_QUEUE_PREFIX)) { + return RoutingType.ANYCAST; + } + return RoutingType.MULTICAST; + } + private void onSessionAcknowledge(Packet packet) { this.storageManager.setContext(session.getSessionContext()); try { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/artemisServer.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/artemisServer.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/artemisServer.groovy new file mode 100644 index 0000000..444eaf1 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/artemisServer.groovy @@ -0,0 +1,53 @@ +package jmsReplyToQueue + +import org.apache.activemq.artemis.api.core.RoutingType +import org.apache.activemq.artemis.api.core.SimpleString +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl +import org.apache.activemq.artemis.core.server.JournalType + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// starts an artemis server +import org.apache.activemq.artemis.core.server.impl.AddressInfo +import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl +import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS + +String folder = arg[0]; +String queueAddress = "jms.queue.myQueue"; +String replyQueueAddress = "jms.queue.myReplyQueue"; + +configuration = new ConfigurationImpl(); +configuration.setJournalType(JournalType.NIO); +configuration.setBrokerInstance(new File(folder + "/server")); +configuration.addAcceptorConfiguration("artemis", "tcp://0.0.0.0:61616"); +configuration.setSecurityEnabled(false); +configuration.setPersistenceEnabled(false); + + +jmsConfiguration = new JMSConfigurationImpl(); + +server = new EmbeddedJMS(); +server.setConfiguration(configuration); +server.setJmsConfiguration(jmsConfiguration); +server.start(); + +server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(queueAddress), RoutingType.ANYCAST)); +server.getActiveMQServer().createQueue(SimpleString.toSimpleString(queueAddress), RoutingType.ANYCAST, SimpleString.toSimpleString(queueAddress), null, true, false); + +server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(replyQueueAddress), RoutingType.ANYCAST)); +server.getActiveMQServer().createQueue(SimpleString.toSimpleString(replyQueueAddress), RoutingType.ANYCAST, SimpleString.toSimpleString(replyQueueAddress), null, true, false); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/receiveMessages.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/receiveMessages.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/receiveMessages.groovy new file mode 100644 index 0000000..0cd5853 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/receiveMessages.groovy @@ -0,0 +1,51 @@ +package jmsReplyToQueue + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ConnectionFactory cf = new ActiveMQConnectionFactory(); +((ActiveMQConnectionFactory)cf).setEnable1xPrefixes(true); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +Queue myQueue = session.createQueue("myQueue"); +MessageConsumer queueConsumer = session.createConsumer(myQueue); +consumerCreated.countDown(); +connection.start() + +Message message = queueConsumer.receive(5000); +GroovyRun.assertNotNull(message) +session.commit(); +System.out.println("Received " + message + " from: " + myQueue); +queueConsumer.close(); + +System.out.println("Sending message to: " + message.getJMSReplyTo()); +MessageProducer producer = session.createProducer(message.getJMSReplyTo()); +message = session.createMessage(); +producer.send(message); +session.commit(); + +connection.close(); + +latch.countDown(); + + + http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/sendMessagesAddress.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/sendMessagesAddress.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/sendMessagesAddress.groovy new file mode 100644 index 0000000..597aa07 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToQueue/sendMessagesAddress.groovy @@ -0,0 +1,50 @@ +package jmsReplyToQueue + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ConnectionFactory cf = new ActiveMQConnectionFactory(); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +connection.start(); + +Queue myQueue = session.createQueue("myQueue"); +Queue temporaryQueue = session.createQueue("myTemporaryQueue"); + +MessageProducer queueProducer = session.createProducer(myQueue) + +queueProducer.setDeliveryMode(DeliveryMode.PERSISTENT); +Message message = session.createMessage(); +message.setJMSReplyTo(temporaryQueue); +System.out.println("Sending " + message + " to: " + myQueue); +queueProducer.send(message); +session.commit(); + +System.out.println("Receiving message from: " + temporaryQueue); +MessageConsumer consumer = session.createConsumer(temporaryQueue); +message = consumer.receive(10000); +GroovyRun.assertNotNull(message); +session.commit(); +System.out.println("Received message: " + message); + +connection.close(); +senderLatch.countDown(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/artemisServer.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/artemisServer.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/artemisServer.groovy new file mode 100644 index 0000000..2b06830 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/artemisServer.groovy @@ -0,0 +1,49 @@ +package jmsReplyToTempQueue + +import org.apache.activemq.artemis.api.core.RoutingType +import org.apache.activemq.artemis.api.core.SimpleString +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl +import org.apache.activemq.artemis.core.server.JournalType + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// starts an artemis server +import org.apache.activemq.artemis.core.server.impl.AddressInfo +import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl +import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS + +String folder = arg[0]; +String queueAddress = "jms.queue.myQueue"; + +configuration = new ConfigurationImpl(); +configuration.setJournalType(JournalType.NIO); +configuration.setBrokerInstance(new File(folder + "/server")); +configuration.addAcceptorConfiguration("artemis", "tcp://0.0.0.0:61616"); +configuration.setSecurityEnabled(false); +configuration.setPersistenceEnabled(false); + + +jmsConfiguration = new JMSConfigurationImpl(); + +server = new EmbeddedJMS(); +server.setConfiguration(configuration); +server.setJmsConfiguration(jmsConfiguration); +server.start(); + +server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(queueAddress), RoutingType.ANYCAST)); +server.getActiveMQServer().createQueue(SimpleString.toSimpleString(queueAddress), RoutingType.ANYCAST, SimpleString.toSimpleString(queueAddress), null, true, false); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/receiveMessages.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/receiveMessages.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/receiveMessages.groovy new file mode 100644 index 0000000..9ee6104 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/receiveMessages.groovy @@ -0,0 +1,51 @@ +package jmsReplyToTempQueue + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ConnectionFactory cf = new ActiveMQConnectionFactory(); +((ActiveMQConnectionFactory)cf).setEnable1xPrefixes(true); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +Queue myQueue = session.createQueue("myQueue"); +MessageConsumer queueConsumer = session.createConsumer(myQueue); +consumerCreated.countDown(); +connection.start() + +Message message = queueConsumer.receive(5000); +GroovyRun.assertNotNull(message) +session.commit(); +System.out.println("Received " + message + " from: " + myQueue); +queueConsumer.close(); + +System.out.println("Sending message to: " + message.getJMSReplyTo()); +MessageProducer producer = session.createProducer(message.getJMSReplyTo()); +message = session.createMessage(); +producer.send(message); +session.commit(); + +connection.close(); + +latch.countDown(); + + + http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/sendMessagesAddress.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/sendMessagesAddress.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/sendMessagesAddress.groovy new file mode 100644 index 0000000..0793b0e --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTempQueue/sendMessagesAddress.groovy @@ -0,0 +1,50 @@ +package jmsReplyToTempQueue + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ConnectionFactory cf = new ActiveMQConnectionFactory(); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +connection.start(); + +Queue myQueue = session.createQueue("myQueue"); +Queue temporaryQueue = session.createTemporaryQueue(); + +MessageProducer queueProducer = session.createProducer(myQueue) + +queueProducer.setDeliveryMode(DeliveryMode.PERSISTENT); +Message message = session.createMessage(); +message.setJMSReplyTo(temporaryQueue); +System.out.println("Sending " + message + " to: " + myQueue); +queueProducer.send(message); +session.commit(); + +System.out.println("Receiving message from: " + temporaryQueue); +MessageConsumer consumer = session.createConsumer(temporaryQueue); +message = consumer.receive(10000); +GroovyRun.assertNotNull(message); +session.commit(); +System.out.println("Received message: " + message); + +connection.close(); +senderLatch.countDown(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/artemisServer.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/artemisServer.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/artemisServer.groovy new file mode 100644 index 0000000..9e85473 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/artemisServer.groovy @@ -0,0 +1,52 @@ +package jmsReplyToTempTopic + +import org.apache.activemq.artemis.api.core.RoutingType +import org.apache.activemq.artemis.api.core.SimpleString +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl +import org.apache.activemq.artemis.core.server.JournalType + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// starts an artemis server +import org.apache.activemq.artemis.core.server.impl.AddressInfo +import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl +import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS + +String folder = arg[0]; +String queueAddress = "jms.queue.myQueue"; +String replyTopicAddress = "jms.topic.myReplyTopic"; + +configuration = new ConfigurationImpl(); +configuration.setJournalType(JournalType.NIO); +configuration.setBrokerInstance(new File(folder + "/server")); +configuration.addAcceptorConfiguration("artemis", "tcp://0.0.0.0:61616"); +configuration.setSecurityEnabled(false); +configuration.setPersistenceEnabled(false); + + +jmsConfiguration = new JMSConfigurationImpl(); + +server = new EmbeddedJMS(); +server.setConfiguration(configuration); +server.setJmsConfiguration(jmsConfiguration); +server.start(); + +server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(queueAddress), RoutingType.ANYCAST)); +server.getActiveMQServer().createQueue(SimpleString.toSimpleString(queueAddress), RoutingType.ANYCAST, SimpleString.toSimpleString(queueAddress), null, true, false); + +server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(replyTopicAddress), RoutingType.MULTICAST)); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/receiveMessages.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/receiveMessages.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/receiveMessages.groovy new file mode 100644 index 0000000..00ec4c8 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/receiveMessages.groovy @@ -0,0 +1,51 @@ +package jmsReplyToTempTopic + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ConnectionFactory cf = new ActiveMQConnectionFactory(); +((ActiveMQConnectionFactory)cf).setEnable1xPrefixes(true); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +Queue myQueue = session.createQueue("myQueue"); +MessageConsumer queueConsumer = session.createConsumer(myQueue); +consumerCreated.countDown(); +connection.start() + +Message message = queueConsumer.receive(5000); +GroovyRun.assertNotNull(message) +session.commit(); +System.out.println("Received " + message + " from: " + myQueue); +queueConsumer.close(); + +System.out.println("Sending message to: " + message.getJMSReplyTo()); +MessageProducer producer = session.createProducer(message.getJMSReplyTo()); +message = session.createMessage(); +producer.send(message); +session.commit(); + +connection.close(); + +latch.countDown(); + + + http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/sendMessagesAddress.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/sendMessagesAddress.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/sendMessagesAddress.groovy new file mode 100644 index 0000000..02a57b2 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTempTopic/sendMessagesAddress.groovy @@ -0,0 +1,50 @@ +package jmsReplyToTempTopic + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ConnectionFactory cf = new ActiveMQConnectionFactory(); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +connection.start(); + +Queue myQueue = session.createQueue("myQueue"); +TemporaryTopic replyTopic = session.createTemporaryTopic(); + +MessageProducer queueProducer = session.createProducer(myQueue) + +queueProducer.setDeliveryMode(DeliveryMode.PERSISTENT); +Message message = session.createMessage(); +message.setJMSReplyTo(replyTopic); +System.out.println("Sending " + message + " to: " + myQueue); +queueProducer.send(message); +session.commit(); + +System.out.println("Receiving message from: " + replyTopic); +MessageConsumer consumer = session.createConsumer(replyTopic); +message = consumer.receive(10000); +GroovyRun.assertNotNull(message); +session.commit(); +System.out.println("Received message: " + message); + +connection.close(); +senderLatch.countDown(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/artemisServer.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/artemisServer.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/artemisServer.groovy new file mode 100644 index 0000000..37a6aa0 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/artemisServer.groovy @@ -0,0 +1,49 @@ +package jmsReplyToTopic + +import org.apache.activemq.artemis.api.core.RoutingType +import org.apache.activemq.artemis.api.core.SimpleString +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl +import org.apache.activemq.artemis.core.server.JournalType + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// starts an artemis server +import org.apache.activemq.artemis.core.server.impl.AddressInfo +import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl +import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS + +String folder = arg[0]; +String queueAddress = "jms.queue.myQueue"; + +configuration = new ConfigurationImpl(); +configuration.setJournalType(JournalType.NIO); +configuration.setBrokerInstance(new File(folder + "/server")); +configuration.addAcceptorConfiguration("artemis", "tcp://0.0.0.0:61616"); +configuration.setSecurityEnabled(false); +configuration.setPersistenceEnabled(false); + + +jmsConfiguration = new JMSConfigurationImpl(); + +server = new EmbeddedJMS(); +server.setConfiguration(configuration); +server.setJmsConfiguration(jmsConfiguration); +server.start(); + +server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(queueAddress), RoutingType.ANYCAST)); +server.getActiveMQServer().createQueue(SimpleString.toSimpleString(queueAddress), RoutingType.ANYCAST, SimpleString.toSimpleString(queueAddress), null, true, false); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/receiveMessages.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/receiveMessages.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/receiveMessages.groovy new file mode 100644 index 0000000..c7058e6 --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/receiveMessages.groovy @@ -0,0 +1,51 @@ +package jmsReplyToTopic + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ConnectionFactory cf = new ActiveMQConnectionFactory(); +((ActiveMQConnectionFactory)cf).setEnable1xPrefixes(true); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +Queue myQueue = session.createQueue("myQueue"); +MessageConsumer queueConsumer = session.createConsumer(myQueue); +consumerCreated.countDown(); +connection.start() + +Message message = queueConsumer.receive(5000); +GroovyRun.assertNotNull(message) +session.commit(); +System.out.println("Received " + message + " from: " + myQueue); +queueConsumer.close(); + +System.out.println("Sending message to: " + message.getJMSReplyTo()); +MessageProducer producer = session.createProducer(message.getJMSReplyTo()); +message = session.createMessage(); +producer.send(message); +session.commit(); + +connection.close(); + +latch.countDown(); + + + http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/sendMessagesAddress.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/sendMessagesAddress.groovy b/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/sendMessagesAddress.groovy new file mode 100644 index 0000000..b5e3d2b --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/jmsReplyToTopic/sendMessagesAddress.groovy @@ -0,0 +1,50 @@ +package jmsReplyToTopic + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ConnectionFactory cf = new ActiveMQConnectionFactory(); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +connection.start(); + +Queue myQueue = session.createQueue("myQueue"); +Topic replyTopic = session.createTopic("myReplyTopic"); + +MessageProducer queueProducer = session.createProducer(myQueue) + +queueProducer.setDeliveryMode(DeliveryMode.PERSISTENT); +Message message = session.createMessage(); +message.setJMSReplyTo(replyTopic); +System.out.println("Sending " + message + " to: " + myQueue); +queueProducer.send(message); +session.commit(); + +System.out.println("Receiving message from: " + replyTopic); +MessageConsumer consumer = session.createConsumer(replyTopic); +message = consumer.receive(10000); +GroovyRun.assertNotNull(message); +session.commit(); +System.out.println("Received message: " + message); + +connection.close(); +senderLatch.countDown(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToQueueTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToQueueTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToQueueTest.java new file mode 100644 index 0000000..b1ff3a3 --- /dev/null +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToQueueTest.java @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.artemis.tests.compatibility; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; +import org.apache.activemq.artemis.utils.FileUtil; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; + +@RunWith(Parameterized.class) +public class JmsReplyToQueueTest extends VersionedBase { + + @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}") + public static Collection getParameters() { + List<Object[]> combinations = new ArrayList<>(); + combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, SNAPSHOT}); + return combinations; + } + + public JmsReplyToQueueTest(String server, String sender, String receiver) throws Exception { + super(server, sender, receiver); + } + + + @Before + public void setUp() throws Throwable { + FileUtil.deleteDirectory(serverFolder.getRoot()); + } + + @After + public void stopTest() throws Exception { + execute(serverClassloader, "server.stop()"); + } + + @Test + public void testJmsReplyToQueue() throws Throwable { + evaluate(serverClassloader, "jmsReplyToQueue/artemisServer.groovy", serverFolder.getRoot().getAbsolutePath(), server); + + CountDownLatch consumerCreated = new CountDownLatch(1); + CountDownLatch receiverLatch = new CountDownLatch(1); + CountDownLatch senderLatch = new CountDownLatch(1); + + setVariable(receiverClassloader, "latch", receiverLatch); + setVariable(receiverClassloader, "consumerCreated", consumerCreated); + + AtomicInteger errors = new AtomicInteger(0); + Thread t1 = new Thread() { + @Override + public void run() { + try { + evaluate(receiverClassloader, "jmsReplyToQueue/receiveMessages.groovy", receiver); + } catch (Throwable e) { + e.printStackTrace(); + errors.incrementAndGet(); + } + } + }; + t1.start(); + + Assert.assertTrue(consumerCreated.await(10, TimeUnit.SECONDS)); + + setVariable(senderClassloader, "senderLatch", senderLatch); + Thread t2 = new Thread() { + @Override + public void run() { + try { + evaluate(senderClassloader, "jmsReplyToQueue/sendMessagesAddress.groovy", sender); + } catch (Throwable e) { + e.printStackTrace(); + errors.incrementAndGet(); + } + } + }; + t2.start(); + + try { + Assert.assertTrue("Sender did not get message from queue", senderLatch.await(10, TimeUnit.SECONDS)); + Assert.assertTrue("Receiver did not receive messages", receiverLatch.await(10, TimeUnit.SECONDS)); + } finally { + + t1.join(TimeUnit.SECONDS.toMillis(1)); + t2.join(TimeUnit.SECONDS.toMillis(1)); + + if (t1.isAlive()) { + t1.interrupt(); + } + + if (t2.isAlive()) { + t2.interrupt(); + } + } + + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTempQueueTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTempQueueTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTempQueueTest.java new file mode 100644 index 0000000..a7231dd --- /dev/null +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTempQueueTest.java @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.artemis.tests.compatibility; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; +import org.apache.activemq.artemis.utils.FileUtil; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; + +@RunWith(Parameterized.class) +public class JmsReplyToTempQueueTest extends VersionedBase { + + @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}") + public static Collection getParameters() { + List<Object[]> combinations = new ArrayList<>(); + combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, SNAPSHOT}); + return combinations; + } + + public JmsReplyToTempQueueTest(String server, String sender, String receiver) throws Exception { + super(server, sender, receiver); + } + + + @Before + public void setUp() throws Throwable { + FileUtil.deleteDirectory(serverFolder.getRoot()); + } + + @After + public void stopTest() throws Exception { + execute(serverClassloader, "server.stop()"); + } + + @Test + public void testJmsReplyToTempQueue() throws Throwable { + evaluate(serverClassloader, "jmsReplyToTempQueue/artemisServer.groovy", serverFolder.getRoot().getAbsolutePath(), server); + + CountDownLatch consumerCreated = new CountDownLatch(1); + CountDownLatch receiverLatch = new CountDownLatch(1); + CountDownLatch senderLatch = new CountDownLatch(1); + + setVariable(receiverClassloader, "latch", receiverLatch); + setVariable(receiverClassloader, "consumerCreated", consumerCreated); + + AtomicInteger errors = new AtomicInteger(0); + Thread t1 = new Thread() { + @Override + public void run() { + try { + evaluate(receiverClassloader, "jmsReplyToTempQueue/receiveMessages.groovy", receiver); + } catch (Throwable e) { + e.printStackTrace(); + errors.incrementAndGet(); + } + } + }; + t1.start(); + + Assert.assertTrue(consumerCreated.await(10, TimeUnit.SECONDS)); + + setVariable(senderClassloader, "senderLatch", senderLatch); + Thread t2 = new Thread() { + @Override + public void run() { + try { + evaluate(senderClassloader, "jmsReplyToTempQueue/sendMessagesAddress.groovy", sender); + } catch (Throwable e) { + e.printStackTrace(); + errors.incrementAndGet(); + } + } + }; + t2.start(); + + try { + Assert.assertTrue("Sender did not get message from temporary queue", senderLatch.await(10, TimeUnit.SECONDS)); + Assert.assertTrue("Receiver did not receive messages", receiverLatch.await(10, TimeUnit.SECONDS)); + } finally { + + t1.join(TimeUnit.SECONDS.toMillis(1)); + t2.join(TimeUnit.SECONDS.toMillis(1)); + + if (t1.isAlive()) { + t1.interrupt(); + } + + if (t2.isAlive()) { + t2.interrupt(); + } + } + + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTempTopicTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTempTopicTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTempTopicTest.java new file mode 100644 index 0000000..e175e61 --- /dev/null +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTempTopicTest.java @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.artemis.tests.compatibility; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; +import org.apache.activemq.artemis.utils.FileUtil; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; + +@RunWith(Parameterized.class) +public class JmsReplyToTempTopicTest extends VersionedBase { + + @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}") + public static Collection getParameters() { + List<Object[]> combinations = new ArrayList<>(); + combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, SNAPSHOT}); + return combinations; + } + + public JmsReplyToTempTopicTest(String server, String sender, String receiver) throws Exception { + super(server, sender, receiver); + } + + + @Before + public void setUp() throws Throwable { + FileUtil.deleteDirectory(serverFolder.getRoot()); + } + + @After + public void stopTest() throws Exception { + execute(serverClassloader, "server.stop()"); + } + + @Test + public void testJmsReplyToTempTopic() throws Throwable { + evaluate(serverClassloader, "jmsReplyToTempTopic/artemisServer.groovy", serverFolder.getRoot().getAbsolutePath(), server); + + CountDownLatch consumerCreated = new CountDownLatch(1); + CountDownLatch receiverLatch = new CountDownLatch(1); + CountDownLatch senderLatch = new CountDownLatch(1); + + setVariable(receiverClassloader, "latch", receiverLatch); + setVariable(receiverClassloader, "consumerCreated", consumerCreated); + + AtomicInteger errors = new AtomicInteger(0); + Thread t1 = new Thread() { + @Override + public void run() { + try { + evaluate(receiverClassloader, "jmsReplyToTempTopic/receiveMessages.groovy", receiver); + } catch (Throwable e) { + e.printStackTrace(); + errors.incrementAndGet(); + } + } + }; + t1.start(); + + Assert.assertTrue(consumerCreated.await(10, TimeUnit.SECONDS)); + + setVariable(senderClassloader, "senderLatch", senderLatch); + Thread t2 = new Thread() { + @Override + public void run() { + try { + evaluate(senderClassloader, "jmsReplyToTempTopic/sendMessagesAddress.groovy", sender); + } catch (Throwable e) { + e.printStackTrace(); + errors.incrementAndGet(); + } + } + }; + t2.start(); + + try { + Assert.assertTrue("Sender did not get message from temporary topic", senderLatch.await(10, TimeUnit.SECONDS)); + Assert.assertTrue("Receiver did not receive messages", receiverLatch.await(10, TimeUnit.SECONDS)); + } finally { + + t1.join(TimeUnit.SECONDS.toMillis(1)); + t2.join(TimeUnit.SECONDS.toMillis(1)); + + if (t1.isAlive()) { + t1.interrupt(); + } + + if (t2.isAlive()) { + t2.interrupt(); + } + } + + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTopicTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTopicTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTopicTest.java new file mode 100644 index 0000000..7ba53db --- /dev/null +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JmsReplyToTopicTest.java @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.artemis.tests.compatibility; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; +import org.apache.activemq.artemis.utils.FileUtil; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; + +@RunWith(Parameterized.class) +public class JmsReplyToTopicTest extends VersionedBase { + + @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}") + public static Collection getParameters() { + List<Object[]> combinations = new ArrayList<>(); + combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, SNAPSHOT}); + return combinations; + } + + public JmsReplyToTopicTest(String server, String sender, String receiver) throws Exception { + super(server, sender, receiver); + } + + + @Before + public void setUp() throws Throwable { + FileUtil.deleteDirectory(serverFolder.getRoot()); + } + + @After + public void stopTest() throws Exception { + execute(serverClassloader, "server.stop()"); + } + + @Test + public void testJmsReplyToTopic() throws Throwable { + evaluate(serverClassloader, "jmsReplyToTopic/artemisServer.groovy", serverFolder.getRoot().getAbsolutePath(), server); + + CountDownLatch consumerCreated = new CountDownLatch(1); + CountDownLatch receiverLatch = new CountDownLatch(1); + CountDownLatch senderLatch = new CountDownLatch(1); + + setVariable(receiverClassloader, "latch", receiverLatch); + setVariable(receiverClassloader, "consumerCreated", consumerCreated); + + AtomicInteger errors = new AtomicInteger(0); + Thread t1 = new Thread() { + @Override + public void run() { + try { + evaluate(receiverClassloader, "jmsReplyToTopic/receiveMessages.groovy", receiver); + } catch (Throwable e) { + e.printStackTrace(); + errors.incrementAndGet(); + } + } + }; + t1.start(); + + Assert.assertTrue(consumerCreated.await(10, TimeUnit.SECONDS)); + + setVariable(senderClassloader, "senderLatch", senderLatch); + Thread t2 = new Thread() { + @Override + public void run() { + try { + evaluate(senderClassloader, "jmsReplyToTopic/sendMessagesAddress.groovy", sender); + } catch (Throwable e) { + e.printStackTrace(); + errors.incrementAndGet(); + } + } + }; + t2.start(); + + try { + Assert.assertTrue("Sender did not get message from topic", senderLatch.await(10, TimeUnit.SECONDS)); + Assert.assertTrue("Receiver did not receive messages", receiverLatch.await(10, TimeUnit.SECONDS)); + } finally { + + t1.join(TimeUnit.SECONDS.toMillis(1)); + t2.join(TimeUnit.SECONDS.toMillis(1)); + + if (t1.isAlive()) { + t1.interrupt(); + } + + if (t2.isAlive()) { + t2.interrupt(); + } + } + + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0cd3fac1/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java index 8aaa17e..ae95c87 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java @@ -21,7 +21,6 @@ import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import java.util.ArrayList; import java.util.HashSet; -import java.util.Map; import java.util.List; import java.util.Set;