disabling failed assertion for test as it is expected based on how this
test is usin the client
This commit is contained in:
Christopher L. Shannon (cshannon) 2016-07-07 18:23:50 +00:00
parent b5b087d558
commit 667ea7c640
1 changed files with 17 additions and 0 deletions

View File

@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.activemq.util.Wait;
import org.apache.activemq.util.Wait.Condition;
import org.fusesource.hawtdispatch.DispatchQueue;
import org.fusesource.hawtdispatch.internal.SerialDispatchQueue;
import org.fusesource.hawtdispatch.transport.Transport;
import org.fusesource.mqtt.client.BlockingConnection;
import org.fusesource.mqtt.client.Callback;
@ -46,6 +48,7 @@ import org.junit.rules.Timeout;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -114,6 +117,8 @@ public class MQTTPingReqTest extends MQTTTestSupport {
fail(error.get().getMessage());
}
disableDispatchAssertion(transport.get());
//Send a PINGREQ without a connect packet first
final MQTTProtocolCodec codec = new MQTTProtocolCodec();
codec.setTransport(transport.get());
@ -153,6 +158,7 @@ public class MQTTPingReqTest extends MQTTTestSupport {
BlockingConnection connection = new BlockingConnection(new FutureConnection(callbackConnection));
connection.connect();
Transport transport = callbackConnection.transport();
disableDispatchAssertion(transport);
//SEND a PINGREQ and wait for the response
final MQTTProtocolCodec codec = new MQTTProtocolCodec();
@ -162,4 +168,15 @@ public class MQTTPingReqTest extends MQTTTestSupport {
//Wait for the response
assertTrue(pingRespReceived.await(5, TimeUnit.SECONDS));
}
private void disableDispatchAssertion(final Transport transport) {
//Since we are purposefully bypassing the normal way of sending a packet, turn off the
//assertion
DispatchQueue dispatchQueue = transport.getDispatchQueue();
if (dispatchQueue instanceof SerialDispatchQueue) {
SerialDispatchQueue spyQueue = Mockito.spy((SerialDispatchQueue)dispatchQueue);
Mockito.doNothing().when(spyQueue).assertExecuting();
transport.setDispatchQueue(spyQueue);
}
}
}