use of com.microsoft.azure.sdk.iot.device.Message in project azure-iot-sdk-java by Azure.
the class MqttTest method receiveReturnsNullMessageWhenParseTopicReturnsNull.
/*
**Tests_SRS_Mqtt_25_022: [**If the call parseTopic returns null or empty string then this method shall do nothing and return null**]**
*/
@Test
public void receiveReturnsNullMessageWhenParseTopicReturnsNull() throws IOException, MqttException {
//arrange
final byte[] payload = { 0x61, 0x62, 0x63 };
baseConstructorExpectations(true);
baseConnectExpectation();
new MockUp<MqttMessaging>() {
@Mock
String parseTopic() throws IOException {
return null;
}
@Mock
byte[] parsePayload(String topic) throws IOException {
return payload;
}
};
final Mqtt mockMqtt = new MqttMessaging(serverUri, clientId, userName, password, mockIotHubSSLContext);
try {
new NonStrictExpectations() {
{
mockMqttAsyncClient.isConnected();
result = true;
}
};
Deencapsulation.invoke(mockMqtt, "connect");
//act
Message receivedMessage = mockMqtt.receive();
//assert
assertNull(receivedMessage);
} finally {
testCleanUp(mockMqtt);
}
}
Aggregations