diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2010-07-17 02:30:59 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2010-07-17 02:30:59 +0000 |
commit | 9007cdedc237f270dbfdd2dd11c5bc84918c2b13 (patch) | |
tree | a45f20b156afe7d95864bb21487da0dc4952ac53 | |
parent | dcfa11df9462a49d8baf9500a8b3d8a3ce5d979f (diff) | |
download | qpid-python-9007cdedc237f270dbfdd2dd11c5bc84918c2b13.tar.gz |
QPID-2735
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@964998 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java | 8 | ||||
-rw-r--r-- | java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java | 29 |
2 files changed, 33 insertions, 4 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java index aeceec4f57..e0fbed5ea7 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java @@ -1219,15 +1219,15 @@ public class AMQSession_0_10 extends AMQSession<BasicMessageConsumer_0_10, Basic } } - @SuppressWarnings("deprecation") private void verifySubject(AMQDestination dest) throws AMQException { if (dest.getSubject() == null || dest.getSubject().trim().equals("")) { - if (dest.getExchangeClass() == ExchangeDefaults.TOPIC_EXCHANGE_CLASS) + + if ("topic".equals(dest.getExchangeClass().toString())) { - dest.setRoutingKey(ExchangeDefaults.WILDCARD_ANY); - dest.setSubject(ExchangeDefaults.WILDCARD_ANY.toString()); + dest.setRoutingKey(new AMQShortString("#")); + dest.setSubject(dest.getRoutingKey().toString()); } else { diff --git a/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java b/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java index aabeba3c63..5bf2de836d 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java @@ -606,4 +606,33 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase assertNotNull("consumer should receive a message",cons.receive(1000)); cons.close(); } + + /** + * The default for amq.topic is "#" and for the rest it's "" + */ + public void testDefaultSubjects() throws Exception + { + Session ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE); + + MessageConsumer queueCons = ssn.createConsumer(new AMQAnyDestination("ADDR:amq.direct")); + MessageConsumer topicCons = ssn.createConsumer(new AMQAnyDestination("ADDR:amq.topic")); + + MessageProducer queueProducer = ssn.createProducer(new AMQAnyDestination("ADDR:amq.direct")); + MessageProducer topicProducer1 = ssn.createProducer(new AMQAnyDestination("ADDR:amq.topic/usa.weather")); + MessageProducer topicProducer2 = ssn.createProducer(new AMQAnyDestination("ADDR:amq.topic/sales")); + + queueProducer.send(ssn.createBytesMessage()); + assertNotNull("The consumer subscribed to amq.direct " + + "with empty binding key should have received the message ",queueCons.receive(1000)); + + topicProducer1.send(ssn.createTextMessage("25c")); + assertEquals("The consumer subscribed to amq.topic " + + "with '#' binding key should have received the message ", + ((TextMessage)topicCons.receive(1000)).getText(),"25c"); + + topicProducer2.send(ssn.createTextMessage("1000")); + assertEquals("The consumer subscribed to amq.topic " + + "with '#' binding key should have received the message ", + ((TextMessage)topicCons.receive(1000)).getText(),"1000"); + } } |