+
+ /**
+ * Build a DMaaP simulator.
+ *
+ * @return the simulator
+ * @throws InterruptedException if a thread is interrupted
+ * @throws IOException if an IO errror occurs
+ * @throws CoderException if the server parameters cannot be loaded
+ */
+ public static HttpServletServer buildDmaapSim() throws InterruptedException, IOException, CoderException {
+ String json = ResourceUtils.getResourceAsString("org/onap/policy/simulators/dmaap/DmaapParameters.json");
+ DmaapSimParameterGroup params = new StandardCoder().decode(json, DmaapSimParameterGroup.class);
+
+ DmaapSimProvider.setInstance(new DmaapSimProvider(params));
+
+ Properties props = DmaapSimRestServer.getServerProperties(params.getRestServerParameters());
+
+ 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);
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 50, 1000L)) {
+ throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
+ }
+ return testServer;
+ }