From 633c33f224f3196f3f9bd80bd2e418d8143fea06 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Fri, 4 May 2012 15:39:19 +0000 Subject: QPID-3858: Updated branch - merged from trunk r.1333987 git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1334037 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/jndi/JNDITest.properties | 28 +++++++ .../PropertiesFileInitialContextFactoryTest.java | 95 ++++++++++++++++++++++ .../java/org/apache/qpid/jndi/hello.properties | 27 ++++++ .../qpid/test/unit/jndi/JNDIPropertyFileTest.java | 88 -------------------- .../apache/qpid/test/unit/jndi/JNDITest.properties | 28 ------- .../qpid/test/unit/message/TestAMQSession.java | 2 +- 6 files changed, 151 insertions(+), 117 deletions(-) create mode 100644 java/client/src/test/java/org/apache/qpid/jndi/JNDITest.properties create mode 100644 java/client/src/test/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactoryTest.java create mode 100644 java/client/src/test/java/org/apache/qpid/jndi/hello.properties delete mode 100644 java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDIPropertyFileTest.java delete mode 100644 java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDITest.properties (limited to 'java/client/src/test') diff --git a/java/client/src/test/java/org/apache/qpid/jndi/JNDITest.properties b/java/client/src/test/java/org/apache/qpid/jndi/JNDITest.properties new file mode 100644 index 0000000000..07017a05a6 --- /dev/null +++ b/java/client/src/test/java/org/apache/qpid/jndi/JNDITest.properties @@ -0,0 +1,28 @@ +# +# 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. +# +java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory + +# Queue name with spaces +queue.QueueNameWithSpace = QueueNameWithSpace + +# Topic name with spaces +topic.TopicNameWithSpace = TopicNameWithSpace + +# Multiple topic names with spaces +topic.MultipleTopicNamesWithSpace = Topic1WithSpace , Topic2WithSpace , Topic3WithSpace diff --git a/java/client/src/test/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactoryTest.java b/java/client/src/test/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactoryTest.java new file mode 100644 index 0000000000..2989970dcd --- /dev/null +++ b/java/client/src/test/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactoryTest.java @@ -0,0 +1,95 @@ +/* + * 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.jndi; + + +import java.util.Properties; + +import javax.jms.Destination; +import javax.jms.Queue; +import javax.jms.Topic; +import javax.naming.ConfigurationException; +import javax.naming.Context; +import javax.naming.InitialContext; + +import junit.framework.TestCase; + +import org.apache.qpid.client.AMQDestination; +import org.apache.qpid.framing.AMQShortString; + +public class PropertiesFileInitialContextFactoryTest extends TestCase +{ + private static final String FILE_URL_PATH = System.getProperty("user.dir") + "/client/src/test/java/org/apache/qpid/jndi/"; + private static final String FILE_NAME = "hello.properties"; + + private Context ctx; + + protected void setUp() throws Exception + { + Properties properties = new Properties(); + properties.load(this.getClass().getResourceAsStream("JNDITest.properties")); + + //Create the initial context + ctx = new InitialContext(properties); + } + + + public void testQueueNamesWithTrailingSpaces() throws Exception + { + Queue queue = (Queue)ctx.lookup("QueueNameWithSpace"); + assertEquals("QueueNameWithSpace",queue.getQueueName()); + } + + public void testTopicNamesWithTrailingSpaces() throws Exception + { + Topic topic = (Topic)ctx.lookup("TopicNameWithSpace"); + assertEquals("TopicNameWithSpace",topic.getTopicName()); + } + + public void testMultipleTopicNamesWithTrailingSpaces() throws Exception + { + Topic topic = (Topic)ctx.lookup("MultipleTopicNamesWithSpace"); + int i = 0; + for (AMQShortString bindingKey: ((AMQDestination)topic).getBindingKeys()) + { + i++; + assertEquals("Topic" + i + "WithSpace",bindingKey.asString()); + } + } + + public void testConfigurationErrors() throws Exception + { + Properties properties = new Properties(); + properties.put("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory"); + properties.put("destination.my-queue","amq.topic/test;create:always}"); + + try + { + ctx = new InitialContext(properties); + fail("A configuration exception should be thrown with details about the address syntax error"); + } + catch(ConfigurationException e) + { + assertTrue("Incorrect exception", e.getMessage().contains("Failed to parse entry: amq.topic/test;create:always}")); + } + + } +} diff --git a/java/client/src/test/java/org/apache/qpid/jndi/hello.properties b/java/client/src/test/java/org/apache/qpid/jndi/hello.properties new file mode 100644 index 0000000000..d017d137fe --- /dev/null +++ b/java/client/src/test/java/org/apache/qpid/jndi/hello.properties @@ -0,0 +1,27 @@ +# +# 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. +# +java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory + +# register some connection factories +# connectionfactory.[jndiname] = [ConnectionURL] +connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://10.0.1.46:5672' + +# Register an AMQP destination in JNDI +# destination.[jniName] = [Address Format] +destination.topicExchange = amq.topic diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDIPropertyFileTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDIPropertyFileTest.java deleted file mode 100644 index 576ab4fa05..0000000000 --- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDIPropertyFileTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.jndi; - -import junit.framework.TestCase; - -import org.apache.qpid.client.AMQDestination; -import org.apache.qpid.framing.AMQShortString; - -import javax.jms.Queue; -import javax.jms.Topic; -import javax.naming.ConfigurationException; -import javax.naming.Context; -import javax.naming.InitialContext; -import java.util.Properties; - -public class JNDIPropertyFileTest extends TestCase -{ - private Context ctx; - - public JNDIPropertyFileTest() throws Exception - { - Properties properties = new Properties(); - properties.load(this.getClass().getResourceAsStream("JNDITest.properties")); - - //Create the initial context - ctx = new InitialContext(properties); - } - - public void testQueueNamesWithTrailingSpaces() throws Exception - { - Queue queue = (Queue)ctx.lookup("QueueNameWithSpace"); - assertEquals("QueueNameWithSpace",queue.getQueueName()); - } - - public void testTopicNamesWithTrailingSpaces() throws Exception - { - Topic topic = (Topic)ctx.lookup("TopicNameWithSpace"); - assertEquals("TopicNameWithSpace",topic.getTopicName()); - } - - public void testMultipleTopicNamesWithTrailingSpaces() throws Exception - { - Topic topic = (Topic)ctx.lookup("MultipleTopicNamesWithSpace"); - int i = 0; - for (AMQShortString bindingKey: ((AMQDestination)topic).getBindingKeys()) - { - i++; - assertEquals("Topic" + i + "WithSpace",bindingKey.asString()); - } - } - - public void testConfigurationErrors() throws Exception - { - Properties properties = new Properties(); - properties.put("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory"); - properties.put("destination.my-queue","amq.topic/test;create:always}"); - - try - { - ctx = new InitialContext(properties); - fail("A configuration exception should be thrown with details about the address syntax error"); - } - catch(ConfigurationException e) - { - assertTrue("Incorrect exception", e.getMessage().contains("Failed to parse entry: amq.topic/test;create:always}")); - } - - } -} diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDITest.properties b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDITest.properties deleted file mode 100644 index 07017a05a6..0000000000 --- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDITest.properties +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# -java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory - -# Queue name with spaces -queue.QueueNameWithSpace = QueueNameWithSpace - -# Topic name with spaces -topic.TopicNameWithSpace = TopicNameWithSpace - -# Multiple topic names with spaces -topic.MultipleTopicNamesWithSpace = Topic1WithSpace , Topic2WithSpace , Topic3WithSpace diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java b/java/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java index 84d91ee57e..f199961b6f 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java @@ -145,7 +145,7 @@ public class TestAMQSession extends AMQSession_0_8 } public void sendQueueDeclare(AMQDestination amqd, AMQProtocolHandler protocolHandler, - boolean nowait) throws AMQException, FailoverException + boolean nowait, boolean passive) throws AMQException, FailoverException { } -- cgit v1.2.1