Author: veithen
Date: Thu Oct 16 15:43:43 2008
New Revision: 705385
URL: http://svn.apache.org/viewvc?rev=705385&view=rev
Log:
JMS transport tests: Explicitly create and delete queues when Qpid is used as
JMS provider. This should avoid random test failures caused by messages being
sent to queues that don't exist because they don't have been auto-created yet.
Added:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidUtil.java
Modified:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/ActiveMQTestEnvironment.java
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSChannel.java
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseChannel.java
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTestEnvironment.java
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidTestEnvironment.java
Modified:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/ActiveMQTestEnvironment.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/ActiveMQTestEnvironment.java?rev=705385&r1=705384&r2=705385&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/ActiveMQTestEnvironment.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/ActiveMQTestEnvironment.java
Thu Oct 16 15:43:43 2008
@@ -19,6 +19,7 @@
package org.apache.axis2.transport.jms;
+import javax.jms.Destination;
import javax.jms.Queue;
import javax.jms.Topic;
@@ -67,4 +68,8 @@
public Topic createTopic(String name) {
return new ActiveMQTopic(name);
}
+
+ @Override
+ public void deleteDestination(Destination destination) throws Exception {
+ }
}
Modified:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSChannel.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSChannel.java?rev=705385&r1=705384&r2=705385&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSChannel.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSChannel.java
Thu Oct 16 15:43:43 2008
@@ -91,6 +91,7 @@
@TearDown @SuppressWarnings("unused")
private void tearDown() throws Exception {
context.unbind(jndiName);
+ env.deleteDestination(destination);
}
@Key("destType")
Modified:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseChannel.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseChannel.java?rev=705385&r1=705384&r2=705385&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseChannel.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseChannel.java
Thu Oct 16 15:43:43 2008
@@ -57,6 +57,7 @@
@TearDown @SuppressWarnings("unused")
private void tearDown() throws Exception {
context.unbind(replyJndiName);
+ env.deleteDestination(replyDestination);
}
@Override
Modified:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTestEnvironment.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTestEnvironment.java?rev=705385&r1=705384&r2=705385&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTestEnvironment.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTestEnvironment.java
Thu Oct 16 15:43:43 2008
@@ -39,7 +39,7 @@
protected abstract ConnectionFactory createConnectionFactory() throws
Exception;
- public Destination createDestination(String destinationType, String name) {
+ public Destination createDestination(String destinationType, String name)
throws Exception {
if (destinationType.equals(JMSConstants.DESTINATION_TYPE_TOPIC)) {
return createTopic(name);
} else {
@@ -47,8 +47,10 @@
}
}
- public abstract Queue createQueue(String name);
- public abstract Topic createTopic(String name);
+ public abstract Queue createQueue(String name) throws Exception;
+ public abstract Topic createTopic(String name) throws Exception;
+
+ public abstract void deleteDestination(Destination destination) throws
Exception;
public ConnectionFactory getConnectionFactory() {
return connectionFactory;
Modified:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java?rev=705385&r1=705384&r2=705385&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
Thu Oct 16 15:43:43 2008
@@ -76,7 +76,6 @@
throw new UnsupportedOperationException("Unsupported
message type");
}
reply.setJMSCorrelationID(message.getJMSMessageID());
- Thread.sleep(50);
producer.send(reply);
log.info("Message sent: ID = " + reply.getJMSMessageID());
} catch (Throwable ex) {
Modified:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidTestEnvironment.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidTestEnvironment.java?rev=705385&r1=705384&r2=705385&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidTestEnvironment.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidTestEnvironment.java
Thu Oct 16 15:43:43 2008
@@ -19,23 +19,33 @@
package org.apache.axis2.transport.jms;
+import javax.jms.Destination;
import javax.jms.Queue;
import javax.jms.Topic;
import org.apache.axis2.transport.testkit.name.Name;
import org.apache.axis2.transport.testkit.tests.Setup;
import org.apache.axis2.transport.testkit.tests.TearDown;
+import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnectionFactory;
+import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.virtualhost.VirtualHost;
@Name("qpid")
public class QpidTestEnvironment extends JMSTestEnvironment {
+ private VirtualHost virtualHost;
+
@Setup @SuppressWarnings("unused")
private void setUp() throws Exception {
TransportConnection.createVMBroker(1);
+ // null means the default virtual host
+ virtualHost =
ApplicationRegistry.getInstance(1).getVirtualHostRegistry().getVirtualHost(null);
}
@TearDown @SuppressWarnings("unused")
@@ -49,12 +59,19 @@
}
@Override
- public Queue createQueue(String name) {
- return new AMQQueue(name, name);
+ public Queue createQueue(String name) throws AMQException {
+ QpidUtil.createQueue(virtualHost,
ExchangeDefaults.DIRECT_EXCHANGE_NAME, name);
+ return new AMQQueue(ExchangeDefaults.DIRECT_EXCHANGE_NAME, name);
}
@Override
- public Topic createTopic(String name) {
- return new AMQTopic(new AMQShortString(name), name);
+ public Topic createTopic(String name) throws AMQException {
+ QpidUtil.createQueue(virtualHost,
ExchangeDefaults.TOPIC_EXCHANGE_NAME, name);
+ return new AMQTopic(ExchangeDefaults.TOPIC_EXCHANGE_NAME, name);
+ }
+
+ @Override
+ public void deleteDestination(Destination destination) throws Exception {
+ QpidUtil.deleteQueue(virtualHost,
((AMQDestination)destination).getDestinationName().asString());
}
}
Added:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidUtil.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidUtil.java?rev=705385&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidUtil.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/QpidUtil.java
Thu Oct 16 15:43:43 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.axis2.transport.jms;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.QueueRegistry;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+
+public class QpidUtil {
+ private QpidUtil() {}
+
+ public static void createQueue(VirtualHost virtualHost, AMQShortString
exchangeName, String name) throws AMQException {
+ AMQShortString _name = new AMQShortString(name);
+ QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
+ if (queueRegistry.getQueue(_name) != null) {
+ throw new IllegalStateException("Queue " + name + " already
exists");
+ }
+ AMQQueue queue = new AMQQueue(_name, false, null, false, virtualHost);
+ queueRegistry.registerQueue(queue);
+ queue.bind(_name, null,
virtualHost.getExchangeRegistry().getExchange(exchangeName));
+ }
+
+ public static void deleteQueue(VirtualHost virtualHost, String name)
throws AMQException {
+ AMQShortString _name = new AMQShortString(name);
+ AMQQueue queue = virtualHost.getQueueRegistry().getQueue(_name);
+ if (queue == null) {
+ throw new IllegalArgumentException("Queue " + name + " doesn't
exist");
+ }
+ queue.delete();
+ }
+}