diff options
author | Rob Daugherty <rd472p@att.com> | 2018-10-29 14:36:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-10-29 14:36:10 +0000 |
commit | ce8b0ccccdac7ff9ad9a81a79a983643179abbdc (patch) | |
tree | 7c7ad0c88bd711ec93556a29563047b0f6dac1fa | |
parent | f33aa5c6da5e4113971f24f8e88693796800d09a (diff) | |
parent | 3149c922b434a7f02d3ba379086f4e6c042f0bca (diff) |
Merge "junits for HttpClientRedirectStrategy"
-rw-r--r-- | cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java index 9a05602b34..b631dab999 100644 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java +++ b/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java @@ -28,6 +28,7 @@ import java.net.URI; import java.net.URISyntaxException; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; import org.apache.http.ProtocolException; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; @@ -87,6 +88,23 @@ public class HttpClientRedirectStrategyTest { assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri); } + @Test + public void getRedirect_shouldReturnHttpGetUri_byDefault() throws URISyntaxException, ProtocolException { + // GIVEN + HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS); + given(request.getRequestLine().getMethod()).willReturn(HttpPost.METHOD_NAME); + HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS); + given(response.getStatusLine().getStatusCode()).willReturn(HttpStatus.SC_ACCEPTED); + URI expectedUri = new URI("http://localhost/host"); + HttpContext context = null; + // WHEN + HttpUriRequest httpUriRequest = new TestableHttpClientRedirectStrategy(expectedUri) + .getRedirect(request, response, context); + // THEN + assertThat(httpUriRequest).isInstanceOf(HttpGet.class); + assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri); + } + private static class TestableHttpClientRedirectStrategy extends HttpClientRedirectStrategy { private final URI expectedUri; |