QPID-6933: [System Tests] Refactor anonymous producer 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/f96d50b9 Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/f96d50b9 Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/f96d50b9 Branch: refs/heads/master Commit: f96d50b9f7447c0e307cb5bb14f433300fc849f4 Parents: f304759 Author: Alex Rudyy <[email protected]> Authored: Wed Dec 27 22:42:20 2017 +0000 Committer: Alex Rudyy <[email protected]> Committed: Wed Dec 27 22:42:20 2017 +0000 ---------------------------------------------------------------------- .../jms_1_1/producer/AnonymousProducerTest.java | 187 +++++++++++++++++++ .../qpid/systest/AnonymousProducerTest.java | 116 ------------ test-profiles/CPPExcludes | 4 - test-profiles/Java010Excludes | 4 - test-profiles/Java10UninvestigatedTestsExcludes | 1 - 5 files changed, 187 insertions(+), 125 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f96d50b9/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/producer/AnonymousProducerTest.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/producer/AnonymousProducerTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/producer/AnonymousProducerTest.java new file mode 100644 index 0000000..8f671cc --- /dev/null +++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/producer/AnonymousProducerTest.java @@ -0,0 +1,187 @@ +/* + * + * 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.producer; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.core.AnyOf.anyOf; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeThat; + +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.junit.Test; + +import org.apache.qpid.server.model.Protocol; +import org.apache.qpid.systests.JmsTestBase; + +public class AnonymousProducerTest extends JmsTestBase +{ + + @Test + public void testPublishIntoDestinationBoundWithNotMatchingFilter() throws Exception + { + Topic topic = createTopic(getTestName()); + final Connection connection = getConnection(); + try + { + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageProducer messageProducer = session.createProducer(null); + + MessageConsumer consumer = session.createConsumer(topic, "id>1"); + TextMessage notMatching = session.createTextMessage("notMatching"); + notMatching.setIntProperty("id", 1); + messageProducer.send(topic, notMatching); + + TextMessage matching = session.createTextMessage("Matching"); + matching.setIntProperty("id", 2); + messageProducer.send(topic, matching); + session.commit(); + + connection.start(); + Message message = consumer.receive(getReceiveTimeout()); + assertTrue("Expected message not received", message instanceof TextMessage); + TextMessage textMessage = (TextMessage) message; + assertEquals("Unexpected text", "Matching", textMessage.getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testPublishIntoNonExistingTopic() throws Exception + { + final Topic topic = createTopic(getTestName()); + final Connection connection = getConnection(); + try + { + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageProducer messageProducer = session.createProducer(null); + messageProducer.send(topic, session.createTextMessage("A")); + session.commit(); + + connection.start(); + MessageConsumer consumer = session.createConsumer(topic); + messageProducer.send(topic, session.createTextMessage("B")); + session.commit(); + + Message message = consumer.receive(getReceiveTimeout()); + assertTrue("Expected message not received", message instanceof TextMessage); + TextMessage textMessage = (TextMessage) message; + assertEquals("Unexpected text", "B", textMessage.getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testPublishIntoNonExistingQueue() throws Exception + { + assumeThat("QPID-7818/QPIDJMS-349", getProtocol(), is(not(anyOf(equalTo(Protocol.AMQP_0_10), equalTo(Protocol.AMQP_1_0))))); + final Connection connection = getConnection(); + try + { + connection.start(); + + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageProducer messageProducer = session.createProducer(null); + try + { + messageProducer.send(session.createQueue("nonExistingQueue"), session.createTextMessage("testMessage")); + session.commit(); + fail("Expected exception was not thrown"); + } + catch (JMSException e) + { + // pass + } + } + finally + { + connection.close(); + } + } + + @Test + public void testSyncPublishIntoNonExistingQueue() throws Exception + { + assumeThat("QPID-7818", getProtocol(), is(not(equalTo(Protocol.AMQP_0_10)))); + final Connection connection = getConnectionBuilder().setSyncPublish(true).build(); + try + { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer producer = session.createProducer(null); + final Queue queue = session.createQueue("nonExistingQueue"); + try + { + producer.send(queue, session.createTextMessage("hello")); + fail("Send to unknown destination should result in error"); + } + catch (JMSException e) + { + // pass + } + } + finally + { + connection.close(); + } + } + + @Test + public void testUnidentifiedDestination() throws Exception + { + Connection connection = getConnection(); + try + { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer publisher = session.createProducer(null); + try + { + publisher.send(session.createTextMessage("Test")); + fail("Did not throw UnsupportedOperationException"); + } + catch (UnsupportedOperationException e) + { + // PASS + } + } + finally + { + connection.close(); + } + } +} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f96d50b9/systests/src/test/java/org/apache/qpid/systest/AnonymousProducerTest.java ---------------------------------------------------------------------- diff --git a/systests/src/test/java/org/apache/qpid/systest/AnonymousProducerTest.java b/systests/src/test/java/org/apache/qpid/systest/AnonymousProducerTest.java deleted file mode 100644 index 2550fdb..0000000 --- a/systests/src/test/java/org/apache/qpid/systest/AnonymousProducerTest.java +++ /dev/null @@ -1,116 +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 javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; - -import org.apache.qpid.test.utils.QpidBrokerTestCase; - -public class AnonymousProducerTest extends QpidBrokerTestCase -{ - - public void testPublishIntoDestinationBoundWithNotMatchingFilter() throws Exception - { - final Connection connection = getConnection(); - connection.start(); - - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - MessageProducer messageProducer = session.createProducer(null); - - Topic topic = createTopicOnFanout(connection, getTestName()); - - session.createConsumer(topic, "id>1"); - TextMessage test = session.createTextMessage("testMessage"); - test.setIntProperty("id", 1); - try - { - messageProducer.send(topic, test); - session.commit(); - } - catch (JMSException e) - { - fail("Exception should not be thrown: " + e.getMessage()); - } - } - - public void testPublishIntoNonExistingTopic() throws Exception - { - final Connection connection = getConnection(); - connection.start(); - - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - MessageProducer messageProducer = session.createProducer(null); - - try - { - messageProducer.send(createTopicOnFanout(connection, "nonExistingTopic"), - session.createTextMessage("testMessage")); - session.commit(); - } - catch (JMSException e) - { - fail("Message should be silently discarded. Exception should not be thrown: " + e.getMessage()); - } - } - - public void testPublishIntoNonExistingQueue() throws Exception - { - final Connection connection = getConnection(); - connection.start(); - - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - MessageProducer messageProducer = session.createProducer(null); - - try - { - messageProducer.send(session.createQueue("nonExistingQueue"), session.createTextMessage("testMessage")); - session.commit(); - fail("Expected exception was not thrown"); - } - catch (JMSException e) - { - // pass - } - } - - public void testSyncPublishIntoNonExistingQueue() throws Exception - { - Session session = getConnectionWithSyncPublishing().createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(null); - try - { - final Queue queue = session.createQueue("nonExistingQueue"); - producer.send(queue, session.createTextMessage("hello")); - fail("Send to unknown destination should result in error"); - } - catch (JMSException e) - { - // pass - } - } - -} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f96d50b9/test-profiles/CPPExcludes ---------------------------------------------------------------------- diff --git a/test-profiles/CPPExcludes b/test-profiles/CPPExcludes index dcfc337..0c493d4 100755 --- a/test-profiles/CPPExcludes +++ b/test-profiles/CPPExcludes @@ -199,10 +199,6 @@ org.apache.qpid.tests.protocol.v1_0.* org.apache.qpid.server.queue.FlowToDiskTest#* -# QPID-7818: Messages published into non existing queue are discarded on 0-10 path -org.apache.qpid.systest.AnonymousProducerTest#testPublishIntoNonExistingQueue -org.apache.qpid.systest.AnonymousProducerTest#testSyncPublishIntoNonExistingQueue - # Tests require AMQP management org.apache.qpid.server.routing.AlternateBindingRoutingTest#* org.apache.qpid.server.queue.LastValueQueueTest#testConflatedQueueDepth http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f96d50b9/test-profiles/Java010Excludes ---------------------------------------------------------------------- diff --git a/test-profiles/Java010Excludes b/test-profiles/Java010Excludes index d0448fa..1d6d98e 100755 --- a/test-profiles/Java010Excludes +++ b/test-profiles/Java010Excludes @@ -68,9 +68,5 @@ org.apache.qpid.systests.jms_2_0.* // Exclude 1.0 protocol tests org.apache.qpid.tests.protocol.v1_0.* -// QPID-7818: Messages published into non existing queue are discarded on 0-10 path -org.apache.qpid.systest.AnonymousProducerTest#testPublishIntoNonExistingQueue -org.apache.qpid.systest.AnonymousProducerTest#testSyncPublishIntoNonExistingQueue - // Tests AMQP 1.0 specific routing semantics org.apache.qpid.systest.MessageRoutingTest#* http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f96d50b9/test-profiles/Java10UninvestigatedTestsExcludes ---------------------------------------------------------------------- diff --git a/test-profiles/Java10UninvestigatedTestsExcludes b/test-profiles/Java10UninvestigatedTestsExcludes index 4402248..9dd40a0 100644 --- a/test-profiles/Java10UninvestigatedTestsExcludes +++ b/test-profiles/Java10UninvestigatedTestsExcludes @@ -21,7 +21,6 @@ // working, defined as broken, or excluded as they test version specific functionality QPID-XXXX: It could be a broker bug. The issue requires further investigation -org.apache.qpid.systest.AnonymousProducerTest#testPublishIntoNonExistingQueue org.apache.qpid.test.client.queue.QueuePolicyTest#testRejectPolicyMessageDepth --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
