diff options
author | liamfallon <liam.fallon@est.tech> | 2021-02-10 14:01:23 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2021-02-10 15:47:17 +0000 |
commit | c64320a45b77eb3474f1f3f7372f1cd1f85ddfef (patch) | |
tree | 45f3b9fc217b9a145b50f76aa2663de7be28adbe /plugins/plugins-event/plugins-event-carrier | |
parent | 8f25e72bd3cef408f78037f6c85c264aa9899cf1 (diff) |
Remove URL and useerid from JMS plugin
This review makes the default URL and userid for JMS null, the actual
values must be specified as parameters.
Issue-ID: POLICY-3035
Change-Id: I9c06d94d8816092425e2df58b849d837ad953fb2
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier')
2 files changed, 50 insertions, 38 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java index cdb3b4677..d93a1b981 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java @@ -84,8 +84,8 @@ public class JmsCarrierTechnologyParameters extends CarrierTechnologyParameters // Default parameter values private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory"; private static final String DEFAULT_INITIAL_CTXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory"; - private static final String DEFAULT_PROVIDER_URL = "remote://localhost:4447"; - private static final String DEFAULT_SECURITY_PRINCIPAL = "userid"; + private static final String DEFAULT_PROVIDER_URL = null; + private static final String DEFAULT_SECURITY_PRINCIPAL = null; private static final String DEFAULT_SECURITY_CREDENTIALS = null; private static final String DEFAULT_CONSUMER_TOPIC = "apex-in"; private static final String DEFAULT_PRODUCER_TOPIC = "apex-out"; @@ -150,8 +150,14 @@ public class JmsCarrierTechnologyParameters extends CarrierTechnologyParameters final Properties jmsProperties = new Properties(); jmsProperties.put(PROPERTY_INITIAL_CONTEXT_FACTORY, initialContextFactory); - jmsProperties.put(PROPERTY_PROVIDER_URL, providerUrl); - jmsProperties.put(PROPERTY_SECURITY_PRINCIPAL, securityPrincipal); + + if (providerUrl != null) { + jmsProperties.put(PROPERTY_PROVIDER_URL, providerUrl); + } + + if (securityPrincipal != null) { + jmsProperties.put(PROPERTY_SECURITY_PRINCIPAL, securityPrincipal); + } if (securityCredentials != null) { jmsProperties.put(PROPERTY_SECURITY_CREDENTIALS, securityCredentials); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java index 6be0fd32c..5f1b99500 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java @@ -44,17 +44,12 @@ public class JmsCarrierTechnologyParametersTest { public static final String JMS_CARRIER_TECHNOLOGY_LABEL = "JMS"; - public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = - ApexJmsProducer.class.getName(); + public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJmsProducer.class.getName(); - public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = - ApexJmsConsumer.class.getName(); + public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJmsConsumer.class.getName(); private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory"; - private static final String DEFAULT_INITIAL_CTXT_FACTORY = - "org.jboss.naming.remote.client.InitialContextFactory"; - private static final String DEFAULT_PROVIDER_URL = "remote://localhost:4447"; - private static final String DEFAULT_SECURITY_PRINCIPAL = "userid"; + private static final String DEFAULT_INITIAL_CTXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory"; private static final String DEFAULT_CONSUMER_TOPIC = "apex-in"; private static final String DEFAULT_PRODUCER_TOPIC = "apex-out"; private static final int DEFAULT_CONSUMER_WAIT_TIME = 100; @@ -76,7 +71,10 @@ public class JmsCarrierTechnologyParametersTest { assertNotNull(result); assertFalse(result.getStatus().isValid()); - jmsCarrierTechnologyParameters.setSecurityCredentials("DUMMY"); + jmsCarrierTechnologyParameters.setProviderUrl("DUMMYURL"); + jmsCarrierTechnologyParameters.setSecurityPrincipal("DUMMYPRINCIPAL"); + jmsCarrierTechnologyParameters.setSecurityCredentials("DUMMYCREDENTIALS"); + result = jmsCarrierTechnologyParameters.validate(); assertNotNull(result); assertTrue(result.getStatus().isValid()); @@ -91,11 +89,30 @@ public class JmsCarrierTechnologyParametersTest { public void testGetJmsProducerProperties() { Properties producerProperties = jmsCarrierTechnologyParameters.getJmsProducerProperties(); assertNotNull(producerProperties); + + assertNull(producerProperties.get(Context.PROVIDER_URL)); + assertNull(producerProperties.get(Context.SECURITY_PRINCIPAL)); assertNull(producerProperties.get(Context.SECURITY_CREDENTIALS)); - jmsCarrierTechnologyParameters.setSecurityCredentials("DUMMY"); + jmsCarrierTechnologyParameters.setProviderUrl("DUMMYURL"); + jmsCarrierTechnologyParameters.setSecurityPrincipal("DUMMYPRINCIPAL"); + jmsCarrierTechnologyParameters.setSecurityCredentials("DUMMYCREDENTIALS"); + producerProperties = jmsCarrierTechnologyParameters.getJmsProducerProperties(); - assertEquals("DUMMY", producerProperties.get(Context.SECURITY_CREDENTIALS)); + + assertEquals("DUMMYURL", producerProperties.get(Context.PROVIDER_URL)); + assertEquals("DUMMYPRINCIPAL", producerProperties.get(Context.SECURITY_PRINCIPAL)); + assertEquals("DUMMYCREDENTIALS", producerProperties.get(Context.SECURITY_CREDENTIALS)); + + jmsCarrierTechnologyParameters.setProviderUrl(null); + jmsCarrierTechnologyParameters.setSecurityPrincipal(null); + jmsCarrierTechnologyParameters.setSecurityCredentials(null); + + producerProperties = jmsCarrierTechnologyParameters.getJmsProducerProperties(); + + assertNull(producerProperties.get(Context.PROVIDER_URL)); + assertNull(producerProperties.get(Context.SECURITY_PRINCIPAL)); + assertNull(producerProperties.get(Context.SECURITY_CREDENTIALS)); } @Test @@ -117,15 +134,13 @@ public class JmsCarrierTechnologyParametersTest { @Test public void testGetConnectionFactory() { - assertEquals(DEFAULT_CONNECTION_FACTORY, - jmsCarrierTechnologyParameters.getConnectionFactory()); + assertEquals(DEFAULT_CONNECTION_FACTORY, jmsCarrierTechnologyParameters.getConnectionFactory()); } @Test public void testSetConnectionFactory() { jmsCarrierTechnologyParameters.setConnectionFactory("QueueConnectionFactory"); - assertNotEquals(DEFAULT_CONNECTION_FACTORY, - jmsCarrierTechnologyParameters.getConnectionFactory()); + assertNotEquals(DEFAULT_CONNECTION_FACTORY, jmsCarrierTechnologyParameters.getConnectionFactory()); } @Test @@ -138,29 +153,23 @@ public class JmsCarrierTechnologyParametersTest { @Test public void testSetConsumerWaitTime() { - assertEquals(DEFAULT_CONSUMER_WAIT_TIME, - jmsCarrierTechnologyParameters.getConsumerWaitTime()); + assertEquals(DEFAULT_CONSUMER_WAIT_TIME, jmsCarrierTechnologyParameters.getConsumerWaitTime()); jmsCarrierTechnologyParameters.setConsumerWaitTime(-1); - assertNotEquals(DEFAULT_CONSUMER_WAIT_TIME, - jmsCarrierTechnologyParameters.getConsumerWaitTime()); + assertNotEquals(DEFAULT_CONSUMER_WAIT_TIME, jmsCarrierTechnologyParameters.getConsumerWaitTime()); } @Test public void testSetEventConsumerPluginClass() { - assertEquals(JMS_EVENT_CONSUMER_PLUGIN_CLASS, - jmsCarrierTechnologyParameters.getEventConsumerPluginClass()); + assertEquals(JMS_EVENT_CONSUMER_PLUGIN_CLASS, jmsCarrierTechnologyParameters.getEventConsumerPluginClass()); jmsCarrierTechnologyParameters.setEventConsumerPluginClass("TestEventConsumerPluginClass"); - assertNotEquals(JMS_EVENT_CONSUMER_PLUGIN_CLASS, - jmsCarrierTechnologyParameters.getEventConsumerPluginClass()); + assertNotEquals(JMS_EVENT_CONSUMER_PLUGIN_CLASS, jmsCarrierTechnologyParameters.getEventConsumerPluginClass()); } @Test public void testSetEventProducerPluginClass() { - assertEquals(JMS_EVENT_PRODUCER_PLUGIN_CLASS, - jmsCarrierTechnologyParameters.getEventProducerPluginClass()); + assertEquals(JMS_EVENT_PRODUCER_PLUGIN_CLASS, jmsCarrierTechnologyParameters.getEventProducerPluginClass()); jmsCarrierTechnologyParameters.setEventProducerPluginClass("TestEventProducerPluginClass"); - assertNotEquals(JMS_EVENT_PRODUCER_PLUGIN_CLASS, - jmsCarrierTechnologyParameters.getEventProducerPluginClass()); + assertNotEquals(JMS_EVENT_PRODUCER_PLUGIN_CLASS, jmsCarrierTechnologyParameters.getEventProducerPluginClass()); } @Test @@ -188,7 +197,7 @@ public class JmsCarrierTechnologyParametersTest { @Test public void testSetProviderUrl() { - assertEquals(DEFAULT_PROVIDER_URL, jmsCarrierTechnologyParameters.getProviderUrl()); + assertNull(jmsCarrierTechnologyParameters.getProviderUrl()); jmsCarrierTechnologyParameters.setProviderUrl(null); result = jmsCarrierTechnologyParameters.validate(); assertFalse(result.getStatus().isValid()); @@ -204,8 +213,7 @@ public class JmsCarrierTechnologyParametersTest { @Test public void testSetSecurityPrincipal() { - assertEquals(DEFAULT_SECURITY_PRINCIPAL, - jmsCarrierTechnologyParameters.getSecurityPrincipal()); + assertNull(jmsCarrierTechnologyParameters.getSecurityPrincipal()); jmsCarrierTechnologyParameters.setSecurityPrincipal(null); result = jmsCarrierTechnologyParameters.validate(); assertFalse(result.getStatus().isValid()); @@ -214,16 +222,14 @@ public class JmsCarrierTechnologyParametersTest { @Test public void testSetInitialContextFactory() { - assertEquals(DEFAULT_INITIAL_CTXT_FACTORY, - jmsCarrierTechnologyParameters.getInitialContextFactory()); + assertEquals(DEFAULT_INITIAL_CTXT_FACTORY, jmsCarrierTechnologyParameters.getInitialContextFactory()); jmsCarrierTechnologyParameters.setInitialContextFactory(null); result = jmsCarrierTechnologyParameters.validate(); assertFalse(result.getStatus().isValid()); jmsCarrierTechnologyParameters.setInitialContextFactory("TestInitialContextFactory"); - assertNotEquals(DEFAULT_INITIAL_CTXT_FACTORY, - jmsCarrierTechnologyParameters.getInitialContextFactory()); + assertNotEquals(DEFAULT_INITIAL_CTXT_FACTORY, jmsCarrierTechnologyParameters.getInitialContextFactory()); } @Test(expected = ParameterRuntimeException.class) |