aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop
diff options
context:
space:
mode:
authorCharles Cole <cc847m@att.com>2017-09-08 14:10:57 -0500
committerCharles Cole <cc847m@att.com>2017-09-11 13:09:17 -0500
commit8d338012d725cb16ebdbff0eb3ff7f47ad08f6d1 (patch)
treed6cb270df5d886f4b557d850c38ac1c3f5cba46d /controlloop
parent6f8b23793f90a3bc944f63be6f11a8f17f78220d (diff)
Move the simulators to a new package
Moved the simulators to the simulators project in controlloop/common. They can now be accessed with the Util class in the simulators project or the Util class in template.demo, for backwards compatability. Also renamed AaiSimulator to AaiSimulatorJaxRs Issue-IS: POLICY-200 Change-Id: Id131af0243777db31a8f22e110d8a708dc033dcf Signed-off-by: Charles Cole <cc847m@att.com>
Diffstat (limited to 'controlloop')
-rw-r--r--controlloop/common/pom.xml1
-rw-r--r--controlloop/common/simulators/pom.xml67
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java)6
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorJaxRs.java)4
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java49
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorJaxRs.java)4
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulatorTest.java)4
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java)4
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorTest.java)4
-rw-r--r--controlloop/templates/template.demo/pom.xml20
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java26
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java19
12 files changed, 159 insertions, 49 deletions
diff --git a/controlloop/common/pom.xml b/controlloop/common/pom.xml
index b6db66660..083a19f0b 100644
--- a/controlloop/common/pom.xml
+++ b/controlloop/common/pom.xml
@@ -38,6 +38,7 @@
<module>eventmanager</module>
<module>model-impl</module>
<module>policy-yaml</module>
+ <module>simulators</module>
</modules>
diff --git a/controlloop/common/simulators/pom.xml b/controlloop/common/simulators/pom.xml
new file mode 100644
index 000000000..9d3b71c0d
--- /dev/null
+++ b/controlloop/common/simulators/pom.xml
@@ -0,0 +1,67 @@
+<!--
+ ============LICENSE_START=======================================================
+ simulators
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>common</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>simulators</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>aai</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>mso</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>vfc</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
index 74b8bde0e..e1668ef4f 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
@@ -26,7 +26,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@Path("/aai")
-public class AaiSimulator {
+public class AaiSimulatorJaxRs {
@GET
@Path("/v8/network/generic-vnfs/generic-vnf/{vnfId}")
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java
index 14e12da7f..824c547ce 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
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
new file mode 100644
index 000000000..27cc6e0fa
--- /dev/null
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * simulators
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.simulators.AaiSimulatorJaxRs;
+import org.onap.policy.simulators.MsoSimulatorJaxRs;
+import org.onap.policy.simulators.VfcSimulatorJaxRs;
+
+public class Util {
+ public static HttpServletServer buildAaiSim() throws InterruptedException {
+ HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6666, "/", false, true);
+ testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ return testServer;
+ }
+
+ public static HttpServletServer buildMsoSim() throws InterruptedException {
+ HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6667, "/", false, true);
+ testServer.addServletClass("/*", MsoSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ return testServer;
+ }
+
+ public static HttpServletServer buildVfcSim() throws InterruptedException {
+ HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6668, "/", false, true);
+ testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ return testServer;
+ }
+}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
index d85a9fb8a..51a85ce60 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
index 3bddbc50d..1b12b2527 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java
index 7696cbe73..917288ed5 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import static org.junit.Assert.*;
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
index 340404136..5bfc4a018 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import static org.junit.Assert.*;
diff --git a/controlloop/templates/template.demo/pom.xml b/controlloop/templates/template.demo/pom.xml
index 0bceea848..e08174004 100644
--- a/controlloop/templates/template.demo/pom.xml
+++ b/controlloop/templates/template.demo/pom.xml
@@ -192,28 +192,16 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.drools-applications</groupId>
- <artifactId>aai</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${project.version}</version>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>[1.4.186,)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onap.policy.drools-applications</groupId>
- <artifactId>mso</artifactId>
+ <artifactId>simulators</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>[1.4.186,)</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
index 0738aadcf..b277b669e 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
@@ -23,6 +23,7 @@ package org.onap.policy.template.demo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.URLEncoder;
@@ -35,6 +36,8 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.kie.api.KieServices;
@@ -53,6 +56,7 @@ import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.impl.ControlLoopLoggerStdOutImpl;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
import org.onap.policy.mso.util.Serialization;
import org.slf4j.Logger;
@@ -63,6 +67,20 @@ public class TestSO {
private static final Logger log = LoggerFactory.getLogger(TestSO.class);
+ @BeforeClass
+ public static void setUpSimulator() {
+ try {
+ Util.buildAaiSim();
+ } catch (InterruptedException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
@Ignore
@Test
public void testvDNS() throws IOException {
@@ -117,10 +135,6 @@ public class TestSO {
@Override
public void run() {
-
- log.debug("\n***** Starting AAI Simulator ***** ");
- AaiSimulatorTest.setUpSimulator();
- log.debug("\n***** AAI Simulator started ***** ");
log.debug("\n************ Starting vDNS Test *************\n");
@@ -197,10 +211,6 @@ public class TestSO {
//
dumpFacts(kieSession);
- log.debug("\n***** Stopping AAI Simulator ***** ");
- AaiSimulatorTest.tearDownSimulator();
- log.debug("\n***** AAI Simulator stopped ***** ");
-
//
// See if there is anything left in memory, there SHOULD only be
// a params fact.
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
index 502ef7c1d..fb9f88f16 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
@@ -53,11 +53,15 @@ import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
import org.onap.policy.guard.PolicyGuardYamlToXacml;
+import org.onap.policy.simulators.AaiSimulatorJaxRs;
+import org.onap.policy.simulators.MsoSimulatorJaxRs;
+import org.onap.policy.simulators.VfcSimulatorJaxRs;
import com.att.research.xacml.api.pdp.PDPEngine;
import com.att.research.xacml.api.pdp.PDPEngineFactory;
import com.att.research.xacml.util.FactoryException;
import com.att.research.xacml.util.XACMLProperties;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -114,24 +118,15 @@ public final class Util {
}
public static HttpServletServer buildAaiSim() throws InterruptedException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6666, "/", false, true);
- testServer.addServletClass("/*", AaiSimulator.class.getName());
- testServer.waitedStart(5000);
- return testServer;
+ return org.onap.policy.simulators.Util.buildAaiSim();
}
public static HttpServletServer buildMsoSim() throws InterruptedException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6667, "/", false, true);
- testServer.addServletClass("/*", MsoSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- return testServer;
+ return org.onap.policy.simulators.Util.buildMsoSim();
}
public static HttpServletServer buildVfcSim() throws InterruptedException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6668, "/", false, true);
- testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- return testServer;
+ return org.onap.policy.simulators.Util.buildVfcSim();
}
private static String generatePolicy(String ruleContents,