use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttTransport in project azure-iot-sdk-java by Azure.
the class MqttTransportTest method handleMessageFailsIfTransportNeverOpened.
// Tests_SRS_MQTTTRANSPORT_15_018: [If the MQTT connection is closed,
// the function shall throw an IllegalStateException.]
@Test(expected = IllegalStateException.class)
public void handleMessageFailsIfTransportNeverOpened() throws IOException {
MqttTransport transport = new MqttTransport(mockConfig);
transport.handleMessage();
}
use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttTransport in project azure-iot-sdk-java by Azure.
the class MqttTransportTest method openDoesNothingIfAlreadyOpened.
// SRS_MQTTTRANSPORT_15_004: [If the MQTT connection is already open, the function shall do nothing.]
@Test
public void openDoesNothingIfAlreadyOpened() throws IOException {
MqttTransport transport = new MqttTransport(mockConfig);
transport.open();
transport.open();
final MqttIotHubConnection expectedConnection = mockConnection;
new Verifications() {
{
expectedConnection.open();
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttTransport in project azure-iot-sdk-java by Azure.
the class MqttTransportTest method openOpensMqttConnection.
// Tests_SRS_MQTTTRANSPORT_15_003: [The function shall establish an MQTT connection
// with IoT Hub given in the configuration.]
@Test
public void openOpensMqttConnection() throws IOException, NoSuchFieldException, IllegalAccessException {
new NonStrictExpectations() {
{
new MqttIotHubConnection(mockConfig);
result = mockConnection;
}
};
MqttTransport transport = new MqttTransport(mockConfig);
transport.open();
final MqttIotHubConnection expectedConnection = mockConnection;
new Verifications() {
{
expectedConnection.open();
}
};
Field sendMessagesLock = transport.getClass().getDeclaredField("sendMessagesLock");
sendMessagesLock.setAccessible(true);
assertNotNull(sendMessagesLock.get(transport));
Field handleMessageLock = transport.getClass().getDeclaredField("handleMessageLock");
handleMessageLock.setAccessible(true);
assertNotNull(handleMessageLock.get(transport));
}
use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttTransport in project azure-iot-sdk-java by Azure.
the class MqttTransportTest method invokeCallbacksFailsIfTransportNeverOpened.
// Tests_SRS_MQTTTRANSPORT_15_014: [If the transport is closed, the function shall throw an IllegalStateException.]
@Test(expected = IllegalStateException.class)
public void invokeCallbacksFailsIfTransportNeverOpened() throws IOException {
MqttTransport transport = new MqttTransport(mockConfig);
transport.invokeCallbacks();
}
use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttTransport in project azure-iot-sdk-java by Azure.
the class MqttTransportTest method closeClosesMqttConnection.
// Tests_SRS_MQTTTRANSPORT_15_005: [The function shall close the MQTT connection
// with the IoT Hub given in the configuration.]
@Test
public void closeClosesMqttConnection() throws IOException {
MqttTransport transport = new MqttTransport(mockConfig);
transport.open();
transport.close();
final MqttIotHubConnection expectedConnection = mockConnection;
new Verifications() {
{
expectedConnection.close();
}
};
}
Aggregations