Search in sources :

Example 6 with IotHubSSLContext

use of com.microsoft.azure.sdk.iot.device.IotHubSSLContext in project azure-iot-sdk-java by Azure.

the class IotHubSSLContextTest method constructorWithInvalidCertPathThrows.

@Test(expected = IOException.class)
public void constructorWithInvalidCertPathThrows() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException, CertificateException {
    new Expectations() {

        {
            Deencapsulation.invoke(mockedDefaultCert, "setValidCertPath", anyString);
            result = new FileNotFoundException();
        }
    };
    //act
    IotHubSSLContext testContext = Deencapsulation.newInstance(IotHubSSLContext.class, "/Invalid/Test/Cert/Path", true);
}
Also used : IotHubSSLContext(com.microsoft.azure.sdk.iot.device.IotHubSSLContext) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.Test)

Example 7 with IotHubSSLContext

use of com.microsoft.azure.sdk.iot.device.IotHubSSLContext in project azure-iot-sdk-java by Azure.

the class DeviceClientConfigTest method getIotHubSSLContextGets.

//Tests_SRS_DEVICECLIENTCONFIG_25_032: [**The function shall return the IotHubSSLContext.**] **
@Test
public void getIotHubSSLContextGets(@Mocked final IotHubSSLContext mockedContext) throws URISyntaxException {
    final String iotHubHostname = "test.iothubhostname";
    final String deviceId = "test-deviceid";
    final String deviceKey = "test-devicekey";
    final String sharedAccessToken = null;
    final String cert = "ValidCertString";
    final IotHubConnectionString iotHubConnectionString = Deencapsulation.newInstance(IotHubConnectionString.class, new Class[] { String.class, String.class, String.class, String.class }, iotHubHostname, deviceId, deviceKey, sharedAccessToken);
    DeviceClientConfig config = new DeviceClientConfig(iotHubConnectionString);
    config.setIotHubSSLContext(mockedContext);
    IotHubSSLContext testContext = config.getIotHubSSLContext();
    assertNotNull(testContext);
    assertEquals(testContext, mockedContext);
}
Also used : IotHubSSLContext(com.microsoft.azure.sdk.iot.device.IotHubSSLContext) DeviceClientConfig(com.microsoft.azure.sdk.iot.device.DeviceClientConfig) IotHubConnectionString(com.microsoft.azure.sdk.iot.device.IotHubConnectionString) IotHubConnectionString(com.microsoft.azure.sdk.iot.device.IotHubConnectionString) Test(org.junit.Test)

Aggregations

IotHubSSLContext (com.microsoft.azure.sdk.iot.device.IotHubSSLContext)7 Test (org.junit.Test)7 DeviceClientConfig (com.microsoft.azure.sdk.iot.device.DeviceClientConfig)2 IotHubConnectionString (com.microsoft.azure.sdk.iot.device.IotHubConnectionString)2 FileNotFoundException (java.io.FileNotFoundException)1 SSLContext (javax.net.ssl.SSLContext)1