diff options
author | 2018-07-29 16:13:45 +0300 | |
---|---|---|
committer | 2018-07-29 16:20:34 +0300 | |
commit | 5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch) | |
tree | 2f9dfc45191e723da69cf74be7829784e9741b94 /common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java | |
parent | 9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff) |
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5
Issue-ID: SDC-1566
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java')
-rw-r--r-- | common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java index 5722fc9c4e..9619e11a14 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java @@ -1,10 +1,6 @@ package org.openecomp.sdc.common.http.client.api; -import java.io.InputStream; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; - +import com.google.common.annotations.VisibleForTesting; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; @@ -13,8 +9,13 @@ import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.datastructure.FunctionalInterfaces.FunctionThrows; import org.openecomp.sdc.common.http.config.HttpClientConfig; -public enum HttpRequestHandler { - HANDLER; +import java.io.InputStream; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +public class HttpRequestHandler { + private static HttpRequestHandler handlerInstance = new HttpRequestHandler(); private static final String HTTPS_PREFIX = "https://"; private static final String HTTP_PREFIX = "http://"; @@ -46,13 +47,13 @@ public enum HttpRequestHandler { httpResponse.getStatusLine().getReasonPhrase()); }; - HttpRequestHandler() { + private HttpRequestHandler() { HttpConnectionMngFactory connectionMngFactory = new HttpConnectionMngFactory(); clientFactory = new HttpClientFactory(connectionMngFactory); } - static HttpRequestHandler get() { - return HANDLER; + public static HttpRequestHandler get() { + return handlerInstance; } public HttpResponse<String> get(String url, Properties headers, HttpClientConfig config) throws HttpExecuteException { @@ -100,7 +101,12 @@ public enum HttpRequestHandler { return clientFactory.createClient(protocol, config); } - private String getProtocol(String url) throws HttpExecuteException { + @VisibleForTesting + public static void setTestInstance(HttpRequestHandler handlerInstance) { + HttpRequestHandler.handlerInstance = handlerInstance; + } + + private String getProtocol(String url) throws HttpExecuteException { if (url.startsWith(HTTPS_PREFIX)) { return Constants.HTTPS; } |