From 829a186f2a05ac50eef389bea5c407559cdccef0 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Tue, 29 Jul 2014 20:16:00 -0400 Subject: [PATCH] Revert to using non-parameterized tests, makes it simpler to debug. --- .../mqtt/MQTTCompositeQueueRetainedTest.java | 6 ++-- .../activemq/transport/mqtt/MQTTNIOTest.java | 33 +++++++++++++++++++ .../activemq/transport/mqtt/MQTTSSLTest.java | 33 +++++++++++++++++++ .../activemq/transport/mqtt/MQTTTest.java | 15 --------- .../transport/mqtt/MQTTTestSupport.java | 13 +++----- .../transport/mqtt/PahoMQTTNIOTest.java | 33 +++++++++++++++++++ .../activemq/transport/mqtt/PahoMQTTTest.java | 14 -------- 7 files changed, 106 insertions(+), 41 deletions(-) create mode 100644 activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTNIOTest.java create mode 100644 activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTSSLTest.java create mode 100644 activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTNIOTest.java diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTCompositeQueueRetainedTest.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTCompositeQueueRetainedTest.java index 33b5039b5e..4b1cc49df2 100644 --- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTCompositeQueueRetainedTest.java +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTCompositeQueueRetainedTest.java @@ -147,7 +147,7 @@ public class MQTTCompositeQueueRetainedTest extends MQTTTestSupport { bs = message.getContent(); assertEquals(RETAINED, new String(bs.data, bs.offset, bs.length)); assertTrue(message.getBooleanProperty(RetainedMessageSubscriptionRecoveryPolicy.RETAINED_PROPERTY)); - assertNull("Should not get second retained message from " + FORWARD_QUEUE, queueConsumer.receive(5000)); + assertNull("Should not get second retained message from " + FORWARD_QUEUE, queueConsumer.receive(2000)); // check whether we received retained message on mapped Topic, again message = (ActiveMQMessage) topicConsumer.receive(5000); @@ -155,11 +155,11 @@ public class MQTTCompositeQueueRetainedTest extends MQTTTestSupport { bs = message.getContent(); assertEquals(RETAINED, new String(bs.data, bs.offset, bs.length)); assertTrue(message.getBooleanProperty(RetainedMessageSubscriptionRecoveryPolicy.RETAINED_PROPERTY)); - assertNull("Should not get second retained message from " + FORWARD_TOPIC, topicConsumer.receive(5000)); + assertNull("Should not get second retained message from " + FORWARD_TOPIC, topicConsumer.receive(2000)); // create second queue consumer and verify that it doesn't trigger message recovery final MessageConsumer queueConsumer2 = s.createConsumer(jmsQueue); - assertNull("Second consumer MUST not receive retained message from " + FORWARD_QUEUE, queueConsumer2.receive(5000)); + assertNull("Second consumer MUST not receive retained message from " + FORWARD_QUEUE, queueConsumer2.receive(2000)); activeMQConnection.close(); provider.disconnect(); diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTNIOTest.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTNIOTest.java new file mode 100644 index 0000000000..abb5d6c4b8 --- /dev/null +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTNIOTest.java @@ -0,0 +1,33 @@ +/** + * 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.mqtt; + +/** + * Run the basic tests with the NIO Transport. + */ +public class MQTTNIOTest extends MQTTTest { + + @Override + public String getProtocolScheme() { + return "mqtt+nio"; + } + + @Override + public boolean isUseSSL() { + return false; + } +} diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTSSLTest.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTSSLTest.java new file mode 100644 index 0000000000..609c49d225 --- /dev/null +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTSSLTest.java @@ -0,0 +1,33 @@ +/** + * 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.mqtt; + +/** + * Run the basic tests with the NIO Transport. + */ +public class MQTTSSLTest extends MQTTTest { + + @Override + public String getProtocolScheme() { + return "mqtt+ssl"; + } + + @Override + public boolean isUseSSL() { + return true; + } +} diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java index 3fe3409efb..e332c48e23 100644 --- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java @@ -27,7 +27,6 @@ import static org.junit.Assert.fail; import java.net.ProtocolException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Random; @@ -64,29 +63,15 @@ import org.fusesource.mqtt.client.Tracer; import org.fusesource.mqtt.codec.MQTTFrame; import org.fusesource.mqtt.codec.PUBLISH; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@RunWith(Parameterized.class) public class MQTTTest extends MQTTTestSupport { private static final Logger LOG = LoggerFactory.getLogger(MQTTTest.class); private static final int NUM_MESSAGES = 250; - @Parameters(name= "{index}: scheme({0})") - public static Collection data() { - return Arrays.asList(new Object[][] { - {"mqtt", false}, - {"mqtt+ssl", true}, - {"mqtt+nio", false} - // TODO - Fails {"mqtt+nio+ssl", true} - }); - } - @Test(timeout = 60 * 1000) public void testSendAndReceiveMQTT() throws Exception { final MQTTClientProvider subscriptionProvider = getMQTTClientProvider(); diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTestSupport.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTestSupport.java index d2448616c4..470e273ac6 100644 --- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTestSupport.java +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTestSupport.java @@ -51,7 +51,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.rules.TestName; -import org.junit.runners.Parameterized.Parameter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,12 +65,8 @@ public class MQTTTestSupport { protected LinkedList exceptions = new LinkedList(); protected boolean persistent; protected String protocolConfig; - - @Parameter(0) - public String protocolScheme; - - @Parameter(1) - public boolean useSSL; + protected String protocolScheme; + protected boolean useSSL; public static final int AT_MOST_ONCE = 0; public static final int AT_LEAST_ONCE = 1; @@ -89,9 +84,9 @@ public class MQTTTestSupport { this.useSSL = false; } - public MQTTTestSupport(String connectorScheme, boolean useSsl) { + public MQTTTestSupport(String connectorScheme, boolean useSSL) { this.protocolScheme = connectorScheme; - this.useSSL = useSsl; + this.useSSL = useSSL; } public String getName() { diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTNIOTest.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTNIOTest.java new file mode 100644 index 0000000000..88c8780df8 --- /dev/null +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTNIOTest.java @@ -0,0 +1,33 @@ +/** + * 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.mqtt; + +/** + * Test the NIO transport with this Test group + */ +public class PahoMQTTNIOTest extends PahoMQTTTest { + + @Override + public String getProtocolScheme() { + return "mqtt+nio"; + } + + @Override + public boolean isUseSSL() { + return false; + } +} diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java index 17305be82e..498ea6dd7a 100644 --- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java @@ -20,8 +20,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import java.util.Arrays; -import java.util.Collection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -36,25 +34,13 @@ import org.apache.activemq.ActiveMQConnection; import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@RunWith(Parameterized.class) public class PahoMQTTTest extends MQTTTestSupport { private static final Logger LOG = LoggerFactory.getLogger(PahoMQTTTest.class); - @Parameters(name= "{index}: scheme({0})") - public static Collection data() { - return Arrays.asList(new Object[][] { - {"mqtt", false}, - {"mqtt+nio", false} - }); - } - @Test(timeout = 300000) public void testLotsOfClients() throws Exception {