use of org.apache.qpid.proton.reactor.Handshaker in project azure-iot-sdk-java by Azure.
the class AmqpsIotHubConnectionTest method constructorCopiesAllData.
// Tests_SRS_AMQPSIOTHUBCONNECTION_15_002: [The constructor shall save the configuration into private member variables.]
// Tests_SRS_AMQPSIOTHUBCONNECTION_15_003: [The constructor shall initialize the sender and receiver
// endpoint private member variables using the send/receiveEndpointFormat constants and device id.]
// Tests_SRS_AMQPSIOTHUBCONNECTION_15_004: [The constructor shall initialize a new Handshaker
// (Proton) object to handle communication handshake.]
// Tests_SRS_AMQPSIOTHUBCONNECTION_15_005: [The constructor shall initialize a new FlowController
// (Proton) object to handle communication flow.]
// Tests_SRS_AMQPSIOTHUBCONNECTION_15_006: [The constructor shall set its state to CLOSED.]
@Test
public void constructorCopiesAllData() throws IOException {
baseExpectations();
AmqpsIotHubConnection connection = new AmqpsIotHubConnection(mockConfig, false);
DeviceClientConfig actualConfig = Deencapsulation.getField(connection, "config");
String actualHostName = Deencapsulation.getField(connection, "hostName");
String actualUserName = Deencapsulation.getField(connection, "userName");
String actualSendEndpoint = Deencapsulation.getField(connection, "sendEndpoint");
String actualReceiveEndpoint = Deencapsulation.getField(connection, "receiveEndpoint");
assertEquals(mockConfig, actualConfig);
assertEquals(hostName + ":" + amqpPort, actualHostName);
assertEquals(deviceId + "@sas." + hubName, actualUserName);
String expectedSendEndpoint = "/devices/test-deviceId/messages/events";
assertEquals(expectedSendEndpoint, actualSendEndpoint);
String expectedReceiveEndpoint = "/devices/test-deviceId/messages/devicebound";
assertEquals(expectedReceiveEndpoint, actualReceiveEndpoint);
new Verifications() {
{
new Handshaker();
times = 1;
new FlowController();
times = 1;
}
};
State actualState = Deencapsulation.getField(connection, "state");
assertEquals(State.CLOSED, actualState);
}
use of org.apache.qpid.proton.reactor.Handshaker in project azure-iot-sdk-java by Azure.
the class AmqpSendHandlerTest method constructor_copies_params_to_members.
// Test_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_001: [The constructor shall copy all input parameters to private member variables for event processing]
// Test_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_002: [The constructor shall concatenate the host name with the port]
// Test_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_003: [The constructor shall initialize a new Handshaker (Proton) object to handle communication handshake]
@Test
public void constructor_copies_params_to_members() {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
new Expectations() {
{
handshaker = new Handshaker();
}
};
// Act
AmqpSendHandler amqpSendHandler = new AmqpSendHandler(hostName, userName, sasToken, iotHubServiceClientProtocol);
String _hostName = Deencapsulation.getField(amqpSendHandler, "hostName");
String _userName = Deencapsulation.getField(amqpSendHandler, "userName");
String _sasToken = Deencapsulation.getField(amqpSendHandler, "sasToken");
IotHubServiceClientProtocol _ioIotHubServiceClientProtocol = Deencapsulation.getField(amqpSendHandler, "iotHubServiceClientProtocol");
// Assert
assertEquals(hostName + ":5671", _hostName);
assertEquals(userName, _userName);
assertEquals(sasToken, _sasToken);
assertEquals(iotHubServiceClientProtocol, _ioIotHubServiceClientProtocol);
}
Aggregations