From d8c2eda6e8354ddbfd5f30072cb907b1d68877f9 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Tue, 11 Feb 2014 12:05:46 -0500 Subject: [PATCH] Add a NIO variant of the JMS clent tests for working through NIO transport issues. --- .../transport/amqp/JMSClientNioTest.java | 137 ++++++++++++++++++ .../transport/amqp/JMSClientTest.java | 16 +- 2 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientNioTest.java diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientNioTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientNioTest.java new file mode 100644 index 0000000000..42420e2efa --- /dev/null +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientNioTest.java @@ -0,0 +1,137 @@ +/** + * 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; + +import javax.jms.JMSException; + +import org.junit.Test; + +/** + * Test the JMS client when connected to the NIO transport. + */ +public class JMSClientNioTest extends JMSClientTest { + + @Override + @Test + public void testProducerConsume() throws Exception { + } + + @Override + @Test + public void testTransactedConsumer() throws Exception { + } + + @Override + @Test + public void testRollbackRececeivedMessage() throws Exception { + } + + @Override + @Test + public void testTXConsumerAndLargeNumberOfMessages() throws Exception { + } + + @Override + @Test + public void testSelectors() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testProducerThrowsWhenBrokerStops() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testProducerCreateThrowsWhenBrokerStops() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testConsumerCreateThrowsWhenBrokerStops() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testConsumerReceiveNoWaitThrowsWhenBrokerStops() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testConsumerReceiveTimedThrowsWhenBrokerStops() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testConsumerReceiveReturnsBrokerStops() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testBrokerRestartWontHangConnectionClose() throws Exception { + } + + @Override + @Test(timeout=120000) + public void testProduceAndConsumeLargeNumbersOfMessages() throws JMSException { + } + + @Override + @Test(timeout=30000) + public void testSyncSends() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testDurableConsumerAsync() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testDurableConsumerSync() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testTopicConsumerAsync() throws Exception { + } + + @Override + @Test(timeout=45000) + public void testTopicConsumerSync() throws Exception { + } + + @Override + @Test(timeout=60000) + public void testConnectionsAreClosed() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testExecptionListenerCalledOnBrokerStop() throws Exception { + } + + @Override + @Test(timeout=30000) + public void testSessionTransactedCommit() throws JMSException, InterruptedException { + } + + @Override + protected int getBrokerPort() { + return nioPort; + } +} 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 2d4df4fc9f..5d16ffc63d 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 @@ -48,7 +48,6 @@ import org.apache.activemq.transport.amqp.joram.ActiveMQAdmin; import org.apache.activemq.util.Wait; import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; @@ -669,14 +668,12 @@ public class JMSClientTest extends AmqpTestSupport { })); } - @Ignore("AMQ-5041") @Test(timeout=30000) public void testExecptionListenerCalledOnBrokerStop() throws Exception { ActiveMQAdmin.enableJMSFrameTracing(); Connection connection = createConnection(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Queue queue = session.createQueue(name.toString()); + connection.createSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); final CountDownLatch called = new CountDownLatch(1); @@ -752,9 +749,18 @@ public class JMSClientTest extends AmqpTestSupport { return createConnection(clientId, false); } + /** + * Can be overridden in subclasses to test against a different transport suchs as NIO. + * + * @return the port to connect to on the Broker. + */ + protected int getBrokerPort() { + return port; + } + private Connection createConnection(String clientId, boolean syncPublish) throws JMSException { - final ConnectionFactoryImpl factory = new ConnectionFactoryImpl("localhost", port, "admin", "password"); + final ConnectionFactoryImpl factory = new ConnectionFactoryImpl("localhost", getBrokerPort(), "admin", "password"); factory.setSyncPublish(syncPublish); factory.setTopicPrefix("topic://");