use of com.microsoft.azure.sdk.iot.service.transport.http.HttpResponse in project azure-iot-sdk-java by Azure.
the class HttpsResponseTest method getHeaderFieldRejectsInvalidFieldName.
// Tests_SRS_SERVICE_SDK_JAVA_HTTPSRESPONSE_12_006: [If a value could not be found for the given header field name, the function shall throw an IllegalArgumentException.]
// Assert
@Test(expected = IllegalArgumentException.class)
public void getHeaderFieldRejectsInvalidFieldName() throws IllegalArgumentException {
// Arrange
final int status = 200;
final byte[] body = { 1 };
final byte[] errorReason = {};
final Map<String, List<String>> headerFields = new HashMap<>();
final String field = "test-field";
// Act
HttpResponse response = new HttpResponse(status, body, headerFields, errorReason);
response.getHeaderField(field);
}
use of com.microsoft.azure.sdk.iot.service.transport.http.HttpResponse in project azure-iot-sdk-java by Azure.
the class HttpsResponseTest method getHeaderFieldReturnsHeaderField.
// Tests_SRS_SERVICE_SDK_JAVA_HTTPSRESPONSE_12_001: [The constructor shall store the input arguments so that the getters can return them later.]
// Tests_SRS_SERVICE_SDK_JAVA_HTTPSRESPONSE_12_004: [The function shall return a comma-separated list of the values associated with the header field name.]
@Test
public void getHeaderFieldReturnsHeaderField() {
// Arrange
final int status = 200;
final byte[] body = { 1 };
final byte[] errorReason = {};
final Map<String, List<String>> headerFields = new HashMap<>();
final String field = "test-field";
final List<String> values = new LinkedList<>();
final String value0 = "test-field-value0";
final String value1 = "test-field-value1";
final String expectedValues = value0 + "," + value1;
values.add(value0);
values.add(value1);
headerFields.put(field, values);
// Act
HttpResponse response = new HttpResponse(status, body, headerFields, errorReason);
String testValues = response.getHeaderField(field);
// Assert
assertThat(testValues, is(expectedValues));
}
Aggregations