Search in sources :

Example 11 with HttpsSingleMessage

use of com.microsoft.azure.sdk.iot.device.transport.https.HttpsSingleMessage in project azure-iot-sdk-java by Azure.

the class HttpsSingleMessageTest method parseHttpsMessageFromResponseDoesNotIncludeNonAppProperties.

// Tests_SRS_HTTPSSINGLEMESSAGE_11_006: [The parsed HttpsSingleMessage shall include all valid HTTPS application-defined properties in the response header as message properties.]
@Test
public void parseHttpsMessageFromResponseDoesNotIncludeNonAppProperties(@Mocked final HttpsResponse mockResponse, @Mocked final MessageProperty mockProperty) {
    final byte[] body = { 0x61, 0x62, 0x63 };
    final Map<String, String> headerFields = new HashMap<>();
    final String propertyName = "test-property-name";
    final String propertyValue = "test-property-value";
    headerFields.put(propertyName, propertyValue);
    new NonStrictExpectations() {

        {
            mockResponse.getBody();
            result = body;
            mockResponse.getHeaderFields();
            result = headerFields;
        }
    };
    HttpsSingleMessage httpsMsg = HttpsSingleMessage.parseHttpsMessage(mockResponse);
    MessageProperty[] testProperties = httpsMsg.getProperties();
    MessageProperty[] expectedProperties = {};
    assertThat(testProperties, is(expectedProperties));
}
Also used : HashMap(java.util.HashMap) MessageProperty(com.microsoft.azure.sdk.iot.device.MessageProperty) NonStrictExpectations(mockit.NonStrictExpectations) HttpsSingleMessage(com.microsoft.azure.sdk.iot.device.transport.https.HttpsSingleMessage) Test(org.junit.Test)

Aggregations

HttpsSingleMessage (com.microsoft.azure.sdk.iot.device.transport.https.HttpsSingleMessage)11 Test (org.junit.Test)11 NonStrictExpectations (mockit.NonStrictExpectations)10 MessageProperty (com.microsoft.azure.sdk.iot.device.MessageProperty)8 HashMap (java.util.HashMap)5 Message (com.microsoft.azure.sdk.iot.device.Message)3 Verifications (mockit.Verifications)3 HttpsBatchMessage (com.microsoft.azure.sdk.iot.device.transport.https.HttpsBatchMessage)1