aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/simulators/src
diff options
context:
space:
mode:
authorVidyashree Rama <vidyashree.rama@huawei.com>2018-10-18 11:45:52 +0530
committerVidyashree Rama <vidyashree.rama@huawei.com>2018-10-23 18:28:01 +0530
commitb9007182f9a8fa0dea48fc970e38fb6761bf6c24 (patch)
tree8acc33b3aab928e3b7e1d4db7baee7c5ee4135af /controlloop/common/simulators/src
parentecffd0e5dfe112bcc69ee420848bbc476571637c (diff)
Add CCVPN policy
CCVPN policy Issue-ID: POLICY-1209 Change-Id: I8adea233f8672c9ff43b4a169b50336d9e43c91d Signed-off-by: Vidyashree Rama <vidyashree.rama@huawei.com>
Diffstat (limited to 'controlloop/common/simulators/src')
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java58
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java21
2 files changed, 79 insertions, 0 deletions
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java
new file mode 100644
index 000000000..47bdf01ed
--- /dev/null
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * simulators
+ * ================================================================================
+ * Copyright (C) 2018 Huawei. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.simulators;
+
+import java.util.UUID;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+
+import org.onap.policy.sdnc.SdncResponse;
+import org.onap.policy.sdnc.SdncResponseOutput;
+import org.onap.policy.sdnc.util.Serialization;
+
+
+@Path("/restconf/operations/")
+public class SdncSimulatorJaxRs {
+
+ /**
+ * SDNC post query.
+ *
+ * @return the response
+ */
+ @POST
+ @Path("/GENERIC-RESOURCE-API:network-topology-operation")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces("application/json")
+ public String sdncPostQuery() {
+ final SdncResponse response = new SdncResponse();
+ response.setRequestId(UUID.randomUUID().toString());
+ SdncResponseOutput responseOutput = new SdncResponseOutput();
+ responseOutput.setResponseCode("200");
+ responseOutput.setAckFinalIndicator("Y");
+ responseOutput.setSvcRequestId(UUID.randomUUID().toString());
+ response.setResponseOutput(responseOutput);
+ return Serialization.gsonPretty.toJson(response);
+ }
+}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
index 16ae615af..1de77638b 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
@@ -30,11 +30,13 @@ public class Util {
public static final String SOSIM_SERVER_NAME = "soSim";
public static final String VFCSIM_SERVER_NAME = "vfcSim";
public static final String GUARDSIM_SERVER_NAME = "guardSim";
+ public static final String SDNCSIM_SERVER_NAME = "sdncSim";
public static final int AAISIM_SERVER_PORT = 6666;
public static final int SOSIM_SERVER_PORT = 6667;
public static final int VFCSIM_SERVER_PORT = 6668;
public static final int GUARDSIM_SERVER_PORT = 6669;
+ public static final int SDNCSIM_SERVER_PORT = 6670;
private static final String CANNOT_CONNECT = "cannot connect to port ";
private static final String LOCALHOST = "localhost";
@@ -62,6 +64,25 @@ public class Util {
}
/**
+ * Build an SDNC simulator.
+ *
+ * @return the simulator
+ * @throws InterruptedException if a thread is interrupted
+ * @throws IOException if an IO errror occurs
+ */
+ public static HttpServletServer buildSdncSim() throws InterruptedException, IOException {
+ final HttpServletServer testServer =
+ HttpServletServer.factory.build(SDNCSIM_SERVER_NAME, LOCALHOST, SDNCSIM_SERVER_PORT, "/", false, true);
+ testServer.addServletClass("/*", SdncSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
+ throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
+ }
+ return testServer;
+ }
+
+
+ /**
* Build an SO simulator.
*
* @return the simulator