From f355b16d382d819657d328192cc5c33b6892d5ba Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Thu, 4 Oct 2012 22:25:15 +0000 Subject: [PATCH] Lets validate the Qpid JMS client <- AMQP 1.0 -> ActiveMQ impl using the Joram compliance suite. (Still not working). git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1394300 13f79535-47bb-0310-9956-ffa450edef68 --- activemq-amqp/pom.xml | 14 ++ .../transport/amqp/JMSClientTest.java | 2 +- .../transport/amqp/joram/ActiveMQAdmin.java | 153 ++++++++++++++++++ .../transport/amqp/joram/JoramJmsTest.java | 74 +++++++++ .../src/test/resources/provider.properties | 20 +++ 5 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/joram/ActiveMQAdmin.java create mode 100644 activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/joram/JoramJmsTest.java create mode 100644 activemq-amqp/src/test/resources/provider.properties diff --git a/activemq-amqp/pom.xml b/activemq-amqp/pom.xml index efeb30512f..dad743716f 100644 --- a/activemq-amqp/pom.xml +++ b/activemq-amqp/pom.xml @@ -59,6 +59,20 @@ test + + + org.fusesource.joram-jms-tests + joram-jms-tests + 1.0 + test + + + + org.eclipse.jetty.aggregate + jetty-all-server + test + + org.apache.activemq activemq-core diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java index 7bb4a60d8b..cbc8e6685a 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java @@ -32,7 +32,7 @@ public class JMSClientTest extends AmqpTestSupport { @Test public void testSendReceive() throws Exception { - QueueImpl queue = new QueueImpl("BURL:direct://amq.direct//test"); + QueueImpl queue = new QueueImpl("queue://testqueue"); int nMsgs = 100; final String dataFormat = "%01024d"; diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/joram/ActiveMQAdmin.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/joram/ActiveMQAdmin.java new file mode 100644 index 0000000000..f75e61183a --- /dev/null +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/joram/ActiveMQAdmin.java @@ -0,0 +1,153 @@ +/** + * 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.activemq.transport.amqp.joram; + +import org.apache.activemq.broker.BrokerFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; +import org.objectweb.jtests.jms.admin.Admin; +import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl; +import org.apache.qpid.amqp_1_0.jms.impl.QueueImpl; +import org.apache.qpid.amqp_1_0.jms.impl.TopicImpl; + +import javax.jms.ConnectionFactory; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import java.io.File; +import java.net.URI; +import java.util.Hashtable; + +/** + * + * @author Hiram Chirino + */ +public class ActiveMQAdmin implements Admin { + + Context context; + { + try { + // Use the jetty JNDI context since it's mutable. + final Hashtable env = new Hashtable(); + env.put("java.naming.factory.initial", "org.eclipse.jetty.jndi.InitialContextFactory"); + env.put("java.naming.factory.url.pkgs", "org.eclipse.jetty.jndi");; + context = new InitialContext(env); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + protected BrokerService createBroker() throws Exception { + return BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false")); + } + + public String getName() { + return getClass().getName(); + } + + BrokerService broker; + int port; + + public void startServer() throws Exception { + if (System.getProperty("basedir") == null) { + File file = new File("."); + System.setProperty("basedir", file.getAbsolutePath()); + } + broker = createBroker(); + broker.start(); + final TransportConnector connector = broker.addConnector("amqp://localhost:0"); + port = connector.getConnectUri().getPort(); + } + + public void stopServer() throws Exception { + broker.stop(); + } + + public void start() throws Exception { + } + + public void stop() throws Exception { + } + + public Context createContext() throws NamingException { + return context; + } + + public void createQueue(String name) { + try { + context.bind(name, new QueueImpl("queue://"+name)); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + public void createTopic(String name) { + try { + context.bind(name, new TopicImpl("topic://"+name)); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + public void deleteQueue(String name) { + // BrokerTestSupport.delete_queue((Broker)base.broker, name); + try { + context.unbind(name); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + public void deleteTopic(String name) { + try { + context.unbind(name); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + public void createConnectionFactory(String name) { + try { + final ConnectionFactory factory = new ConnectionFactoryImpl("localhost", port, null, null); + context.bind(name, factory); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + public void deleteConnectionFactory(String name) { + try { + context.unbind(name); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + public void createQueueConnectionFactory(String name) { + createConnectionFactory(name); + } + public void createTopicConnectionFactory(String name) { + createConnectionFactory(name); + } + public void deleteQueueConnectionFactory(String name) { + deleteConnectionFactory(name); + } + public void deleteTopicConnectionFactory(String name) { + deleteConnectionFactory(name); + } + +} diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/joram/JoramJmsTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/joram/JoramJmsTest.java new file mode 100644 index 0000000000..534a18e7e8 --- /dev/null +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/joram/JoramJmsTest.java @@ -0,0 +1,74 @@ +/** + * 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.activemq.transport.amqp.joram; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import org.objectweb.jtests.jms.conform.connection.ConnectionTest; +import org.objectweb.jtests.jms.conform.connection.TopicConnectionTest; +import org.objectweb.jtests.jms.conform.message.MessageBodyTest; +import org.objectweb.jtests.jms.conform.message.MessageDefaultTest; +import org.objectweb.jtests.jms.conform.message.MessageTypeTest; +import org.objectweb.jtests.jms.conform.message.headers.MessageHeaderTest; +import org.objectweb.jtests.jms.conform.message.properties.JMSXPropertyTest; +import org.objectweb.jtests.jms.conform.message.properties.MessagePropertyConversionTest; +import org.objectweb.jtests.jms.conform.message.properties.MessagePropertyTest; +import org.objectweb.jtests.jms.conform.queue.QueueBrowserTest; +import org.objectweb.jtests.jms.conform.queue.TemporaryQueueTest; +import org.objectweb.jtests.jms.conform.selector.SelectorSyntaxTest; +import org.objectweb.jtests.jms.conform.selector.SelectorTest; +import org.objectweb.jtests.jms.conform.session.QueueSessionTest; +import org.objectweb.jtests.jms.conform.session.SessionTest; +import org.objectweb.jtests.jms.conform.session.TopicSessionTest; +import org.objectweb.jtests.jms.conform.session.UnifiedSessionTest; +import org.objectweb.jtests.jms.conform.topic.TemporaryTopicTest; + +/** + * @author Hiram Chirino + */ +public class JoramJmsTest extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(); +// TODO: figure out why the following tests are failing.. +// suite.addTestSuite(ConnectionTest.class); +// suite.addTestSuite(TopicConnectionTest.class); +// suite.addTestSuite(MessageHeaderTest.class); +// suite.addTestSuite(MessageBodyTest.class); +// suite.addTestSuite(MessageDefaultTest.class); +// suite.addTestSuite(MessageTypeTest.class); +// suite.addTestSuite(JMSXPropertyTest.class); +// suite.addTestSuite(MessagePropertyConversionTest.class); +// suite.addTestSuite(TemporaryQueueTest.class); +// suite.addTestSuite(SelectorSyntaxTest.class); +// suite.addTestSuite(QueueSessionTest.class); +// suite.addTestSuite(SessionTest.class); +// suite.addTestSuite(TopicSessionTest.class); +// suite.addTestSuite(TemporaryTopicTest.class); +// suite.addTestSuite(UnifiedSessionTest.class); +// suite.addTestSuite(QueueBrowserTest.class); +// suite.addTestSuite(MessagePropertyTest.class); +// suite.addTestSuite(SelectorTest.class); + return suite; + } + + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + +} diff --git a/activemq-amqp/src/test/resources/provider.properties b/activemq-amqp/src/test/resources/provider.properties new file mode 100644 index 0000000000..76e08a38e8 --- /dev/null +++ b/activemq-amqp/src/test/resources/provider.properties @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# This config file is used by the joram jms tests. +# +jms.provider.admin.class=org.apache.activemq.transport.amqp.joram.ActiveMQAdmin \ No newline at end of file