summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-02-10 14:01:23 +0000
committerliamfallon <liam.fallon@est.tech>2021-02-10 15:47:17 +0000
commitc64320a45b77eb3474f1f3f7372f1cd1f85ddfef (patch)
tree45f3b9fc217b9a145b50f76aa2663de7be28adbe
parent8f25e72bd3cef408f78037f6c85c264aa9899cf1 (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>
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java3
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java14
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParametersTest.java74
-rw-r--r--testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSJsonEvent.json4
-rw-r--r--testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSObjectEvent.json4
5 files changed, 55 insertions, 44 deletions
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
index 3bc83b970..6b2576d90 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
import lombok.Getter;
-import lombok.Setter;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
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)
diff --git a/testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSJsonEvent.json b/testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSJsonEvent.json
index 89c24a719..63239a406 100644
--- a/testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSJsonEvent.json
+++ b/testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSJsonEvent.json
@@ -7403,7 +7403,7 @@
"parameters": {
"initialContextFactory": "org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestInitialContextFactory",
"connectionFactory": "ConnectionFactory",
- "providerURL": "remote://localhost:5445",
+ "providerUrl": "remote://localhost:4447",
"securityPrincipal": "guest",
"securityCredentials": "IAmAGuest",
"producerTopic": "jms/topic/apexOut",
@@ -7424,7 +7424,7 @@
"parameters": {
"initialContextFactory": "org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestInitialContextFactory",
"connectionFactory": "ConnectionFactory",
- "providerURL": "remote://localhost:5445",
+ "providerUrl": "remote://localhost:4447",
"securityPrincipal": "guest",
"securityCredentials": "IAmAGuest",
"consumerTopic": "jms/topic/apexIn"
diff --git a/testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSObjectEvent.json b/testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSObjectEvent.json
index 787d0bdb3..b9c535f3f 100644
--- a/testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSObjectEvent.json
+++ b/testsuites/integration/integration-common/src/main/resources/examples/config/JMS/JMS2JMSObjectEvent.json
@@ -487,7 +487,7 @@
"parameters": {
"initialContextFactory": "org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestInitialContextFactory",
"connectionFactory": "ConnectionFactory",
- "providerURL": "remote://localhost:5445",
+ "providerUrl": "remote://localhost:4447",
"securityPrincipal": "guest",
"securityCredentials": "IAmAGuest",
"producerTopic": "jms/topic/apexOut"
@@ -507,7 +507,7 @@
"parameters": {
"initialContextFactory": "org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestInitialContextFactory",
"connectionFactory": "ConnectionFactory",
- "providerURL": "remote://localhost:5445",
+ "providerUrl": "remote://localhost:4447",
"securityPrincipal": "guest",
"securityCredentials": "IAmAGuest",
"consumerTopic": "jms/topic/apexIn"