diff options
author | Smokowski, Kevin (ks6305) <kevin.smokowski@att.com> | 2019-07-26 20:24:59 +0000 |
---|---|---|
committer | Kevin Smokowski <kevin.smokowski@att.com> | 2019-07-26 21:03:10 +0000 |
commit | dd48a8a5083e3a65c8b47ce45ce7517afc47c1ff (patch) | |
tree | 7b774e48531e16a703ac1a901e1437ad8c9c7907 /message-router/publisher/provider/src/test | |
parent | 145a984ea7b2376e1d187ca0ad9ff0b62e7adae0 (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/test')
-rw-r--r-- | message-router/publisher/provider/src/test/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImplTest.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/message-router/publisher/provider/src/test/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImplTest.java b/message-router/publisher/provider/src/test/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImplTest.java new file mode 100644 index 000000000..53744f73e --- /dev/null +++ b/message-router/publisher/provider/src/test/java/org/onap/ccsdk/sli/adaptors/messagerouter/publisher/provider/impl/PublisherApiImplTest.java @@ -0,0 +1,51 @@ +package org.onap.ccsdk.sli.adaptors.messagerouter.publisher.provider.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Test;
+
+public class PublisherApiImplTest {
+ @Test
+ public void verifyDefaultTimeouts() {
+ PublisherApiImpl pub = new PublisherApiImpl();
+ assertEquals(pub.DEFAULT_CONNECT_TIMEOUT, pub.connectTimeout);
+ assertEquals(pub.DEFAULT_READ_TIMEOUT, pub.readTimeout);
+ }
+
+ @Test
+ public void buildHttpURLConnection() throws Exception {
+ PublisherApiImpl pub = new PublisherApiImpl();
+ pub.init();
+
+ String myUserName = "Batman";
+ pub.setUsername(myUserName);
+ assertEquals(myUserName, pub.username);
+ String password = "P@$$";
+ pub.setPassword(password);
+
+ HttpURLConnection httpUrlConnection = pub.buildHttpURLConnection(new URL("http://localhost:7001"));
+ assertNotNull(httpUrlConnection.getReadTimeout());
+ assertNotNull(httpUrlConnection.getConnectTimeout());
+ assertEquals("application/json", httpUrlConnection.getRequestProperty("Content-Type"));
+ assertEquals("application/json", httpUrlConnection.getRequestProperty("Accept"));
+ }
+
+ @Test
+ public void testMultipleHosts() {
+ PublisherApiImpl pub = new PublisherApiImpl();
+ String myTopic = "worldNews";
+ String hostOne = "http://localhost:7001";
+ String hostTwo = "http://localhost:7002";
+ String hostThree = "http://localhost:7003";
+
+ pub.setHost(hostOne + "," + hostTwo + "," + hostThree);
+
+ assertEquals("http://localhost:7001/events/worldNews", pub.buildUrlString(0, myTopic));
+ assertEquals("http://localhost:7002/events/worldNews", pub.buildUrlString(1, myTopic));
+ assertEquals("http://localhost:7003/events/worldNews", pub.buildUrlString(2, myTopic));
+ }
+}
\ No newline at end of file |