aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/simulators
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/simulators')
-rw-r--r--controlloop/common/simulators/pom.xml5
-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
3 files changed, 84 insertions, 0 deletions
diff --git a/controlloop/common/simulators/pom.xml b/controlloop/common/simulators/pom.xml
index 3eabd6391..5259890ca 100644
--- a/controlloop/common/simulators/pom.xml
+++ b/controlloop/common/simulators/pom.xml
@@ -68,5 +68,10 @@
<artifactId>gson</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId>
+ <artifactId>sdnc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
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