Repository: qpid-broker-j Updated Branches: refs/heads/master 4542234d5 -> a2e57db7c
QPID-6933: [System Tests] Refactor AMQP 1-0 JMS routing tests as JMS 1.1 system test Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/61389ed5 Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/61389ed5 Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/61389ed5 Branch: refs/heads/master Commit: 61389ed54cf1dca3548d4ad2c9450b6232db248a Parents: 4542234 Author: Alex Rudyy <[email protected]> Authored: Fri Jan 5 00:13:49 2018 +0000 Committer: Alex Rudyy <[email protected]> Committed: Fri Jan 5 00:13:49 2018 +0000 ---------------------------------------------------------------------- .../extensions/routing/MessageRoutingTest.java | 299 +++++++++++++++++++ .../apache/qpid/systest/MessageRoutingTest.java | 186 ------------ test-profiles/CPPExcludes | 2 - test-profiles/Java010Excludes | 2 - test-profiles/JavaPre010Excludes | 3 - 5 files changed, 299 insertions(+), 193 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/61389ed5/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/routing/MessageRoutingTest.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/routing/MessageRoutingTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/routing/MessageRoutingTest.java new file mode 100644 index 0000000..db6b61e --- /dev/null +++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/routing/MessageRoutingTest.java @@ -0,0 +1,299 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.systests.jms_1_1.extensions.routing; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assume.assumeThat; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import javax.jms.Connection; +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 org.junit.Test; + +import org.apache.qpid.server.model.Exchange; +import org.apache.qpid.server.model.Protocol; +import org.apache.qpid.systests.JmsTestBase; + +public class MessageRoutingTest extends JmsTestBase +{ + private static final String EXCHANGE_NAME = "testExchange"; + private static final String QUEUE_NAME = "testQueue"; + private static final String ROUTING_KEY = "testRoute"; + + @Test + public void testRoutingWithSubjectSetAsJMSMessageType() throws Exception + { + assumeThat("AMQP 1.0 test", getProtocol(), is(equalTo(Protocol.AMQP_1_0))); + + prepare(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination sendingDestination = session.createTopic(EXCHANGE_NAME); + Destination receivingDestination = session.createQueue(QUEUE_NAME); + + Message message = session.createTextMessage("test"); + message.setJMSType(ROUTING_KEY); + + MessageProducer messageProducer = session.createProducer(sendingDestination); + messageProducer.send(message); + + MessageConsumer messageConsumer = session.createConsumer(receivingDestination); + Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); + + assertNotNull("Message not received", receivedMessage); + assertEquals("test", ((TextMessage) message).getText()); + } + finally + { + connection.close(); + } + } + + + + @Test + public void testAnonymousRelayRoutingWithSubjectSetAsJMSMessageType() throws Exception + { + assumeThat("AMQP 1.0 test", getProtocol(), is(equalTo(Protocol.AMQP_1_0))); + + prepare(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Destination sendingDestination = session.createTopic(EXCHANGE_NAME); + Destination receivingDestination = session.createQueue(QUEUE_NAME); + + Message message = session.createTextMessage("test"); + message.setJMSType(ROUTING_KEY); + + MessageProducer messageProducer = session.createProducer(null); + messageProducer.send(sendingDestination, message); + + MessageConsumer messageConsumer = session.createConsumer(receivingDestination); + Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); + + assertNotNull("Message not received", receivedMessage); + assertEquals("test", ((TextMessage) message).getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testRoutingWithRoutingKeySetAsJMSProperty() throws Exception + { + assumeThat("AMQP 1.0 test", getProtocol(), is(equalTo(Protocol.AMQP_1_0))); + + prepare(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination sendingDestination = session.createTopic(EXCHANGE_NAME); + Destination receivingDestination = session.createQueue(QUEUE_NAME); + + Message message = session.createTextMessage("test"); + message.setStringProperty("routing_key", ROUTING_KEY); + + MessageProducer messageProducer = session.createProducer(sendingDestination); + messageProducer.send(message); + + MessageConsumer messageConsumer = session.createConsumer(receivingDestination); + Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); + + assertNotNull("Message not received", receivedMessage); + assertEquals("test", ((TextMessage) message).getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testRoutingWithExchangeAndRoutingKeyDestination() throws Exception + { + assumeThat("AMQP 1.0 test", getProtocol(), is(equalTo(Protocol.AMQP_1_0))); + + prepare(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination sendingDestination = session.createTopic(EXCHANGE_NAME + "/" + ROUTING_KEY); + Destination receivingDestination = session.createQueue(QUEUE_NAME); + + Message message = session.createTextMessage("test"); + + MessageProducer messageProducer = session.createProducer(sendingDestination); + messageProducer.send(message); + + MessageConsumer messageConsumer = session.createConsumer(receivingDestination); + Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); + + assertNotNull("Message not received", receivedMessage); + assertEquals("test", ((TextMessage) message).getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testAnonymousRelayRoutingWithExchangeAndRoutingKeyDestination() throws Exception + { + assumeThat("AMQP 1.0 test", getProtocol(), is(equalTo(Protocol.AMQP_1_0))); + + prepare(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination sendingDestination = session.createTopic(EXCHANGE_NAME + "/" + ROUTING_KEY); + Destination receivingDestination = session.createQueue(QUEUE_NAME); + + Message message = session.createTextMessage("test"); + + MessageProducer messageProducer = session.createProducer(null); + messageProducer.send(sendingDestination, message); + + MessageConsumer messageConsumer = session.createConsumer(receivingDestination); + Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); + + assertNotNull("Message not received", receivedMessage); + assertEquals("test", ((TextMessage) message).getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testRoutingToQueue() throws Exception + { + assumeThat("AMQP 1.0 test", getProtocol(), is(equalTo(Protocol.AMQP_1_0))); + + prepare(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination sendingDestination = session.createQueue(QUEUE_NAME); + Destination receivingDestination = session.createQueue(QUEUE_NAME); + + Message message = session.createTextMessage("test"); + + MessageProducer messageProducer = session.createProducer(sendingDestination); + messageProducer.send(message); + + MessageConsumer messageConsumer = session.createConsumer(receivingDestination); + Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); + + assertNotNull("Message not received", receivedMessage); + assertEquals("test", ((TextMessage) message).getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testAnonymousRelayRoutingToQueue() throws Exception + { + assumeThat("AMQP 1.0 test", getProtocol(), is(equalTo(Protocol.AMQP_1_0))); + + prepare(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination sendingDestination = session.createQueue(QUEUE_NAME); + Destination receivingDestination = session.createQueue(QUEUE_NAME); + + Message message = session.createTextMessage("test"); + + MessageProducer messageProducer = session.createProducer(null); + messageProducer.send(sendingDestination, message); + + MessageConsumer messageConsumer = session.createConsumer(receivingDestination); + Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); + + assertNotNull("Message not received", receivedMessage); + assertEquals("test", ((TextMessage) message).getText()); + } + finally + { + connection.close(); + } + } + + private void prepare() throws Exception + { + createEntityUsingAmqpManagement(EXCHANGE_NAME, "org.apache.qpid.DirectExchange", + Collections.singletonMap(Exchange.UNROUTABLE_MESSAGE_BEHAVIOUR, "REJECT")); + createEntityUsingAmqpManagement(QUEUE_NAME, "org.apache.qpid.Queue", Collections.emptyMap()); + + final Map<String, Object> arguments = new HashMap<>(); + arguments.put("destination", QUEUE_NAME); + arguments.put("bindingKey", ROUTING_KEY); + performOperationUsingAmqpManagement(EXCHANGE_NAME, "bind", "org.apache.qpid.Exchange", arguments); + } +} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/61389ed5/systests/src/test/java/org/apache/qpid/systest/MessageRoutingTest.java ---------------------------------------------------------------------- diff --git a/systests/src/test/java/org/apache/qpid/systest/MessageRoutingTest.java b/systests/src/test/java/org/apache/qpid/systest/MessageRoutingTest.java deleted file mode 100644 index f2f6b4a..0000000 --- a/systests/src/test/java/org/apache/qpid/systest/MessageRoutingTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.systest; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import javax.jms.Connection; -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 org.apache.qpid.server.model.Exchange; -import org.apache.qpid.test.utils.QpidBrokerTestCase; - -public class MessageRoutingTest extends QpidBrokerTestCase -{ - private static final String EXCHANGE_NAME = "testExchange"; - private static final String QUEUE_NAME = "testQueue"; - private static final String ROUTING_KEY = "testRoute"; - private Connection _connection; - private Session _session; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - _connection = getConnectionBuilder().build(); - _connection.start(); - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - createEntityUsingAmqpManagement(EXCHANGE_NAME, _session, "org.apache.qpid.DirectExchange", - Collections.singletonMap(Exchange.UNROUTABLE_MESSAGE_BEHAVIOUR, "REJECT")); - createEntityUsingAmqpManagement(QUEUE_NAME, _session, "org.apache.qpid.Queue"); - - final Map<String, Object> arguments = new HashMap<>(); - arguments.put("destination", QUEUE_NAME); - arguments.put("bindingKey", ROUTING_KEY); - performOperationUsingAmqpManagement(EXCHANGE_NAME, "bind", _connection.createSession(false, Session.AUTO_ACKNOWLEDGE), "org.apache.qpid.Exchange", - arguments); - } - - public void testRoutingWithSubjectSetAsJMSMessageType() throws Exception - { - Destination sendingDestination = _session.createTopic(EXCHANGE_NAME); - Destination receivingDestination = _session.createQueue(QUEUE_NAME); - - Message message = _session.createTextMessage("test"); - message.setJMSType(ROUTING_KEY); - - MessageProducer messageProducer = _session.createProducer(sendingDestination); - messageProducer.send(message); - - MessageConsumer messageConsumer = _session.createConsumer(receivingDestination); - Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); - - assertNotNull("Message not received", receivedMessage); - assertEquals("test", ((TextMessage)message).getText()); - } - - public void testAnonymousRelayRoutingWithSubjectSetAsJMSMessageType() throws Exception - { - Destination sendingDestination = _session.createTopic(EXCHANGE_NAME); - Destination receivingDestination = _session.createQueue(QUEUE_NAME); - - Message message = _session.createTextMessage("test"); - message.setJMSType(ROUTING_KEY); - - MessageProducer messageProducer = _session.createProducer(null); - messageProducer.send(sendingDestination, message); - - MessageConsumer messageConsumer = _session.createConsumer(receivingDestination); - Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); - - assertNotNull("Message not received", receivedMessage); - assertEquals("test", ((TextMessage)message).getText()); - } - - public void testRoutingWithRoutingKeySetAsJMSProperty() throws Exception - { - Destination sendingDestination = _session.createTopic(EXCHANGE_NAME); - Destination receivingDestination = _session.createQueue(QUEUE_NAME); - - Message message = _session.createTextMessage("test"); - message.setStringProperty("routing_key", ROUTING_KEY); - - MessageProducer messageProducer = _session.createProducer(sendingDestination); - messageProducer.send(message); - - MessageConsumer messageConsumer = _session.createConsumer(receivingDestination); - Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); - - assertNotNull("Message not received", receivedMessage); - assertEquals("test", ((TextMessage)message).getText()); - } - - public void testRoutingWithExchangeAndRoutingKeyDestination() throws Exception - { - Destination sendingDestination = _session.createTopic(EXCHANGE_NAME + "/" + ROUTING_KEY); - Destination receivingDestination = _session.createQueue(QUEUE_NAME); - - Message message = _session.createTextMessage("test"); - - MessageProducer messageProducer = _session.createProducer(sendingDestination); - messageProducer.send(message); - - MessageConsumer messageConsumer = _session.createConsumer(receivingDestination); - Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); - - assertNotNull("Message not received", receivedMessage); - assertEquals("test", ((TextMessage)message).getText()); - } - - public void testAnonymousRelayRoutingWithExchangeAndRoutingKeyDestination() throws Exception - { - Destination sendingDestination = _session.createTopic(EXCHANGE_NAME + "/" + ROUTING_KEY); - Destination receivingDestination = _session.createQueue(QUEUE_NAME); - - Message message = _session.createTextMessage("test"); - - MessageProducer messageProducer = _session.createProducer(null); - messageProducer.send(sendingDestination, message); - - MessageConsumer messageConsumer = _session.createConsumer(receivingDestination); - Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); - - assertNotNull("Message not received", receivedMessage); - assertEquals("test", ((TextMessage)message).getText()); - } - - public void testRoutingToQueue() throws Exception - { - Destination sendingDestination = _session.createQueue(QUEUE_NAME); - Destination receivingDestination = _session.createQueue(QUEUE_NAME); - - Message message = _session.createTextMessage("test"); - - MessageProducer messageProducer = _session.createProducer(sendingDestination); - messageProducer.send(message); - - MessageConsumer messageConsumer = _session.createConsumer(receivingDestination); - Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); - - assertNotNull("Message not received", receivedMessage); - assertEquals("test", ((TextMessage)message).getText()); - } - - public void testAnonymousRelayRoutingToQueue() throws Exception - { - Destination sendingDestination = _session.createQueue(QUEUE_NAME); - Destination receivingDestination = _session.createQueue(QUEUE_NAME); - - Message message = _session.createTextMessage("test"); - - MessageProducer messageProducer = _session.createProducer(null); - messageProducer.send(sendingDestination, message); - - MessageConsumer messageConsumer = _session.createConsumer(receivingDestination); - Message receivedMessage = messageConsumer.receive(getReceiveTimeout()); - - assertNotNull("Message not received", receivedMessage); - assertEquals("test", ((TextMessage)message).getText()); - } -} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/61389ed5/test-profiles/CPPExcludes ---------------------------------------------------------------------- diff --git a/test-profiles/CPPExcludes b/test-profiles/CPPExcludes index 4d8fe5c..09e7152 100755 --- a/test-profiles/CPPExcludes +++ b/test-profiles/CPPExcludes @@ -175,7 +175,5 @@ org.apache.qpid.tests.protocol.v1_0.* org.apache.qpid.server.queue.QueueDepthWithSelectorTest#test org.apache.qpid.test.unit.message.UTF8Test#* -# Tests AMQP 1.0 specific routing semantics -org.apache.qpid.systest.MessageRoutingTest#* http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/61389ed5/test-profiles/Java010Excludes ---------------------------------------------------------------------- diff --git a/test-profiles/Java010Excludes b/test-profiles/Java010Excludes index db3316c..e95fbee 100755 --- a/test-profiles/Java010Excludes +++ b/test-profiles/Java010Excludes @@ -62,5 +62,3 @@ org.apache.qpid.systests.jms_2_0.* // Exclude 1.0 protocol tests org.apache.qpid.tests.protocol.v1_0.* -// Tests AMQP 1.0 specific routing semantics -org.apache.qpid.systest.MessageRoutingTest#* http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/61389ed5/test-profiles/JavaPre010Excludes ---------------------------------------------------------------------- diff --git a/test-profiles/JavaPre010Excludes b/test-profiles/JavaPre010Excludes index 42f007d..f27acda 100644 --- a/test-profiles/JavaPre010Excludes +++ b/test-profiles/JavaPre010Excludes @@ -60,9 +60,6 @@ org.apache.qpid.systests.jms_2_0.* // Exclude 1.0 protocol tests org.apache.qpid.tests.protocol.v1_0.* -// Tests AMQP 1.0 specific routing semantics -org.apache.qpid.systest.MessageRoutingTest#* - // QPID-7948: A publish confirms defect prevents this test passing. org.apache.qpid.server.security.acl.MessagingACLTest#testPublishToTempTopicSuccess --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
