use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class ServiceClientTest method send_call_sender_close.
// Tests_SRS_SERVICE_SDK_JAVA_SERVICECLIENT_12_013: [The function shall call send() on the member AMQP sender object with the given parameters]
@Test
public void send_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);
String deviceId = "XXX";
String content = "HELLO";
Message iotMessage = new Message(content);
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
ServiceClient serviceClient = ServiceClient.createFromConnectionString(connectionString, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
amqpSend.send(deviceId, iotMessage);
}
};
// Act
serviceClient.send(deviceId, iotMessage);
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class ServiceClientTest method open_async_future_return_ok.
// Tests_SRS_SERVICE_SDK_JAVA_SERVICECLIENT_12_014: [The function shall create an async wrapper around the open() function call, handle the return value or delegate exception]
@Test
public void open_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.open();
serviceClient.open();
}
};
// Act
CompletableFuture<Void> completableFuture = serviceClient.openAsync();
completableFuture.get();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class ServiceClientTest method getFeedbackReceiver_good_case_without_deviceid.
// Tests_SRS_SERVICE_SDK_JAVA_SERVICECLIENT_12_017: [The function shall create a FeedbackReceiver object and returns with it]
@Test
public void getFeedbackReceiver_good_case_without_deviceid() 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;
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
ServiceClient serviceClient = ServiceClient.createFromConnectionString(connectionString, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
feedbackReceiver = new FeedbackReceiver(anyString, anyString, anyString, iotHubServiceClientProtocol);
}
};
// Act
FeedbackReceiver feedbackReceiver = serviceClient.getFeedbackReceiver();
// Assert
assertNotEquals(null, feedbackReceiver);
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class ToolsTest method isNullOrWhiteSpace_not_empty.
// Tests_SRS_SERVICE_SDK_JAVA_TOOLS_12_005: [The function shall call the isNullOrEmpty function and return with it’s return value]
@Test
public void isNullOrWhiteSpace_not_empty() {
// Arrange
String value = "XXX";
Boolean expResult = false;
new Expectations() {
Tools tools;
{
tools.isNullOrEmpty(anyString);
}
};
// Act
Boolean result = Tools.isNullOrWhiteSpace(value);
// Assert
assertEquals(expResult, result);
}
use of mockit.Expectations in project pulsar by yahoo.
the class AbstractStatelessLongHashTest method testCalculateByteBuffer.
@Test
public void testCalculateByteBuffer() {
final ByteBuffer input = ByteBuffer.allocate(20);
input.position(5);
input.limit(15);
new Expectations(hash) {
{
hash.calculateUnchecked(input.array(), input.arrayOffset() + 5, 10);
}
};
hash.calculate(input);
assertEquals(input.limit(), input.position());
}
Aggregations