use of mockit.Expectations in project java-chassis by ServiceComb.
the class TestHttpsClient method testInitKeyStore.
@Test
public void testInitKeyStore(@Mocked final HttpsConfigInfoBean configInfoBean, @Mocked final KeyManagerFactory factory) {
HttpsConfigInfoBean oBean = new HttpsConfigInfoBean();
new Expectations() {
{
configInfoBean.getKeyStorePath();
result = "/foundation-common/src/test/resources/config/test.1.properties";
configInfoBean.getKeyStorePasswd();
result = "1769";
configInfoBean.getTrustStorePath();
result = "/foundation-common/src/test/resources/config/test.1.properties";
configInfoBean.getTrustStorePasswd();
result = "1769";
}
};
new MockUp<KeyManagerFactory>() {
@Mock
public final void init(KeyStore ks, char[] password) {
}
@Mock
public final KeyManager[] getKeyManagers() {
return null;
}
};
String keyStoreType = KeyStore.getDefaultType();
try {
final KeyStore keyStore = KeyStore.getInstance(keyStoreType);
new MockUp<HttpsClient>() {
@Mock
private KeyStore initKeyStore(String storePath, String storePasswd, String storeType) throws IOException {
return keyStore;
}
};
} catch (KeyStoreException e) {
Assert.assertTrue(false);
}
HttpsClient.getHttpsClient(oBean);
Assert.assertNotEquals(null, HttpsClient.getHttpsClient(Mockito.mock(HttpsConfigInfoBean.class)));
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method receive_async_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_013: [The function shall create an async wrapper around the receive() function call]
@Test
public void receive_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.receive(Deencapsulation.getField(feedbackReceiver, "DEFAULT_TIMEOUT_MS"));
feedbackReceiver.receive();
}
};
// Act
CompletableFuture<FeedbackBatch> completableFuture = feedbackReceiver.receiveAsync();
completableFuture.get();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method receive_with_timout_call_receive_timeout_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_010: [The function shall call receive() on the member AMQPReceive object and return with the result]
@Test
public void receive_with_timout_call_receive_timeout_without_deviceId() throws Exception {
// Arrange
long timeoutMs = 1000;
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(timeoutMs);
}
};
// Act
feedbackReceiver.receive(timeoutMs);
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method open_call_receiver_open_without_deviceId.
// 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_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.open();
}
};
// Act
feedbackReceiver.open();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method close_call_receiver_close.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_007: [The function shall call close() on the member AMQPReceive object]
@Test
public void close_call_receiver_close() 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.close();
}
};
// Act
feedbackReceiver.close();
}
Aggregations