use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method receive_call_receive_timeout_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_008: [The function shall call receive(long timeoutMs) function with the default timeout]
@Test
public void receive_call_receive_timeout_without_deviceId() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
amqpReceive.receive(Deencapsulation.getField(feedbackReceiver, "DEFAULT_TIMEOUT_MS"));
}
};
// Act
feedbackReceiver.receive();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method open_call_receiver_open.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_005: [The function shall call open() on the member AMQPReceive object]
@Test
public void open_call_receiver_open() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
// Assert
new Expectations() {
{
amqpReceive.open();
}
};
// Act
feedbackReceiver.open();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method close_async_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_012: [The function shall create an async wrapper around the close() function call]
@Test
public void close_async_without_deviceId() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
amqpReceive.close();
feedbackReceiver.close();
}
};
// Act
CompletableFuture<Void> completableFuture = feedbackReceiver.closeAsync();
completableFuture.get();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class ServiceClientTest method close_call_sender_close.
// Tests_SRS_SERVICE_SDK_JAVA_SERVICECLIENT_12_011: [The function shall call close() on the member AMQP sender object]
@Test
public void close_call_sender_close() throws Exception {
// Arrange
String iotHubName = "IOTHUBNAME";
String hostName = "HOSTNAME";
String sharedAccessKeyName = "ACCESSKEYNAME";
String policyName = "SharedAccessKey";
String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
String connectionString = "HostName=" + hostName + "." + iotHubName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
ServiceClient serviceClient = ServiceClient.createFromConnectionString(connectionString, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
amqpSend.close();
}
};
// Act
serviceClient.close();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class ServiceClientTest method close_async_future_return_ok.
// Tests_SRS_SERVICE_SDK_JAVA_SERVICECLIENT_12_015: [The function shall create an async wrapper around the close() function call, handle the return value or delegate exception]
@Test
public void close_async_future_return_ok() throws Exception {
// Arrange
String iotHubName = "IOTHUBNAME";
String hostName = "HOSTNAME";
String sharedAccessKeyName = "ACCESSKEYNAME";
String policyName = "SharedAccessKey";
String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
String connectionString = "HostName=" + hostName + "." + iotHubName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
ServiceClient serviceClient = ServiceClient.createFromConnectionString(connectionString, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
amqpSend.close();
serviceClient.close();
}
};
// Act
CompletableFuture<Void> completableFuture = serviceClient.closeAsync();
completableFuture.get();
}
Aggregations