Revert to using non-parameterized tests, makes it simpler to debug.

This commit is contained in:
Timothy Bish 2014-07-29 20:16:00 -04:00
parent e47e0e0463
commit 829a186f2a
7 changed files with 106 additions and 41 deletions

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<Object[]> 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();

View File

@ -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<Throwable> exceptions = new LinkedList<Throwable>();
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() {

View File

@ -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;
}
}

View File

@ -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<Object[]> data() {
return Arrays.asList(new Object[][] {
{"mqtt", false},
{"mqtt+nio", false}
});
}
@Test(timeout = 300000)
public void testLotsOfClients() throws Exception {