aboutsummaryrefslogtreecommitdiffstats
path: root/message-router/publisher/provider/src/main
diff options
context:
space:
mode:
authorSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>2019-07-26 20:24:59 +0000
committerKevin Smokowski <kevin.smokowski@att.com>2019-07-26 21:03:10 +0000
commitdd48a8a5083e3a65c8b47ce45ce7517afc47c1ff (patch)
tree7b774e48531e16a703ac1a901e1437ad8c9c7907 /message-router/publisher/provider/src/main
parent145a984ea7b2376e1d187ca0ad9ff0b62e7adae0 (diff)
Improve code coverage in sli adaptors
increase code coverage in message router in sli adaptors Issue-ID: CCSDK-1548 Signed-off-by: Smokowski, Kevin (ks6305) <kevin.smokowski@att.com> Change-Id: I64f0e025a759b219ce4c7e017b500952d1c7f30b
Diffstat (limited to 'message-router/publisher/provider/src/main')
-rwxr-xr-xmessage-router/publisher/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImpl.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/message-router/publisher/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImpl.java b/message-router/publisher/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImpl.java
index d88dc66b..58d0bc9f 100755
--- a/message-router/publisher/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImpl.java
+++ b/message-router/publisher/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImpl.java
@@ -28,12 +28,12 @@ public class PublisherApiImpl implements PublisherApi {
public void setUsername(String username) {
this.username = username;
- buildAuthorizationString();
+ setAuthorizationString();
}
public void setPassword(String password) {
this.password = password;
- buildAuthorizationString();
+ setAuthorizationString();
}
public void setHost(String hostString) {
@@ -51,10 +51,10 @@ public class PublisherApiImpl implements PublisherApi {
}
public void init() {
- buildAuthorizationString();
+ setAuthorizationString();
}
- private String buildUrlString(Integer hostIndex, String topic) {
+ protected String buildUrlString(Integer hostIndex, String topic) {
return hosts[hostIndex] + "/events/" + topic;
}
@@ -116,15 +116,22 @@ public class PublisherApiImpl implements PublisherApi {
return false;
}
- private void buildAuthorizationString() {
- String basicAuthString = username + ":" + password;
- basicAuthString = Base64.getEncoder().encodeToString(basicAuthString.getBytes());
- this.authorizationString = "Basic " + basicAuthString;
+ protected void setAuthorizationString() {
+ String str = buildAuthorizationString(this.username, this.password);
+ this.authorizationString = str;
+ //System.out.println(this.authorizationString);
}
+
+ protected String buildAuthorizationString(String username, String password) {
+ String basicAuthString = username + ":" + password;
+ basicAuthString = Base64.getEncoder().encodeToString(basicAuthString.getBytes());
+ return "Basic " + basicAuthString;
+ }
protected HttpURLConnection buildHttpURLConnection(URL url) throws IOException {
HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
if (authorizationString != null) {
+ System.out.println(authorizationString);
httpUrlConnection.setRequestProperty("Authorization", authorizationString);
}
httpUrlConnection.setRequestProperty("Accept", "application/json");