Move the simulators to a new package 19/11719/2
authorCharles Cole <cc847m@att.com>
Fri, 8 Sep 2017 19:10:57 +0000 (14:10 -0500)
committerCharles Cole <cc847m@att.com>
Mon, 11 Sep 2017 18:09:17 +0000 (13:09 -0500)
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>
12 files changed:
controlloop/common/pom.xml
controlloop/common/simulators/pom.xml [new file with mode: 0644]
controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java [moved from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java with 99% similarity]
controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java [moved from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorJaxRs.java with 96% similarity]
controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java [new file with mode: 0644]
controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java [moved from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorJaxRs.java with 97% similarity]
controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java [moved from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulatorTest.java with 97% similarity]
controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java [moved from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java with 97% similarity]
controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java [moved from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorTest.java with 98% similarity]
controlloop/templates/template.demo/pom.xml
controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java

index b6db666..083a19f 100644 (file)
@@ -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 (file)
index 0000000..9d3b71c
--- /dev/null
@@ -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
@@ -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}")
@@ -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 (file)
index 0000000..27cc6e0
--- /dev/null
@@ -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;
+       }
+}
@@ -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;
@@ -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;
@@ -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.*;
 
@@ -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.*;
 
index 0bceea8..e081740 100644 (file)
                        <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>
index 0738aad..b277b66 100644 (file)
@@ -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.
index 502ef7c..fb9f88f 100644 (file)
@@ -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,