Search in sources :

Example 36 with IotHubConnectionString

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

the class DeviceClientConfigTest method getandsetMessageValidSecsReturnsConstant.

// Tests_SRS_DEVICECLIENTCONFIG_25_008: [The function shall set the value of tokenValidSecs.]
@Test
public void getandsetMessageValidSecsReturnsConstant() throws URISyntaxException {
    final String iotHubHostname = "test.iothubhostname";
    final String deviceId = "test-deviceid";
    final String deviceKey = "test-devicekey";
    final String sharedAccessToken = null;
    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);
    long testsetMessageValidSecs = 60;
    config.setTokenValidSecs(testsetMessageValidSecs);
    long testgetMessageValidSecs = config.getTokenValidSecs();
    final long expectedMessageValidSecs = testsetMessageValidSecs;
    assertThat(testgetMessageValidSecs, is(expectedMessageValidSecs));
}
Also used : 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)

Example 37 with IotHubConnectionString

use of com.microsoft.azure.sdk.iot.device.IotHubConnectionString 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)

Example 38 with IotHubConnectionString

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

the class DeviceClientConfigTest method getAndSetDeviceMethodMessageCallbackAndContextsMatch.

/*
    **Tests_SRS_DEVICECLIENTCONFIG_25_022: [**The function shall return the current DeviceMethod message context.**] **
    **Tests_SRS_DEVICECLIENTCONFIG_25_023: [**The function shall set the DeviceTwin message callback.**] **
    **Tests_SRS_DEVICECLIENTCONFIG_25_021: [**The function shall return the current DeviceMethod message callback.**] **
    **Tests_SRS_DEVICECLIENTCONFIG_25_022: [**The function shall return the current DeviceMethod message context.**] **
     */
@Test
public void getAndSetDeviceMethodMessageCallbackAndContextsMatch(@Mocked final MessageCallback mockCallback) throws URISyntaxException {
    final String iotHubHostname = "test.iothubhostname";
    final String deviceId = "test-deviceid";
    final String deviceKey = "test-devicekey";
    final String sharedAccessToken = null;
    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);
    Object context = new Object();
    config.setDeviceMethodMessageCallback(mockCallback, context);
    Object testContext = config.getDeviceMethodMessageContext();
    final Object expectedContext = context;
    assertThat(testContext, is(expectedContext));
    assertEquals(config.getDeviceMethodMessageCallback(), mockCallback);
}
Also used : 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)

Example 39 with IotHubConnectionString

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

the class DeviceClientConfigTest method getMessageValidSecsReturnsConstant.

// Tests_SRS_DEVICECLIENTCONFIG_11_005: [The function shall return the value of tokenValidSecs.]
@Test
public void getMessageValidSecsReturnsConstant() throws URISyntaxException {
    final String iotHubHostname = "test.iothubhostname";
    final String deviceId = "test-deviceid";
    final String deviceKey = "test-devicekey";
    final String sharedAccessToken = null;
    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);
    long testMessageValidSecs = config.getTokenValidSecs();
    final long expectedMessageValidSecs = 3600;
    assertThat(testMessageValidSecs, is(expectedMessageValidSecs));
}
Also used : 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)

Example 40 with IotHubConnectionString

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

the class DeviceClientConfigTest method setUserCertificateSets.

//Tests_SRS_DEVICECLIENTCONFIG_25_029: [**The function shall set user certificate String**] **
@Test
public void setUserCertificateSets() 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.setUserCertificateString(cert);
    String testCert = config.getUserCertificateString();
    assertNotNull(cert);
    assertEquals(testCert, cert);
}
Also used : 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

IotHubConnectionString (com.microsoft.azure.sdk.iot.device.IotHubConnectionString)64 Test (org.junit.Test)63 DeviceClientConfig (com.microsoft.azure.sdk.iot.device.DeviceClientConfig)31 IotHubSasToken (com.microsoft.azure.sdk.iot.device.auth.IotHubSasToken)27 NonStrictExpectations (mockit.NonStrictExpectations)9 IotHubSSLContext (com.microsoft.azure.sdk.iot.device.IotHubSSLContext)2 Message (com.microsoft.azure.sdk.iot.device.Message)1 MessageCallback (com.microsoft.azure.sdk.iot.device.MessageCallback)1 MessageType (com.microsoft.azure.sdk.iot.device.MessageType)1 Date (java.util.Date)1