summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-simulators/src/main
diff options
context:
space:
mode:
authordc443y <dc443y@att.com>2022-01-21 14:43:18 -0600
committerdc443y <dc443y@att.com>2022-01-21 14:59:42 -0600
commitc445d7865f1ded1c62f720abb70382b2963fff57 (patch)
tree059ff8eaa968a5e2a1c39a0a456741e6f94097ae /models-interactions/model-simulators/src/main
parent7a718bd9b82ac16e5d49a1a2fb2256682f020656 (diff)
Add configurable port and authentication to DMaaP simulator
Issue-ID: POLICY-3890 Signed-off-by: dc443y <dc443y@att.com> Change-Id: Idbeb3590a767e51aa0058a7a45d56a61e81301cb
Diffstat (limited to 'models-interactions/model-simulators/src/main')
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java19
-rw-r--r--models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/AuthDmaapParameters.json11
2 files changed, 25 insertions, 5 deletions
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
index 24fd7ece5..155107bbd 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java
@@ -156,19 +156,30 @@ public final class Util {
}
/**
- * Build a DMaaP simulator.
+ * Builds an unauthenticated HTTP DMaaP simulator.
*
* @return the simulator
* @throws InterruptedException if a thread is interrupted
*/
public static HttpServletServer buildDmaapSim() throws InterruptedException {
- var json = ResourceUtils.getResourceAsString("org/onap/policy/simulators/dmaap/DmaapParameters.json");
+ return buildDmaapSim("org/onap/policy/simulators/dmaap/DmaapParameters.json");
+ }
+
+ /**
+ * Build a DMaaP simulator from a properties file.
+ *
+ * @param resourceName the name of the properties file
+ * @return the simulator
+ * @throws InterruptedException if a thread is interrupted
+ */
+ public static HttpServletServer buildDmaapSim(String resourceName) throws InterruptedException {
+ var json = ResourceUtils.getResourceAsString(resourceName);
DmaapSimParameterGroup params = null;
try {
params = new StandardCoder().decode(json, DmaapSimParameterGroup.class);
} catch (CoderException ce) {
throw new ParameterRuntimeException(
- CANNOT_PROCESS_PARAMETERS + "org/onap/policy/simulators/dmaap/DmaapParameters.json", ce);
+ CANNOT_PROCESS_PARAMETERS + resourceName, ce);
}
DmaapSimProvider.setInstance(new DmaapSimProvider(params));
@@ -177,8 +188,6 @@ public final class Util {
final String svcpfx = PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ params.getRestServerParameters().getName();
- props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX,
- Integer.toString(DMAAPSIM_SERVER_PORT));
props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
HttpServletServer testServer = HttpServletServerFactoryInstance.getServerFactory().build(props).get(0);
diff --git a/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/AuthDmaapParameters.json b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/AuthDmaapParameters.json
new file mode 100644
index 000000000..0ef03169a
--- /dev/null
+++ b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/dmaap/AuthDmaapParameters.json
@@ -0,0 +1,11 @@
+{
+ "name": "AuthDMaapSim",
+ "topicSweepSec": 300,
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 3903,
+ "useHttps": true,
+ "userName": "my-username",
+ "password": "my-password"
+ }
+}