1 package org.openecomp.mso.bpmn.common;
3 import javax.xml.ws.Endpoint;
5 import org.camunda.bpm.engine.ProcessEngineServices;
6 import org.junit.rules.TestRule;
7 import org.junit.runner.Description;
8 import org.junit.runners.model.Statement;
9 import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl;
12 * A JUnit rule that starts the SDNC Adapter Callback Service before
13 * every test, and tears it down after every test. Example:
16 * public final SDNCAdapterCallbackRule sdncAdapterCallbackRule =
17 * new SDNCAdapterCallbackRule(processEngineRule);
20 public class SDNCAdapterCallbackRule implements TestRule {
21 public static final String DEFAULT_ENDPOINT_URL =
22 "http://localhost:28080/mso/SDNCAdapterCallbackService";
24 private final ProcessEngineServices processEngineServices;
25 private final String endpointUrl;
27 public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices) {
28 this(processEngineServices, DEFAULT_ENDPOINT_URL);
31 public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices,
33 this.processEngineServices = processEngineServices;
34 this.endpointUrl = endpointUrl;
38 public Statement apply(final Statement baseStmt, Description description) {
39 return new Statement() {
41 public void evaluate() throws Throwable {
42 Endpoint endpoint = null;
45 SDNCAdapterCallbackServiceImpl sdncCallbackService = new SDNCAdapterCallbackServiceImpl();
46 sdncCallbackService.setProcessEngineServices4junit(processEngineServices);
48 System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
49 System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
51 System.out.println("Publishing Endpoint - " + endpointUrl);
52 endpoint = Endpoint.publish(endpointUrl, sdncCallbackService);
56 if (endpoint != null) {
57 System.out.println("Stopping Endpoint - " + endpointUrl);