summaryrefslogtreecommitdiffstats
path: root/base/http/provider/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'base/http/provider/src/test')
-rw-r--r--base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java47
-rw-r--r--base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/BasicAuthFilterTest.java20
-rw-r--r--base/http/provider/src/test/resources/testprops.properties1
3 files changed, 68 insertions, 0 deletions
diff --git a/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java b/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java
new file mode 100644
index 00000000..ee2d223d
--- /dev/null
+++ b/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java
@@ -0,0 +1,47 @@
+package org.onap.ccsdk.sli.adaptors.base.http;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+import java.util.Set;
+
+import javax.ws.rs.client.Client;
+
+import org.junit.Test;
+
+public class AbstractHttpAdapterTest {
+
+ public class NonLoggingHttpAdapter extends AbstractHttpAdapter {
+ @Override
+ protected void registerLoggingFilter() {
+ // nonlogging, do nothing
+ }
+ }
+
+ @Test
+ public void checkTimeouts() throws Exception {
+ NonLoggingHttpAdapter adapter = new NonLoggingHttpAdapter();
+ Client client = adapter.getClientBuilder().build();
+ assertNotNull(client.getConfiguration().getProperty("jersey.config.client.readTimeout"));
+ assertNotNull(client.getConfiguration().getProperty("jersey.config.client.connectTimeout"));
+ }
+
+ @Test
+ public void propertiesTest() throws Exception {
+ System.setProperty(AbstractHttpAdapter.SDNC_CONFIG_DIR, "src/test/resources/");
+ NonLoggingHttpAdapter adapter = new NonLoggingHttpAdapter();
+ Properties props = adapter.getProperties("testprops.properties");
+ assertNotNull(props);
+ assertEquals("world", props.get("hello"));
+ }
+
+ @Test
+ public void basicAuthFilter() throws Exception {
+ NonLoggingHttpAdapter adapter = new NonLoggingHttpAdapter();
+ adapter.addBasicAuthCredentials("hello", "world");
+ Set<Object> objs = adapter.getClientBuilder().getConfiguration().getInstances();
+ assertEquals(BasicAuthFilter.class,objs.iterator().next().getClass());
+ }
+
+}
diff --git a/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/BasicAuthFilterTest.java b/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/BasicAuthFilterTest.java
new file mode 100644
index 00000000..b9565ba6
--- /dev/null
+++ b/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/BasicAuthFilterTest.java
@@ -0,0 +1,20 @@
+package org.onap.ccsdk.sli.adaptors.base.http;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class BasicAuthFilterTest {
+
+ @Test
+ public void notNullParameters() throws Exception {
+ BasicAuthFilter myFilter = new BasicAuthFilter("helloworld");
+ assertNotNull(myFilter);
+ }
+
+ @Test
+ public void nullParameters() throws Exception {
+ BasicAuthFilter myFilter = new BasicAuthFilter(null);
+ assertNotNull(myFilter);
+ }
+}
diff --git a/base/http/provider/src/test/resources/testprops.properties b/base/http/provider/src/test/resources/testprops.properties
new file mode 100644
index 00000000..3f602680
--- /dev/null
+++ b/base/http/provider/src/test/resources/testprops.properties
@@ -0,0 +1 @@
+hello = world \ No newline at end of file