2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.common;
23 import javax.xml.ws.Endpoint;
24 import org.camunda.bpm.engine.ProcessEngineServices;
25 import org.junit.rules.TestRule;
26 import org.junit.runner.Description;
27 import org.junit.runners.model.Statement;
28 import org.onap.so.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl;
31 * A JUnit rule that starts the SDNC Adapter Callback Service before every test, and tears it down after every test.
36 * public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = new SDNCAdapterCallbackRule(processEngineRule);
39 public class SDNCAdapterCallbackRule implements TestRule {
40 public static final String DEFAULT_ENDPOINT_URL = "http://localhost:28080/mso/SDNCAdapterCallbackService";
42 private final ProcessEngineServices processEngineServices;
43 private final String endpointUrl;
45 public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices) {
46 this(processEngineServices, DEFAULT_ENDPOINT_URL);
49 public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices, String endpointUrl) {
50 this.processEngineServices = processEngineServices;
51 this.endpointUrl = endpointUrl;
55 public Statement apply(final Statement baseStmt, Description description) {
56 return new Statement() {
58 public void evaluate() throws Throwable {
59 Endpoint endpoint = null;
62 SDNCAdapterCallbackServiceImpl sdncCallbackService = new SDNCAdapterCallbackServiceImpl();
63 sdncCallbackService.setProcessEngineServices4junit(processEngineServices);
65 System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
66 System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
68 System.out.println("Publishing Endpoint - " + endpointUrl);
69 endpoint = Endpoint.publish(endpointUrl, sdncCallbackService);
73 if (endpoint != null) {
74 System.out.println("Stopping Endpoint - " + endpointUrl);