Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,14 @@ public boolean needsReconnect()
return true;
}

for (MultiplexedDeviceState multiplexedDeviceState : this.multiplexedDeviceConnectionStates.values())
if (this.isMultiplexing)
{
if (multiplexedDeviceState.getConnectionStatus() == IotHubConnectionStatus.DISCONNECTED_RETRYING)
for (MultiplexedDeviceState multiplexedDeviceState : this.multiplexedDeviceConnectionStates.values())
{
return true;
if (multiplexedDeviceState.getConnectionStatus() == IotHubConnectionStatus.DISCONNECTED_RETRYING)
{
return true;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,50 @@ public void constructorThrowsForNullConfig()
IotHubTransport transport = new IotHubTransport(null, mockedIotHubConnectionStatusChangeCallback, false);
}

@Test
public void needsReconnectIgnoresDeviceSessionStateWhenNotMultiplexing()
{
//arrange
new Expectations()
{
{
mockedConfig.getDeviceId();
result = "someDeviceId";
}
};
IotHubTransport transport = new IotHubTransport(mockedConfig, mockedIotHubConnectionStatusChangeCallback, false);
Map<String, MultiplexedDeviceState> deviceConnectionStates = Deencapsulation.getField(transport, "multiplexedDeviceConnectionStates");
deviceConnectionStates.values().iterator().next().setConnectionStatus(DISCONNECTED_RETRYING);

//act
boolean needsReconnect = transport.needsReconnect();

//assert
assertFalse(needsReconnect);
}

@Test
public void needsReconnectChecksDeviceSessionStateWhenMultiplexing()
{
//arrange
new Expectations()
{
{
mockedConfig.getDeviceId();
result = "someDeviceId";
}
};
IotHubTransport transport = new IotHubTransport(mockedConfig, mockedIotHubConnectionStatusChangeCallback, true);
Map<String, MultiplexedDeviceState> deviceConnectionStates = Deencapsulation.getField(transport, "multiplexedDeviceConnectionStates");
deviceConnectionStates.values().iterator().next().setConnectionStatus(DISCONNECTED_RETRYING);

//act
boolean needsReconnect = transport.needsReconnect();

//assert
assertTrue(needsReconnect);
}

//Tests_SRS_IOTHUBTRANSPORT_34_004: [This function shall retrieve a packet from the inProgressPackets queue with the message id from the provided message if there is one.]
//Tests_SRS_IOTHUBTRANSPORT_34_006: [If there was a packet in the inProgressPackets queue tied to the provided message, and the provided throwable is a TransportException, this function shall call "handleMessageException" with the provided packet and transport exception.]
@Test
Expand Down