mirror of https://github.com/apache/activemq.git
Revert to using non-parameterized tests, makes it simpler to debug.
This commit is contained in:
parent
e47e0e0463
commit
829a186f2a
|
@ -147,7 +147,7 @@ public class MQTTCompositeQueueRetainedTest extends MQTTTestSupport {
|
||||||
bs = message.getContent();
|
bs = message.getContent();
|
||||||
assertEquals(RETAINED, new String(bs.data, bs.offset, bs.length));
|
assertEquals(RETAINED, new String(bs.data, bs.offset, bs.length));
|
||||||
assertTrue(message.getBooleanProperty(RetainedMessageSubscriptionRecoveryPolicy.RETAINED_PROPERTY));
|
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
|
// check whether we received retained message on mapped Topic, again
|
||||||
message = (ActiveMQMessage) topicConsumer.receive(5000);
|
message = (ActiveMQMessage) topicConsumer.receive(5000);
|
||||||
|
@ -155,11 +155,11 @@ public class MQTTCompositeQueueRetainedTest extends MQTTTestSupport {
|
||||||
bs = message.getContent();
|
bs = message.getContent();
|
||||||
assertEquals(RETAINED, new String(bs.data, bs.offset, bs.length));
|
assertEquals(RETAINED, new String(bs.data, bs.offset, bs.length));
|
||||||
assertTrue(message.getBooleanProperty(RetainedMessageSubscriptionRecoveryPolicy.RETAINED_PROPERTY));
|
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
|
// create second queue consumer and verify that it doesn't trigger message recovery
|
||||||
final MessageConsumer queueConsumer2 = s.createConsumer(jmsQueue);
|
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();
|
activeMQConnection.close();
|
||||||
provider.disconnect();
|
provider.disconnect();
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,6 @@ import static org.junit.Assert.fail;
|
||||||
import java.net.ProtocolException;
|
import java.net.ProtocolException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
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.MQTTFrame;
|
||||||
import org.fusesource.mqtt.codec.PUBLISH;
|
import org.fusesource.mqtt.codec.PUBLISH;
|
||||||
import org.junit.Test;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class MQTTTest extends MQTTTestSupport {
|
public class MQTTTest extends MQTTTestSupport {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(MQTTTest.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MQTTTest.class);
|
||||||
|
|
||||||
private static final int NUM_MESSAGES = 250;
|
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)
|
@Test(timeout = 60 * 1000)
|
||||||
public void testSendAndReceiveMQTT() throws Exception {
|
public void testSendAndReceiveMQTT() throws Exception {
|
||||||
final MQTTClientProvider subscriptionProvider = getMQTTClientProvider();
|
final MQTTClientProvider subscriptionProvider = getMQTTClientProvider();
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.rules.TestName;
|
import org.junit.rules.TestName;
|
||||||
import org.junit.runners.Parameterized.Parameter;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -66,12 +65,8 @@ public class MQTTTestSupport {
|
||||||
protected LinkedList<Throwable> exceptions = new LinkedList<Throwable>();
|
protected LinkedList<Throwable> exceptions = new LinkedList<Throwable>();
|
||||||
protected boolean persistent;
|
protected boolean persistent;
|
||||||
protected String protocolConfig;
|
protected String protocolConfig;
|
||||||
|
protected String protocolScheme;
|
||||||
@Parameter(0)
|
protected boolean useSSL;
|
||||||
public String protocolScheme;
|
|
||||||
|
|
||||||
@Parameter(1)
|
|
||||||
public boolean useSSL;
|
|
||||||
|
|
||||||
public static final int AT_MOST_ONCE = 0;
|
public static final int AT_MOST_ONCE = 0;
|
||||||
public static final int AT_LEAST_ONCE = 1;
|
public static final int AT_LEAST_ONCE = 1;
|
||||||
|
@ -89,9 +84,9 @@ public class MQTTTestSupport {
|
||||||
this.useSSL = false;
|
this.useSSL = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MQTTTestSupport(String connectorScheme, boolean useSsl) {
|
public MQTTTestSupport(String connectorScheme, boolean useSSL) {
|
||||||
this.protocolScheme = connectorScheme;
|
this.protocolScheme = connectorScheme;
|
||||||
this.useSSL = useSsl;
|
this.useSSL = useSSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,8 +20,6 @@ import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
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.MqttClient;
|
||||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||||
import org.junit.Test;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class PahoMQTTTest extends MQTTTestSupport {
|
public class PahoMQTTTest extends MQTTTestSupport {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(PahoMQTTTest.class);
|
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)
|
@Test(timeout = 300000)
|
||||||
public void testLotsOfClients() throws Exception {
|
public void testLotsOfClients() throws Exception {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue