use of com.microsoft.azure.sdk.iot.deps.transport.http.HttpMethod in project azure-iot-sdk-java by Azure.
the class HttpConnectionTest method connectUsesCorrectUrl.
// Tests_SRS_HTTPSCONNECTION_25_005: [The function shall send a request to the URL given in the constructor.]
@Test
public void connectUsesCorrectUrl() throws IOException {
// Arrange
final HttpMethod httpsMethod = HttpMethod.PUT;
new NonStrictExpectations() {
{
mockUrl.getProtocol();
result = "https";
mockUrl.openConnection();
result = mockUrlConn;
mockUrlConn.getRequestMethod();
result = httpsMethod.name();
}
};
// Act
HttpConnection conn = new HttpConnection(mockUrl, httpsMethod);
conn.connect();
// Assert
new Verifications() {
{
mockUrl.openConnection().connect();
}
};
}
use of com.microsoft.azure.sdk.iot.deps.transport.http.HttpMethod in project azure-iot-sdk-java by Azure.
the class HttpConnectionTest method readErrorReturnsEmptyErrorReasonIfNoErrorReason.
// Tests_SRS_HTTPSCONNECTION_25_017: [The function shall read from the error stream and return the response.]
@Test
public void readErrorReturnsEmptyErrorReasonIfNoErrorReason() throws IOException {
// Arrange
final HttpMethod httpsMethod = HttpMethod.GET;
byte[] expectedError = {};
new NonStrictExpectations() {
{
mockUrl.getProtocol();
result = "https";
mockUrl.openConnection();
result = mockUrlConn;
mockUrlConn.getRequestMethod();
result = httpsMethod.name();
mockUrlConn.getErrorStream();
result = null;
}
};
HttpConnection conn = new HttpConnection(mockUrl, httpsMethod);
conn.connect();
// Act
byte[] testError = conn.readError();
// Assert
assertThat(testError, is(expectedError));
}
Aggregations