diff options
| author | Alex Rudyy <orudyy@apache.org> | 2013-07-17 16:10:51 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2013-07-17 16:10:51 +0000 |
| commit | f267c580488c9a1f46be65cd4b1d298563dcb3c6 (patch) | |
| tree | ce6842576d94801a105c6871c9c8a1a44ca7698c /qpid/java/client/src/test | |
| parent | 286ece348bd9f70fc4eddfb990df59a3156745b0 (diff) | |
| download | qpid-python-f267c580488c9a1f46be65cd4b1d298563dcb3c6.tar.gz | |
QPID-4995: Generate queue name on a client if it is not provided in binding URL
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1504186 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/src/test')
| -rw-r--r-- | qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_8Test.java | 73 | ||||
| -rw-r--r-- | qpid/java/client/src/test/java/org/apache/qpid/client/ConnectionListenerSupport.java | 55 |
2 files changed, 128 insertions, 0 deletions
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_8Test.java b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_8Test.java new file mode 100644 index 0000000000..d9caa68ef8 --- /dev/null +++ b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_8Test.java @@ -0,0 +1,73 @@ +/* + * + * 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.AMQException; +import org.apache.qpid.framing.AMQShortString; +import org.apache.qpid.framing.amqp_0_91.QueueDeclareOkBodyImpl; +import org.apache.qpid.test.utils.QpidTestCase; +import org.apache.qpid.transport.TestNetworkConnection; +import org.apache.qpid.transport.network.NetworkConnection; +import org.apache.qpid.url.AMQBindingURL; + +public class AMQSession_0_8Test extends QpidTestCase +{ + private AMQConnection _connection; + + public void setUp() throws Exception + { + _connection = new MockAMQConnection("amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'"); + NetworkConnection network = new TestNetworkConnection(); + _connection.getProtocolHandler().setNetworkConnection(network); + } + + public void testQueueNameIsGeneratedOnDeclareQueueWithEmptyQueueName() throws Exception + { + final AMQShortString testQueueName = AMQShortString.valueOf("tmp_127_0_0_1_1_1"); + + _connection.setConnectionListener(new ConnectionListenerSupport() + { + @Override + public void bytesSent(long count) + { + try + { + _connection.getProtocolHandler().methodBodyReceived(1, new QueueDeclareOkBodyImpl(testQueueName, 0, 0)); + } + catch (AMQException e) + { + throw new RuntimeException(e); + } + } + }); + + AMQSession_0_8 session = new AMQSession_0_8(_connection, 1, true, 0, 1, 1); + + AMQBindingURL bindingURL = new AMQBindingURL("topic://amq.topic//?routingkey='testTopic'"); + AMQQueue queue = new AMQQueue(bindingURL); + + assertEquals("Unexpected queue name", AMQShortString.EMPTY_STRING, queue.getAMQQueueName()); + + session.declareQueue(queue, true); + + assertEquals("Unexpected queue name", testQueueName, queue.getAMQQueueName()); + } +} diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/ConnectionListenerSupport.java b/qpid/java/client/src/test/java/org/apache/qpid/client/ConnectionListenerSupport.java new file mode 100644 index 0000000000..fc66e60bc0 --- /dev/null +++ b/qpid/java/client/src/test/java/org/apache/qpid/client/ConnectionListenerSupport.java @@ -0,0 +1,55 @@ +/* + * + * 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.jms.ConnectionListener; + +public class ConnectionListenerSupport implements ConnectionListener +{ + + @Override + public void bytesSent(long count) + { + } + + @Override + public void bytesReceived(long count) + { + } + + @Override + public boolean preFailover(boolean redirect) + { + return true; + } + + @Override + public boolean preResubscribe() + { + return false; + } + + @Override + public void failoverComplete() + { + } + +} |
