Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 61374 invoked from network); 3 Mar 2010 10:35:45 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Mar 2010 10:35:45 -0000 Received: (qmail 61703 invoked by uid 500); 3 Mar 2010 10:35:39 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 61652 invoked by uid 500); 3 Mar 2010 10:35:38 -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 61645 invoked by uid 99); 3 Mar 2010 10:35:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Mar 2010 10:35:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Mar 2010 10:35:38 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F33D6238896F; Wed, 3 Mar 2010 10:35:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r918388 - in /activemq/branches/activemq-5.3/activemq-core/src: main/java/org/apache/activemq/command/ActiveMQDestination.java test/java/org/apache/activemq/command/ActiveMQDestinationTest.java Date: Wed, 03 Mar 2010 10:35:17 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100303103517.F33D6238896F@eris.apache.org> Author: gtully Date: Wed Mar 3 10:35:17 2010 New Revision: 918388 URL: http://svn.apache.org/viewvc?rev=918388&view=rev Log: merge -c 918381 https://svn.apache.org/repos/asf/activemq/trunk - resolve https://issues.apache.org/activemq/browse/AMQ-2630 - added test and restricted imlementation Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java?rev=918388&r1=918387&r2=918388&view=diff ============================================================================== --- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java (original) +++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java Wed Mar 3 10:35:17 2010 @@ -117,6 +117,17 @@ if (dest instanceof ActiveMQDestination) { return (ActiveMQDestination)dest; } + + if (dest instanceof Queue && dest instanceof Topic) { + String queueName = ((Queue) dest).getQueueName(); + String topicName = ((Topic) dest).getTopicName(); + if (queueName != null && topicName == null) { + return new ActiveMQQueue(queueName); + } else if (queueName == null && topicName != null) { + return new ActiveMQTopic(topicName); + } + throw new JMSException("Could no disambiguate on queue|Topic-name totransform pollymorphic destination into a ActiveMQ destination: " + dest); + } if (dest instanceof TemporaryQueue) { return new ActiveMQTempQueue(((TemporaryQueue)dest).getQueueName()); } Modified: activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java?rev=918388&r1=918387&r2=918388&view=diff ============================================================================== --- activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java (original) +++ activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java Wed Mar 3 10:35:17 2010 @@ -24,6 +24,12 @@ import java.util.SortedSet; import java.util.TreeSet; +import javax.jms.JMSException; +import javax.jms.Queue; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.Topic; + import junit.framework.Test; public class ActiveMQDestinationTest extends DataStructureTestSupport { @@ -71,6 +77,46 @@ assertEquals("Sorted order", expected, actual); } + // https://issues.apache.org/activemq/browse/AMQ-2630 + class CombyDest implements Queue, Topic, TemporaryQueue, TemporaryTopic { + + private final String qName; + private final String topicName; + + public CombyDest(String qName, String topicName) { + this.qName = qName; + this.topicName = topicName; + } + + public void delete() throws JMSException { + } + + public String getTopicName() throws JMSException { + return topicName; + } + + public String getQueueName() throws JMSException { + return qName; + } + } + + public void testTransformPollymorphic() throws Exception { + ActiveMQQueue queue = new ActiveMQQueue("TEST"); + assertEquals(ActiveMQDestination.transform(queue), queue); + assertTrue("is a q", ActiveMQDestination.transform(new CombyDest(null, "Topic")) instanceof ActiveMQTopic); + assertTrue("is a q", ActiveMQDestination.transform(new CombyDest("Q", null)) instanceof ActiveMQQueue); + try { + ActiveMQDestination.transform(new CombyDest(null, null)); + fail("expect ex as cannot disambiguate"); + } catch (JMSException expected) { + } + try { + ActiveMQDestination.transform(new CombyDest("Q", "T")); + fail("expect ex as cannot disambiguate"); + } catch (JMSException expected) { + } + } + public static Test suite() { return suite(ActiveMQDestinationTest.class); }