Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9925517D06 for ; Thu, 19 Mar 2015 14:41:29 +0000 (UTC) Received: (qmail 22752 invoked by uid 500); 19 Mar 2015 14:41:20 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 22715 invoked by uid 500); 19 Mar 2015 14:41:20 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 22706 invoked by uid 99); 19 Mar 2015 14:41:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Mar 2015 14:41:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D4615E1916; Thu, 19 Mar 2015 14:41:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Message-Id: <475472d93c7549c9b8ca00b6c5ff48c9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: activemq git commit: https://issues.apache.org/jira/browse/AMQ-5666 Date: Thu, 19 Mar 2015 14:41:19 +0000 (UTC) Repository: activemq Updated Branches: refs/heads/master 8e6a404d5 -> 85d9d4e94 https://issues.apache.org/jira/browse/AMQ-5666 Test that a receiver can also create temporary destinations when it has a Source configured as dynamic, also test that link close destroys the temporary destinations. Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/85d9d4e9 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/85d9d4e9 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/85d9d4e9 Branch: refs/heads/master Commit: 85d9d4e941a08f31630df13e8aad5e967363a361 Parents: 8e6a404 Author: Timothy Bish Authored: Thu Mar 19 10:40:46 2015 -0400 Committer: Timothy Bish Committed: Thu Mar 19 10:40:46 2015 -0400 ---------------------------------------------------------------------- .../amqp/interop/AmqpTempDestinationTest.java | 94 ++++++++++++++++++++ 1 file changed, 94 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/85d9d4e9/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpTempDestinationTest.java ---------------------------------------------------------------------- diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpTempDestinationTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpTempDestinationTest.java index 18ef7dd..dfbbc0b 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpTempDestinationTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpTempDestinationTest.java @@ -29,10 +29,12 @@ import org.apache.activemq.broker.jmx.BrokerViewMBean; import org.apache.activemq.transport.amqp.client.AmqpClient; import org.apache.activemq.transport.amqp.client.AmqpClientTestSupport; import org.apache.activemq.transport.amqp.client.AmqpConnection; +import org.apache.activemq.transport.amqp.client.AmqpReceiver; import org.apache.activemq.transport.amqp.client.AmqpSender; import org.apache.activemq.transport.amqp.client.AmqpSession; import org.apache.qpid.proton.amqp.Symbol; import org.apache.qpid.proton.amqp.messaging.DeleteOnClose; +import org.apache.qpid.proton.amqp.messaging.Source; import org.apache.qpid.proton.amqp.messaging.Target; import org.apache.qpid.proton.amqp.messaging.TerminusDurability; import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy; @@ -113,6 +115,98 @@ public class AmqpTempDestinationTest extends AmqpClientTestSupport { connection.close(); } + @Test(timeout = 60000) + public void testCreateDynamicReceiverToTopic() throws Exception { + doTestCreateDynamicSender(true); + } + + @Test(timeout = 60000) + public void testCreateDynamicReceiverToQueue() throws Exception { + doTestCreateDynamicSender(false); + } + + protected void doTestCreateDynamicReceiver(boolean topic) throws Exception { + Source source = createDynamicSource(topic); + + final BrokerViewMBean brokerView = getProxyToBroker(); + + AmqpClient client = createAmqpClient(); + AmqpConnection connection = client.connect(); + AmqpSession session = connection.createSession(); + + AmqpReceiver receiver = session.createReceiver(source); + assertNotNull(receiver); + + if (topic) { + assertEquals(1, brokerView.getTemporaryTopics().length); + } else { + assertEquals(1, brokerView.getTemporaryQueues().length); + } + + connection.close(); + } + + @Test(timeout = 60000) + public void testDynamicReceiverLifetimeBoundToLinkTopic() throws Exception { + doTestDynamicReceiverLifetimeBoundToLinkQueue(true); + } + + @Test(timeout = 60000) + public void testDynamicReceiverLifetimeBoundToLinkQueue() throws Exception { + doTestDynamicReceiverLifetimeBoundToLinkQueue(false); + } + + protected void doTestDynamicReceiverLifetimeBoundToLinkQueue(boolean topic) throws Exception { + Source source = createDynamicSource(topic); + + final BrokerViewMBean brokerView = getProxyToBroker(); + + AmqpClient client = createAmqpClient(); + AmqpConnection connection = client.connect(); + AmqpSession session = connection.createSession(); + + AmqpReceiver receiver = session.createReceiver(source); + assertNotNull(receiver); + + if (topic) { + assertEquals(1, brokerView.getTemporaryTopics().length); + } else { + assertEquals(1, brokerView.getTemporaryQueues().length); + } + + receiver.close(); + + if (topic) { + assertEquals(0, brokerView.getTemporaryTopics().length); + } else { + assertEquals(0, brokerView.getTemporaryQueues().length); + } + + connection.close(); + } + + protected Source createDynamicSource(boolean topic) { + + Source source = new Source(); + source.setDynamic(true); + source.setDurable(TerminusDurability.NONE); + source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH); + + // Set the dynamic node lifetime-policy + Map dynamicNodeProperties = new HashMap(); + dynamicNodeProperties.put(DYNAMIC_NODE_LIFETIME_POLICY, DeleteOnClose.getInstance()); + source.setDynamicNodeProperties(dynamicNodeProperties); + + // Set the capability to indicate the node type being created + if (!topic) { + source.setCapabilities(TEMP_QUEUE_CAPABILITY); + } else { + source.setCapabilities(TEMP_TOPIC_CAPABILITY); + } + + return source; + } + protected Target createDynamicTarget(boolean topic) { Target target = new Target();