summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorArnaud Simon <arnaudsimon@apache.org>2008-10-22 08:17:06 +0000
committerArnaud Simon <arnaudsimon@apache.org>2008-10-22 08:17:06 +0000
commit05e6258230c0ae9f8033dd77635420ae6474daeb (patch)
tree83aa42b055b06744149833ad448368a6bc5c57a7 /java
parentcbba7837e1b2221ffcfacca66f34eb3fa21ecdd3 (diff)
downloadqpid-python-05e6258230c0ae9f8033dd77635420ae6474daeb.tar.gz
QPID-1384: updated AMQDestination + added test for 0.10 code path
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@706894 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/08ExcludeList2
-rw-r--r--java/08ExcludeList-nonvm3
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQDestination.java4
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java113
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java2
5 files changed, 121 insertions, 3 deletions
diff --git a/java/08ExcludeList b/java/08ExcludeList
index 8af1f14a03..0e900736c0 100644
--- a/java/08ExcludeList
+++ b/java/08ExcludeList
@@ -9,3 +9,5 @@ org.apache.qpid.test.testcases.FailoverTest#*
org.apache.qpid.test.client.failover.FailoverTest#test4MinuteFailover
// QPID-1225 : Temporary remove this test until the problem has been addressed
org.apache.qpid.server.security.acl.SimpleACLTest#testClientPublishInvalidQueueSuccess
+// Those tests are written against the 0.10 path
+org.apache.qpid.test.unit.message.UTF8Test#* \ No newline at end of file
diff --git a/java/08ExcludeList-nonvm b/java/08ExcludeList-nonvm
index e80106f9f4..d67e2bdaec 100644
--- a/java/08ExcludeList-nonvm
+++ b/java/08ExcludeList-nonvm
@@ -30,3 +30,6 @@ org.apache.qpid.test.client.timeouts.SyncWaitDelayTest#*
// QPID-1262, QPID-1119 : This test fails occasionally due to potential protocol issue.
org.apache.qpid.test.client.timeouts.SyncWaitTimeoutDelayTest#*
+
+// Those tests are written against the 0.10 path
+org.apache.qpid.test.unit.message.UTF8Test#* \ No newline at end of file
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
index 6c78b754bb..4f157d89ea 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
@@ -82,8 +82,8 @@ public abstract class AMQDestination implements Destination, Referenceable
_isExclusive = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_EXCLUSIVE));
_isAutoDelete = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_AUTODELETE));
_isDurable = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_DURABLE));
- _queueName = binding.getQueueName() == null ? null : new AMQShortString(binding.getQueueName());
- _routingKey = binding.getRoutingKey() == null ? null : new AMQShortString(binding.getRoutingKey());
+ _queueName = binding.getQueueName() == null ? null : binding.getQueueName();
+ _routingKey = binding.getRoutingKey() == null ? null : binding.getRoutingKey();
_bindingKeys = binding.getBindingKeys() == null || binding.getBindingKeys().length == 0 ? new AMQShortString[0] : binding.getBindingKeys();
}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java b/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java
new file mode 100644
index 0000000000..61e6349d94
--- /dev/null
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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.unit.message;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.transport.Connection;
+import org.apache.qpid.transport.Session;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.InitialContext;
+import javax.jms.*;
+import java.util.Properties;
+
+
+/**
+ * @author Apache Software Foundation
+ * This test makes sure that utf8 characters can be used for
+ * specifying exchange, queue name and routing key.
+ *
+ * those tests are related to qpid-1384
+ */
+public class UTF8Test extends QpidTestCase
+{
+ private static final Logger _logger = LoggerFactory.getLogger(UTF8Test.class);
+
+
+ public void testPlainEn() throws Exception
+ {
+ runTest("exhangeName", "queueName", "routingkey", "data");
+ }
+
+
+ public void testUTF8Jp() throws Exception
+ {
+ runTest("設定がそのように構成されていなければな", "的某些更新没有出现在这个 README 中。你可以访问下面的", "的发行版本包括多张光盘,其中包括安装光盘和源码光盘", "目のインストール CD は、ほとんどの最近のシス");
+ }
+
+ private void runTest(String exchangeName, String queueName, String routingKey, String data) throws Exception
+ {
+ _logger.info("Running test for exchange: " + exchangeName
+ + " queue Name: " + queueName
+ + " routing key: " + routingKey);
+ declareQueue(exchangeName, routingKey, queueName);
+
+ javax.jms.Connection con = getConnection();
+ javax.jms.Session sess = con.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
+ Destination dest = getDestination(exchangeName, routingKey, queueName);
+ // Send data
+ MessageProducer msgProd = sess.createProducer(dest);
+ TextMessage message = sess.createTextMessage(data);
+ msgProd.send(message);
+ // consume data
+ MessageConsumer msgCons = sess.createConsumer(dest);
+ con.start();
+ TextMessage m = (TextMessage) msgCons.receive(RECEIVE_TIMEOUT);
+ assertNotNull(m);
+ assertEquals(m.getText(), data);
+ }
+
+ private void declareQueue(String exch, String routkey, String qname) throws Exception
+ {
+ Connection conn = new Connection();
+ if (!_broker.equals(QpidTestCase.EXTERNAL) && !isBroker08())
+ {
+ conn.connect("localhost", 5672, "test", "guest", "guest");
+ }
+ else
+ {
+ throw new Exception("unsupported test " +
+ "configuration. broker: " + _broker + " version > 0.10 "+ !isBroker08() + " This test must be run on a local broker using protocol 0.10 or higher.");
+ }
+ Session sess = conn.createSession(0);
+ sess.exchangeDeclare(exch, "direct", null, null);
+ sess.queueDeclare(qname, null, null);
+ sess.exchangeBind(qname, exch, routkey, null);
+ sess.sync();
+
+ conn.close();
+ }
+
+ private Destination getDestination(String exch, String routkey, String qname)
+ throws Exception
+ {
+ Properties props = new Properties();
+ props.setProperty("destination.directUTF8Queue",
+ "direct://" + exch + "//" + qname + "?autodelete='false'&durable='false'"
+ + "&routingkey='" + routkey + "'");
+
+ // Get our connection context
+ InitialContext ctx = new InitialContext(props);
+ return (Destination) ctx.lookup("directUTF8Queue");
+ }
+}
diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
index 74b3d5e049..0cbef4c520 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
@@ -129,7 +129,7 @@ public class QpidTestCase extends TestCase
// values
protected static final String VM = "vm";
- private static final String EXTERNAL = "external";
+ protected static final String EXTERNAL = "external";
private static final String VERSION_08 = "0-8";
private static final String VERSION_010 = "0-10";