diff options
author | IanHowell <ian.howell@att.com> | 2018-04-25 15:14:28 -0500 |
---|---|---|
committer | IanHowell <ian.howell@att.com> | 2018-04-25 15:14:31 -0500 |
commit | 5c2768c78ba2601c2e5e2309e535527d7d92f95d (patch) | |
tree | 919fd5f866ad9f7179a62624dc4062f96237fb83 /cadi/client/src/main | |
parent | 1efda07f5d8e14d028fddf62dec62c95af9c7342 (diff) |
Improve coverage of cadi-client
Issue-ID: AAF-224
Change-Id: I83aefd55f7e6627b402ab89c8f3da036b8b153c3
Signed-off-by: IanHowell <ian.howell@att.com>
Diffstat (limited to 'cadi/client/src/main')
-rw-r--r-- | cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java index 46099887..456184c3 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java @@ -28,6 +28,7 @@ import java.io.OutputStream; import java.io.Reader; import java.net.HttpURLConnection; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; @@ -121,18 +122,11 @@ public class HClient implements EClient<HttpURLConnection> { } pi.append(pathinfo); } - URL url = new URI( - uri.getScheme(), - uri.getUserInfo(), - uri.getHost(), - uri.getPort(), - pi==null?uri.getPath():pi.toString(), - query, - fragment).toURL(); pathinfo=null; query=null; fragment=null; - huc = (HttpURLConnection) url.openConnection(); + //huc = (HttpURLConnection) url.openConnection(); + huc = getConnection(uri, pi); huc.setRequestMethod(meth); if(ss!=null) { ss.setSecurity(huc); @@ -169,10 +163,21 @@ public class HClient implements EClient<HttpURLConnection> { return connectTimeout; } - public abstract class HFuture<T> extends Future<T> { + protected HttpURLConnection getConnection(URI uri, StringBuilder pi) throws IOException, URISyntaxException { + URL url = new URI( + uri.getScheme(), + uri.getUserInfo(), + uri.getHost(), + uri.getPort(), + pi==null?uri.getPath():pi.toString(), + query, + fragment).toURL(); + return (HttpURLConnection) url.openConnection(); + } + + public abstract class HFuture<T> extends Future<T> { protected HttpURLConnection huc; protected int respCode; - protected String respMessage; protected IOException exception; protected StringBuilder errContent; @@ -258,10 +263,6 @@ public class HClient implements EClient<HttpURLConnection> { return exception; } - public String respMessage() { - return respMessage; - } - @Override public String header(String tag) { return huc.getHeaderField(tag); @@ -285,9 +286,6 @@ public class HClient implements EClient<HttpURLConnection> { public String body() { if (errContent != null) { return errContent.toString(); - - } else if (respMessage != null) { - return respMessage; } return ""; } @@ -314,8 +312,6 @@ public class HClient implements EClient<HttpURLConnection> { return value; } else if (errContent != null) { return errContent.toString(); - } else if (respMessage != null) { - return respMessage; } return ""; } @@ -346,8 +342,6 @@ public class HClient implements EClient<HttpURLConnection> { } } else if (errContent != null) { return errContent.toString(); - } else if (respMessage != null) { - return respMessage; } return ""; } @@ -369,8 +363,6 @@ public class HClient implements EClient<HttpURLConnection> { public String body() { if (errContent != null) { return errContent.toString(); - } else if (respMessage != null) { - return respMessage; } return Integer.toString(respCode); } @@ -419,7 +411,7 @@ public class HClient implements EClient<HttpURLConnection> { @Override public String body() { - return errContent==null?respMessage:errContent.toString(); + return errContent==null?null:errContent.toString(); } }; } |