summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@est.tech>2019-09-03 14:44:15 +0000
committera.sreekumar <ajith.sreekumar@est.tech>2019-09-03 14:44:15 +0000
commit7cf00931901b54b916a9e25f957bf7904aa9b068 (patch)
treec8d3d1fdf6252d82fbaa2de443cb0eac4e790be8 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test
parent8379a2cec88ba880e0ee472c32f57217b231d348 (diff)
Enable https support in ApexRestServer
Enable https support in ApexRestServer by using the RestServer from policy-common Change-Id: I3dc8d88a499dfa9f0a82585a083526e236420c6e Issue-ID: POLICY-2016 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java61
2 files changed, 62 insertions, 1 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java
index 02daed02e..07f705cc6 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java
@@ -93,7 +93,7 @@ public class ApexRestServerConsumerTest {
incomingEventReceiver);
}
- @Test(expected = IllegalStateException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testInitWithSynchronousModeAndProperValues()
throws ApexEventException, NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException {
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
index dbe20c960..2c8a764e8 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java
@@ -86,4 +86,65 @@ public class RestServerCarrierTechnologyParametersTest {
assertFalse(result.isValid());
}
+ @Test
+ public void testValidateWithValidValues() throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
+
+ Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("standalone");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, true);
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("host");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, "localhost");
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("port");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, 6969);
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("userName");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, "username");
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("password");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, "password");
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("https");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, true);
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("aaf");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, true);
+ result = restServerCarrierTechnologyParameters.validate();
+ assertNotNull(result);
+ assertTrue(result.isValid());
+ }
+
+ @Test
+ public void testValidateWithInvalidValues() throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
+
+ Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("standalone");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, false);
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("host");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, "localhost");
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("port");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, 6969);
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("userName");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, "username");
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("password");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, "password");
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("https");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, true);
+ field = RestServerCarrierTechnologyParameters.class.getDeclaredField("aaf");
+ field.setAccessible(true);
+ field.set(restServerCarrierTechnologyParameters, true);
+ result = restServerCarrierTechnologyParameters.validate();
+ assertNotNull(result);
+ assertFalse(result.isValid());
+ assertTrue(result.getResult().contains("host is specified only in standalone mode"));
+ assertTrue(result.getResult().contains("port is specified only in standalone mode"));
+ }
}