You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/01/10 17:17:40 UTC
[2/2] qpid-broker-j git commit: QPID-6933: [System Tests] Remove JMS
AMQP 0-x client specific tests moved into client system test module
QPID-6933: [System Tests] Remove JMS AMQP 0-x client specific tests moved into client system test module
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/e65b7367
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/e65b7367
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/e65b7367
Branch: refs/heads/master
Commit: e65b7367306eab3c76dc4cd4e3b7f9fb3cd69736
Parents: 507b0c5
Author: Alex Rudyy <or...@apache.org>
Authored: Wed Jan 10 17:10:24 2018 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Wed Jan 10 17:10:52 2018 +0000
----------------------------------------------------------------------
.../qpid/client/AMQTestConnection_0_10.java | 34 -
.../ReturnUnroutableMandatoryMessageTest.java | 298 ----
.../CloseOnNoRouteForMandatoryMessageTest.java | 141 --
.../ImmediateAndMandatoryPublishingTest.java | 244 ---
.../UnroutableMessageTestExceptionListener.java | 157 --
.../AddressBasedDestinationTest.java | 1659 ------------------
test-profiles/CPPExcludes | 13 -
test-profiles/Java010Excludes | 9 -
test-profiles/Java10Excludes | 4 -
test-profiles/JavaPre010Excludes | 13 -
10 files changed, 2572 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e65b7367/systests/src/test/java/org/apache/qpid/client/AMQTestConnection_0_10.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/client/AMQTestConnection_0_10.java b/systests/src/test/java/org/apache/qpid/client/AMQTestConnection_0_10.java
deleted file mode 100644
index c5dd523..0000000
--- a/systests/src/test/java/org/apache/qpid/client/AMQTestConnection_0_10.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.client;
-
-import org.apache.qpid.transport.Connection;
-
-public class AMQTestConnection_0_10 extends AMQConnection
-{
- public AMQTestConnection_0_10(String url) throws Exception
- {
- super(url);
- }
-
- public Connection getConnection()
- {
- return((AMQConnectionDelegate_0_10)getDelegate()).getQpidConnection();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e65b7367/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java b/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
deleted file mode 100644
index af17308..0000000
--- a/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.server.exchange;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-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 org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.client.AMQHeadersExchange;
-import org.apache.qpid.client.AMQNoRouteException;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.exchange.ExchangeDefaults;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.url.AMQBindingURL;
-import org.apache.qpid.url.BindingURL;
-
-public class ReturnUnroutableMandatoryMessageTest extends QpidBrokerTestCase implements ExceptionListener
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(ReturnUnroutableMandatoryMessageTest.class);
-
- private final List<Message> _bouncedMessageList = Collections.synchronizedList(new ArrayList<Message>());
-
- /**
- * Tests that mandatory message which are not routable are returned to the producer
- *
- * @throws Exception
- */
- public void testReturnUnroutableMandatoryMessage_HEADERS() throws Exception
- {
- _bouncedMessageList.clear();
- MessageConsumer consumer = null;
- AMQSession producerSession = null;
- AMQHeadersExchange queue = null;
- Connection con=null, con2 = null;
- try
- {
- con = getConnection();
-
- AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
- queue = new AMQHeadersExchange(new AMQBindingURL(ExchangeDefaults.HEADERS_EXCHANGE_CLASS + "://" + ExchangeDefaults.HEADERS_EXCHANGE_NAME + "/test/queue1?" + BindingURL.OPTION_ROUTING_KEY + "='F0000=1'"));
-
- Map<String,Object> ft = new HashMap<>();
- ft.put("F1000", "1");
- consumerSession.declareAndBind(queue, ft);
-
- consumer = consumerSession.createConsumer(queue);
-
- //force synch to ensure the consumer has resulted in a bound queue
- //((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
- // This is the default now
-
- con2 = getConnection();
-
- con2.setExceptionListener(this);
- producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
- // Need to start the "producer" connection in order to receive bounced messages
- LOGGER.info("Starting producer connection");
- con2.start();
- }
- catch (JMSException jmse)
- {
- fail(jmse.getMessage());
- }
-
- try
- {
- MessageProducer nonMandatoryProducer = producerSession.createProducer(queue, false, false);
- MessageProducer mandatoryProducer = producerSession.createProducer(queue);
-
- // First test - should neither be bounced nor routed
- LOGGER.info("Sending non-routable non-mandatory message");
- TextMessage msg1 = producerSession.createTextMessage("msg1");
- nonMandatoryProducer.send(msg1);
-
- // Second test - should be bounced
- LOGGER.info("Sending non-routable mandatory message");
- TextMessage msg2 = producerSession.createTextMessage("msg2");
- mandatoryProducer.send(msg2);
-
- // Third test - should be routed
- LOGGER.info("Sending routable message");
- TextMessage msg3 = producerSession.createTextMessage("msg3");
- msg3.setStringProperty("F1000", "1");
- mandatoryProducer.send(msg3);
-
- LOGGER.info("Starting consumer connection");
- con.start();
- TextMessage tm = (TextMessage) consumer.receive(1000L);
-
- assertTrue("No message routed to receiver", tm != null);
- assertTrue("Wrong message routed to receiver: " + tm.getText(), "msg3".equals(tm.getText()));
-
- try
- {
- Thread.sleep(1000L);
- }
- catch (InterruptedException e)
- {
- ;
- }
-
- assertTrue("Wrong number of messages bounced (expect 1): " + _bouncedMessageList.size(), _bouncedMessageList.size() == 1);
- Message m = _bouncedMessageList.get(0);
- assertTrue("Wrong message bounced: " + m.toString(), m.toString().contains("msg2"));
- }
- catch (JMSException jmse)
- {
-
- }
- con.close();
- con2.close();
-
- }
-
- public void testReturnUnroutableMandatoryMessage_QUEUE() throws Exception
- {
- _bouncedMessageList.clear();
- Connection con = getConnection();
-
- AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
- AMQQueue valid_queue = new AMQQueue(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, "testReturnUnroutableMandatoryMessage_QUEUE");
- AMQQueue invalid_queue = new AMQQueue(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, "testReturnUnroutableMandatoryMessage_QUEUE_INVALID");
- MessageConsumer consumer = consumerSession.createConsumer(valid_queue);
-
- //force synch to ensure the consumer has resulted in a bound queue
- //((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
- // This is the default now
-
- Connection con2 = getConnection();
-
- con2.setExceptionListener(this);
- AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
- // Need to start the "producer" connection in order to receive bounced messages
- LOGGER.info("Starting producer connection");
- con2.start();
-
- MessageProducer nonMandatoryProducer = producerSession.createProducer(valid_queue, false, false);
- MessageProducer mandatoryProducer = producerSession.createProducer(invalid_queue);
-
- // First test - should be routed
- LOGGER.info("Sending non-mandatory message");
- TextMessage msg1 = producerSession.createTextMessage("msg1");
- nonMandatoryProducer.send(msg1);
-
- // Second test - should be bounced
- LOGGER.info("Sending non-routable mandatory message");
- TextMessage msg2 = producerSession.createTextMessage("msg2");
- mandatoryProducer.send(msg2);
-
- LOGGER.info("Starting consumer connection");
- con.start();
- TextMessage tm = (TextMessage) consumer.receive(1000L);
-
- assertTrue("No message routed to receiver", tm != null);
- assertTrue("Wrong message routed to receiver: " + tm.getText(), "msg1".equals(tm.getText()));
-
- try
- {
- Thread.sleep(1000L);
- }
- catch (InterruptedException e)
- {
- ;
- }
-
- assertTrue("Wrong number of messages bounced (expect 1): " + _bouncedMessageList.size(), _bouncedMessageList.size() == 1);
- Message m = _bouncedMessageList.get(0);
- assertTrue("Wrong message bounced: " + m.toString(), m.toString().contains("msg2"));
-
- con.close();
- con2.close();
- }
-
- public void testReturnUnroutableMandatoryMessage_TOPIC() throws Exception
- {
- _bouncedMessageList.clear();
- Connection con = getConnection();
-
- AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
- AMQTopic valid_topic = new AMQTopic(ExchangeDefaults.TOPIC_EXCHANGE_CLASS, "test.Return.Unroutable.Mandatory.Message.TOPIC");
- AMQTopic invalid_topic = new AMQTopic(ExchangeDefaults.TOPIC_EXCHANGE_CLASS, "test.Return.Unroutable.Mandatory.Message.TOPIC.invalid");
- MessageConsumer consumer = consumerSession.createConsumer(valid_topic);
-
- //force synch to ensure the consumer has resulted in a bound queue
- //((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
- // This is the default now
-
- Connection con2 = getConnection();
-
- con2.setExceptionListener(this);
- AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
- // Need to start the "producer" connection in order to receive bounced messages
- LOGGER.info("Starting producer connection");
- con2.start();
-
- MessageProducer nonMandatoryProducer = producerSession.createProducer(valid_topic, false, false);
- MessageProducer mandatoryProducer = producerSession.createProducer(invalid_topic, false, true);
-
- // First test - should be routed
- LOGGER.info("Sending non-mandatory message");
- TextMessage msg1 = producerSession.createTextMessage("msg1");
- nonMandatoryProducer.send(msg1);
-
- // Second test - should be bounced
- LOGGER.info("Sending non-routable mandatory message");
- TextMessage msg2 = producerSession.createTextMessage("msg2");
- mandatoryProducer.send(msg2);
-
- LOGGER.info("Starting consumer connection");
- con.start();
- TextMessage tm = (TextMessage) consumer.receive(1000L);
-
- assertTrue("No message routed to receiver", tm != null);
- assertTrue("Wrong message routed to receiver: " + tm.getText(), "msg1".equals(tm.getText()));
-
- try
- {
- Thread.sleep(1000L);
- }
- catch (InterruptedException e)
- {
- ;
- }
-
- assertEquals("Wrong number of messages bounced: ", 1, _bouncedMessageList.size());
- Message m = _bouncedMessageList.get(0);
- assertTrue("Wrong message bounced: " + m.toString(), m.toString().contains("msg2"));
-
- con.close();
- con2.close();
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(ReturnUnroutableMandatoryMessageTest.class);
- }
-
- @Override
- public void onException(JMSException jmsException)
- {
-
- Exception linkedException = null;
- linkedException = jmsException.getLinkedException();
- if (linkedException instanceof AMQNoRouteException)
- {
- AMQNoRouteException noRoute = (AMQNoRouteException) linkedException;
- Message bounced = (Message) noRoute.getUndeliveredMessage();
- _bouncedMessageList.add(bounced);
- LOGGER.info("Caught expected NoRouteException");
- }
- else
- {
- LOGGER.warn("Caught exception on producer: ", jmsException);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e65b7367/systests/src/test/java/org/apache/qpid/test/client/CloseOnNoRouteForMandatoryMessageTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/test/client/CloseOnNoRouteForMandatoryMessageTest.java b/systests/src/test/java/org/apache/qpid/test/client/CloseOnNoRouteForMandatoryMessageTest.java
deleted file mode 100644
index 5a86be1..0000000
--- a/systests/src/test/java/org/apache/qpid/test/client/CloseOnNoRouteForMandatoryMessageTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.test.client;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.IllegalStateException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-/**
- * Tests the broker's connection-closing behaviour when it receives an unroutable message
- * on a transactional session.
- *
- * @see ImmediateAndMandatoryPublishingTest for more general tests of mandatory and immediate publishing
- */
-public class CloseOnNoRouteForMandatoryMessageTest extends QpidBrokerTestCase
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(CloseOnNoRouteForMandatoryMessageTest.class);
-
- private Connection _connection;
- private UnroutableMessageTestExceptionListener _testExceptionListener = new UnroutableMessageTestExceptionListener();
-
- public void testNoRoute_brokerClosesConnection() throws Exception
- {
- createConnectionWithCloseWhenNoRoute(true);
-
- Session transactedSession = _connection.createSession(true, Session.SESSION_TRANSACTED);
- String testQueueName = getTestQueueName();
- MessageProducer mandatoryProducer = ((AMQSession<?, ?>) transactedSession).createProducer(
- transactedSession.createQueue(testQueueName),
- true, // mandatory
- false); // immediate
-
- Message message = transactedSession.createMessage();
- mandatoryProducer.send(message);
-
- _testExceptionListener.assertReceivedNoRoute(testQueueName);
-
- try
- {
- transactedSession.commit();
- fail("Expected exception not thrown");
- }
- catch (IllegalStateException ise)
- {
- LOGGER.debug("Caught exception", ise);
- //The session was marked closed even before we had a chance to call commit on it
- assertTrue("ISE did not indicate closure", ise.getMessage().contains("closed"));
- }
- }
-
- public void testNoRouteForNonMandatoryMessage_brokerKeepsConnectionOpenAndCallsExceptionListener() throws Exception
- {
- createConnectionWithCloseWhenNoRoute(true);
-
- Session transactedSession = _connection.createSession(true, Session.SESSION_TRANSACTED);
- String testQueueName = getTestQueueName();
- MessageProducer nonMandatoryProducer = ((AMQSession<?, ?>) transactedSession).createProducer(
- transactedSession.createQueue(testQueueName),
- false, // mandatory
- false); // immediate
-
- Message message = transactedSession.createMessage();
- nonMandatoryProducer.send(message);
-
- // should succeed - the message is simply discarded
- transactedSession.commit();
-
- _testExceptionListener.assertNoException();
- }
-
-
- public void testNoRouteOnNonTransactionalSession_brokerKeepsConnectionOpenAndCallsExceptionListener() throws Exception
- {
- createConnectionWithCloseWhenNoRoute(true);
-
- Session nonTransactedSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- String testQueueName = getTestQueueName();
- MessageProducer mandatoryProducer = ((AMQSession<?, ?>) nonTransactedSession).createProducer(
- nonTransactedSession.createQueue(testQueueName),
- true, // mandatory
- false); // immediate
-
- Message message = nonTransactedSession.createMessage();
- mandatoryProducer.send(message);
-
- _testExceptionListener.assertReceivedNoRouteWithReturnedMessage(message, getTestQueueName());
- }
-
- public void testClientDisablesCloseOnNoRoute_brokerKeepsConnectionOpenAndCallsExceptionListener() throws Exception
- {
- createConnectionWithCloseWhenNoRoute(false);
-
- Session transactedSession = _connection.createSession(true, Session.SESSION_TRANSACTED);
- String testQueueName = getTestQueueName();
- MessageProducer mandatoryProducer = ((AMQSession<?, ?>) transactedSession).createProducer(
- transactedSession.createQueue(testQueueName),
- true, // mandatory
- false); // immediate
-
- Message message = transactedSession.createMessage();
- mandatoryProducer.send(message);
- transactedSession.commit();
- _testExceptionListener.assertReceivedNoRouteWithReturnedMessage(message, getTestQueueName());
- }
-
- private void createConnectionWithCloseWhenNoRoute(boolean closeWhenNoRoute) throws Exception
- {
- Map<String, String> options = new HashMap<>();
- options.put(ConnectionURL.OPTIONS_CLOSE_WHEN_NO_ROUTE, Boolean.toString(closeWhenNoRoute));
- _connection = getConnectionWithOptions(options);
- _connection.setExceptionListener(_testExceptionListener);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e65b7367/systests/src/test/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java b/systests/src/test/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java
deleted file mode 100644
index 88ecf65..0000000
--- a/systests/src/test/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.test.client;
-
-import java.util.Collections;
-
-import javax.jms.Connection;
-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;
-
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.port.AmqpPort;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-/**
- * @see CloseOnNoRouteForMandatoryMessageTest for related tests
- */
-public class ImmediateAndMandatoryPublishingTest extends QpidBrokerTestCase
-{
- private Connection _connection;
- private UnroutableMessageTestExceptionListener _testExceptionListener =
- new UnroutableMessageTestExceptionListener();
-
- @Override
- public void setUp() throws Exception
- {
- getDefaultBrokerConfiguration().setObjectAttribute(Port.class,
- TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT,
- AmqpPort.CONTEXT,
- Collections.singletonMap(AmqpPort.CLOSE_WHEN_NO_ROUTE, "false"));
-
- super.setUp();
- _connection = getConnection();
- _connection.setExceptionListener(_testExceptionListener);
- }
-
- public void testPublishP2PWithNoConsumerAndImmediateOnAndAutoAck() throws Exception
- {
- publishIntoExistingDestinationWithNoConsumerAndImmediateOn(Session.AUTO_ACKNOWLEDGE, false);
- }
-
- public void testPublishP2PWithNoConsumerAndImmediateOnAndTx() throws Exception
- {
- publishIntoExistingDestinationWithNoConsumerAndImmediateOn(Session.SESSION_TRANSACTED, false);
- }
-
- public void testPublishPubSubWithDisconnectedDurableSubscriberAndImmediateOnAndAutoAck() throws Exception
- {
- publishIntoExistingDestinationWithNoConsumerAndImmediateOn(Session.AUTO_ACKNOWLEDGE, true);
- }
-
- public void testPublishPubSubWithDisconnectedDurableSubscriberAndImmediateOnAndTx() throws Exception
- {
- publishIntoExistingDestinationWithNoConsumerAndImmediateOn(Session.SESSION_TRANSACTED, true);
- }
-
- public void testPublishP2PIntoNonExistingDesitinationWithMandatoryOnAutoAck() throws Exception
- {
- publishWithMandatoryOnImmediateOff(Session.AUTO_ACKNOWLEDGE, false);
- }
-
- public void testPublishP2PIntoNonExistingDesitinationWithMandatoryOnAndTx() throws Exception
- {
- publishWithMandatoryOnImmediateOff(Session.SESSION_TRANSACTED, false);
- }
-
- public void testPubSubMandatoryAutoAck() throws Exception
- {
- publishWithMandatoryOnImmediateOff(Session.AUTO_ACKNOWLEDGE, true);
- }
-
- public void testPubSubMandatoryTx() throws Exception
- {
- publishWithMandatoryOnImmediateOff(Session.SESSION_TRANSACTED, true);
- }
-
- public void testP2PNoMandatoryAutoAck() throws Exception
- {
- publishWithMandatoryOffImmediateOff(Session.AUTO_ACKNOWLEDGE, false);
- }
-
- public void testP2PNoMandatoryTx() throws Exception
- {
- publishWithMandatoryOffImmediateOff(Session.SESSION_TRANSACTED, false);
- }
-
- public void testPubSubWithImmediateOnAndAutoAck() throws Exception
- {
- consumerCreateAndClose(true, false);
-
- Message message = produceMessage(Session.AUTO_ACKNOWLEDGE, true, false, true);
- _testExceptionListener.assertReceivedNoRouteWithReturnedMessage(message, getTestQueueName());
- }
-
- private void publishIntoExistingDestinationWithNoConsumerAndImmediateOn(int acknowledgeMode, boolean pubSub)
- throws Exception
- {
- consumerCreateAndClose(pubSub, true);
-
- Message message = produceMessage(acknowledgeMode, pubSub, false, true);
-
- _testExceptionListener.assertReceivedNoConsumersWithReturnedMessage(message);
- }
-
- private void publishWithMandatoryOnImmediateOff(int acknowledgeMode, boolean pubSub) throws Exception
- {
- Message message = produceMessage(acknowledgeMode, pubSub, true, false);
- _testExceptionListener.assertReceivedNoRouteWithReturnedMessage(message, getTestQueueName());
- }
-
- private void publishWithMandatoryOffImmediateOff(int acknowledgeMode, boolean pubSub) throws Exception
- {
- produceMessage(acknowledgeMode, pubSub, false, false);
-
- _testExceptionListener.assertNoException();
- }
-
- private void consumerCreateAndClose(boolean pubSub, boolean durable) throws JMSException
- {
- Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Destination destination = null;
- MessageConsumer consumer = null;
- if (pubSub)
- {
- destination = session.createTopic(getTestQueueName());
- if (durable)
- {
- consumer = session.createDurableSubscriber((Topic) destination, getTestName());
- }
- else
- {
- consumer = session.createConsumer(destination);
- }
- }
- else
- {
- destination = session.createQueue(getTestQueueName());
- consumer = session.createConsumer(destination);
- }
- consumer.close();
- }
-
- private Message produceMessage(int acknowledgeMode, boolean pubSub, boolean mandatory, boolean immediate)
- throws JMSException
- {
- Session session = _connection.createSession(acknowledgeMode == Session.SESSION_TRANSACTED, acknowledgeMode);
- Destination destination = null;
- if (pubSub)
- {
- destination = session.createTopic(getTestQueueName());
- }
- else
- {
- destination = session.createQueue(getTestQueueName());
- }
-
- MessageProducer producer = ((AMQSession<?, ?>) session).createProducer(destination, mandatory, immediate);
- Message message = session.createMessage();
- producer.send(message);
- if (session.getTransacted())
- {
- session.commit();
- }
- return message;
- }
-
- public void testMandatoryAndImmediateDefaults() throws Exception
- {
- Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // publish to non-existent queue - should get mandatory failure
- MessageProducer producer = session.createProducer(session.createQueue(getTestQueueName()));
- Message message = session.createMessage();
- producer.send(message);
-
- _testExceptionListener.assertReceivedNoRouteWithReturnedMessage(message, getTestQueueName());
-
- producer = session.createProducer(null);
- message = session.createMessage();
- producer.send(session.createQueue(getTestQueueName()), message);
-
- _testExceptionListener.assertReceivedNoRouteWithReturnedMessage(message, getTestQueueName());
-
- // publish to non-existent topic - should get no failure
- producer = session.createProducer(session.createTopic(getTestQueueName()));
- message = session.createMessage();
- producer.send(message);
-
- _testExceptionListener.assertNoException();
-
- producer = session.createProducer(null);
- message = session.createMessage();
- producer.send(session.createTopic(getTestQueueName()), message);
-
- _testExceptionListener.assertNoException();
-
- session.close();
- }
-
- public void testMandatoryAndImmediateSystemProperties() throws Exception
- {
- setTestClientSystemProperty("qpid.default_mandatory", "true");
- Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // publish to non-existent topic - should get mandatory failure
-
- MessageProducer producer = session.createProducer(session.createTopic(getTestQueueName()));
- Message message = session.createMessage();
- producer.send(message);
-
- _testExceptionListener.assertReceivedNoRouteWithReturnedMessage(message, getTestQueueName());
-
- // now set topic specific system property to false - should no longer get mandatory failure on new producer
- setTestClientSystemProperty("qpid.default_mandatory_topic", "false");
- producer = session.createProducer(null);
- message = session.createMessage();
- producer.send(session.createTopic(getTestQueueName()), message);
-
- _testExceptionListener.assertNoException();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e65b7367/systests/src/test/java/org/apache/qpid/test/client/UnroutableMessageTestExceptionListener.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/test/client/UnroutableMessageTestExceptionListener.java b/systests/src/test/java/org/apache/qpid/test/client/UnroutableMessageTestExceptionListener.java
deleted file mode 100644
index 87204c5..0000000
--- a/systests/src/test/java/org/apache/qpid/test/client/UnroutableMessageTestExceptionListener.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.test.client;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQNoConsumersException;
-import org.apache.qpid.client.AMQNoRouteException;
-import org.apache.qpid.server.protocol.ErrorCodes;
-
-/**
- * Provides utility methods for checking exceptions that are thrown on the client side when a message is
- * not routable.
- *
- * Exception objects are passed either explicitly as method parameters or implicitly
- * by previously doing {@link Connection#setExceptionListener(ExceptionListener)}.
- */
-public class UnroutableMessageTestExceptionListener implements ExceptionListener
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(UnroutableMessageTestExceptionListener.class);
-
- /**
- * Number of seconds to check for an event that should should NOT happen
- */
- private static final int NEGATIVE_TIMEOUT = 2;
-
- /**
- * Number of seconds to keep checking for an event that should should happen
- */
- private static final int POSITIVE_TIMEOUT = 30;
-
- private BlockingQueue<JMSException> _exceptions = new ArrayBlockingQueue<JMSException>(1);
-
- @Override
- public void onException(JMSException e)
- {
- LOGGER.info("Received exception " + e);
- _exceptions.add(e);
- }
-
- public void assertReceivedNoRouteWithReturnedMessage(Message message, String intendedQueueName) throws Exception
- {
- JMSException exception = getReceivedException();
- assertNoRouteExceptionWithReturnedMessage(exception, message, intendedQueueName);
- }
-
- public void assertReceivedNoRoute(String intendedQueueName) throws Exception
- {
- JMSException exception = getReceivedException();
- assertNoRoute(exception, intendedQueueName);
- }
-
- public void assertReceivedNoConsumersWithReturnedMessage(Message message) throws Exception
- {
- JMSException exception = getReceivedException();
- AMQNoConsumersException noConsumersException = (AMQNoConsumersException) exception.getLinkedException();
- assertNotNull("AMQNoConsumersException should be linked to JMSException", noConsumersException);
- Message bounceMessage = (Message) noConsumersException.getUndeliveredMessage();
- assertNotNull("Bounced Message is expected", bounceMessage);
-
- assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
- }
-
- public void assertNoRouteExceptionWithReturnedMessage(
- JMSException exception, Message message, String intendedQueueName) throws Exception
- {
- assertNoRoute(exception, intendedQueueName);
-
- assertNoRouteException(exception, message);
- }
-
- private void assertNoRouteException(JMSException exception, Message message) throws Exception
- {
- AMQNoRouteException noRouteException = (AMQNoRouteException) exception.getLinkedException();
- assertNotNull("AMQNoRouteException should be linked to JMSException", noRouteException);
- Message bounceMessage = (Message) noRouteException.getUndeliveredMessage();
- assertNotNull("Bounced Message is expected", bounceMessage);
-
- assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
- }
-
- public void assertNoRoute(JMSException exception, String intendedQueueName)
- {
- assertTrue(
- exception + " message should contain intended queue name",
- exception.getMessage().contains(intendedQueueName));
-
- AMQException noRouteException = (AMQException) exception.getLinkedException();
- assertNotNull("AMQException should be linked to JMSException", noRouteException);
-
- assertAMQException("Unexpected error code", ErrorCodes.NO_ROUTE, noRouteException);
- assertTrue(
- "Linked exception " + noRouteException + " message should contain intended queue name",
- noRouteException.getMessage().contains(intendedQueueName));
- }
-
-
- public void assertNoException() throws Exception
- {
- assertNull("Unexpected JMSException", _exceptions.poll(NEGATIVE_TIMEOUT, TimeUnit.SECONDS));
- }
-
- private JMSException getReceivedException() throws Exception
- {
- JMSException exception = _exceptions.poll(POSITIVE_TIMEOUT, TimeUnit.SECONDS);
- assertNotNull("JMSException is expected", exception);
- return exception;
- }
-
- private void assertAMQException(final String message, final int expected, final AMQException e)
- {
- Object object = e.getErrorCode(); // API change after v6.1
- if (object instanceof Integer)
- {
- assertEquals(message, expected, e.getErrorCode());
- }
- else
- {
- final String fullMessage = String.format("%s. expected actual : %s to start with %d", message, e.getErrorCode(), expected);
- final String actual = String.valueOf(e.getErrorCode());
- assertTrue(fullMessage, actual.startsWith(Integer.toString(expected)));
- }
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org