pdp-d feature to simulate aai/mso/vfc in lab 53/14053/2
authorJorge Hernandez <jh1730@att.com>
Thu, 21 Sep 2017 04:12:27 +0000 (23:12 -0500)
committerJorge Hernandez <jh1730@att.com>
Thu, 21 Sep 2017 15:29:20 +0000 (10:29 -0500)
implemented as an optional loadable feature, this
capability enables to bring up simulators used by
junits in a pdp-d lab configuration.

After lab installation, perform:

1. features enable controlloop-util
2. policy start

Now the simulators are opened at ports 6666, 6667, and 6668.

netstat output:
tcp6       0      0 127.0.0.1:6666          :::*                    LISTEN      21562/java
tcp6       0      0 127.0.0.1:6667          :::*                    LISTEN      21562/java
tcp6       0      0 127.0.0.1:6668          :::*                    LISTEN      21562/java

21562 is the pdp-d PID in the lab.

curl http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/vnfIdA
{ "vnf-id": "5e49ca06-2972-4532-9ed4-6d071588d792", ... }

Change-Id: I3f05333ce5549b2274eb967b2b8866189b7f8843
Issue-ID: POLICY-259
Signed-off-by: Jorge Hernandez <jh1730@att.com>
12 files changed:
controlloop/common/feature-controlloop-utils/pom.xml [new file with mode: 0644]
controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml [new file with mode: 0644]
controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment [new file with mode: 0644]
controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java [new file with mode: 0644]
controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI [new file with mode: 0644]
controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java [new file with mode: 0644]
controlloop/common/pom.xml
controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
controlloop/packages/apps/pom.xml

diff --git a/controlloop/common/feature-controlloop-utils/pom.xml b/controlloop/common/feature-controlloop-utils/pom.xml
new file mode 100644 (file)
index 0000000..f0f95f2
--- /dev/null
@@ -0,0 +1,134 @@
+<!--
+  ============LICENSE_START=======================================================
+  ONAP
+  ================================================================================
+  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>feature-controlloop-utils</artifactId>
+       <description>
+               Loadable PDP-D feature module to enable simulator usage in a non-junit 
+               lab environments.  In a pdp-d lab environment this capability can be 
+               enabled with the "feature" mechanisms.
+       </description>
+       
+       <properties>
+               <maven.compiler.source>1.8</maven.compiler.source>
+               <maven.compiler.target>1.8</maven.compiler.target>
+       </properties>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <artifactId>maven-assembly-plugin</artifactId>
+                               <version>2.6</version>
+                               <executions>
+                                       <execution>
+                                               <id>zipfile</id>
+                                               <goals>
+                                                       <goal>single</goal>
+                                               </goals>
+                                               <phase>package</phase>
+                                               <configuration>
+                                                       <attach>true</attach>
+                                                       <finalName>${project.artifactId}-${project.version}</finalName>
+                                                       <descriptors>
+                                                               <descriptor>src/assembly/assemble_zip.xml</descriptor>
+                                                       </descriptors>
+                                                       <appendAssemblyId>false</appendAssemblyId>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+                       
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-dependency-plugin</artifactId>
+                               <version>2.8</version>
+                               <executions>
+                                       <execution>
+                                               <id>copy-dependencies</id>
+                                               <goals>
+                                                       <goal>copy-dependencies</goal>
+                                               </goals>
+                                               <phase>prepare-package</phase>
+                                               <configuration>
+                                                       <transitive>false</transitive>
+                                                       <outputDirectory>${project.build.directory}/assembly/lib</outputDirectory>
+                                                       <overWriteReleases>false</overWriteReleases>
+                                                       <overWriteSnapshots>true</overWriteSnapshots>
+                                                       <overWriteIfNewer>true</overWriteIfNewer>
+                                                       <useRepositoryLayout>false</useRepositoryLayout>
+                                                       <addParentPoms>false</addParentPoms>
+                                                       <copyPom>false</copyPom>
+                                                       <includeScope>runtime</includeScope>
+                                                       <excludeTransitive>true</excludeTransitive>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+       
+       <dependencies>
+               <dependency>
+                       <groupId>org.onap.policy.drools-pdp</groupId>
+                       <artifactId>policy-management</artifactId>
+                       <version>${project.version}</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.onap.policy.drools-pdp</groupId>
+                       <artifactId>policy-endpoints</artifactId>
+                       <version>${project.version}</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.onap.policy.drools-applications</groupId>
+                       <artifactId>simulators</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.onap.policy.drools-applications</groupId>
+                       <artifactId>aai</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.onap.policy.drools-applications</groupId>
+                       <artifactId>so</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.onap.policy.drools-applications</groupId>
+                       <artifactId>rest</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.12</version>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+</project>
diff --git a/controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml b/controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml
new file mode 100644 (file)
index 0000000..26e6676
--- /dev/null
@@ -0,0 +1,75 @@
+<!--
+  ============LICENSE_START=======================================================
+  ONAP
+  ================================================================================
+  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=========================================================
+  -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+       xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+       <id>feature-controlloop-utils-package</id>
+       <formats>
+               <format>zip</format>
+       </formats>
+
+       <includeBaseDirectory>false</includeBaseDirectory>
+
+       <fileSets>
+               <fileSet>
+                       <directory>target</directory>
+                       <outputDirectory>lib/feature</outputDirectory>
+                       <includes>
+                               <include>feature-controlloop-utils-${project.version}.jar</include>
+                       </includes>
+               </fileSet>
+               <fileSet>
+                       <directory>target/assembly/lib</directory>
+                       <outputDirectory>lib/dependencies</outputDirectory>
+                       <includes>
+                               <include>*.jar</include>
+                       </includes>
+               </fileSet>
+               <fileSet>
+                       <directory>src/main/feature/config</directory>
+                       <outputDirectory>config</outputDirectory>
+                       <fileMode>0644</fileMode>
+                       <excludes/>
+               </fileSet>
+               <fileSet>
+                       <directory>src/main/feature/bin</directory>
+                       <outputDirectory>bin</outputDirectory>
+                       <fileMode>0744</fileMode>
+                       <excludes/>
+               </fileSet>
+               <fileSet>
+                       <directory>src/main/feature/db</directory>
+                       <outputDirectory>db</outputDirectory>
+                       <fileMode>0744</fileMode>
+                       <excludes/>
+               </fileSet>
+               <fileSet>
+                       <directory>src/main/feature/install</directory>
+                       <outputDirectory>install</outputDirectory>
+                       <fileMode>0744</fileMode>
+                       <excludes/>
+               </fileSet>
+       </fileSets>
+
+</assembly>
diff --git a/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment b/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment
new file mode 100644 (file)
index 0000000..daa9879
--- /dev/null
@@ -0,0 +1,26 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP
+# ================================================================================
+# 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=========================================================
+###
+
+# Environment file (.environment) for the simulator for control loop applications
+
+aai.url=http://localhost:6666
+so.url=http://localhost:6667
+vfc.url=http://localhost:6668
+
diff --git a/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java b/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java
new file mode 100644 (file)
index 0000000..5087631
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * 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.drools.apps.controlloop.feature.utils;
+
+import java.io.IOException;
+
+import org.onap.policy.drools.features.PolicyEngineFeatureAPI;
+import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.simulators.Util;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * PDP-D feature for lab environments that provides Server simulation capabilities for AAI, SO, and
+ * VFC
+ *
+ */
+public class ControlLoopUtilsFeature implements PolicyEngineFeatureAPI {
+
+  /**
+   * Logger
+   */
+  private static Logger logger = LoggerFactory.getLogger(ControlLoopUtilsFeature.class);
+
+  @Override
+  public boolean afterStart(PolicyEngine engine) {
+    try {
+      Util.buildAaiSim();
+      Util.buildSoSim();
+      Util.buildVfcSim();
+    } catch (final InterruptedException e) {
+      logger.error("{}: initialization aborted", ControlLoopUtilsFeature.class.getName(), e);
+      Thread.currentThread().interrupt();
+    } catch (final IOException e) {
+      logger.error("{}: a simulator cannot be built because of {}",
+          ControlLoopUtilsFeature.class.getName(), e.getMessage(), e);
+    }
+    return false;
+  }
+
+  @Override
+  public int getSequenceNumber() {
+    return 100000;
+  }
+
+}
diff --git a/controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI b/controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI
new file mode 100644 (file)
index 0000000..b5a71b8
--- /dev/null
@@ -0,0 +1 @@
+org.onap.policy.drools.apps.controlloop.feature.utils.ControlLoopUtilsFeature
diff --git a/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java
new file mode 100644 (file)
index 0000000..5ba3758
--- /dev/null
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * 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.drools.apps.controlloop.feature.utils;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.utils.LoggerUtil;
+import org.onap.policy.simulators.Util;
+
+/**
+ * ControlLoopUtilsFeature JUnit Tests
+ */
+public class ControlLoopUtilsFeatureTest {
+
+  @Test
+  public void simulate() {
+    LoggerUtil.setLevel("ROOT", "INFO");
+    LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+    final ControlLoopUtilsFeature feature = new ControlLoopUtilsFeature();
+    feature.afterStart(PolicyEngine.manager);
+    assertNotNull(HttpServletServer.factory.get(Util.AAISIM_SERVER_PORT));
+    assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT));
+    assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT));
+  }
+
+}
index 083a19f..39f1b70 100644 (file)
@@ -39,6 +39,7 @@
         <module>model-impl</module>
        <module>policy-yaml</module>
        <module>simulators</module>
+       <module>feature-controlloop-utils</module>
     </modules>
 
 
index 9fbb2b5..4a2bcf7 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -24,35 +24,43 @@ import java.io.IOException;
 
 import org.onap.policy.drools.http.server.HttpServletServer;
 import org.onap.policy.drools.utils.NetworkUtil;
-import org.onap.policy.simulators.AaiSimulatorJaxRs;
-import org.onap.policy.simulators.SoSimulatorJaxRs;
-import org.onap.policy.simulators.VfcSimulatorJaxRs;
 
 public class Util {
-       public static HttpServletServer buildAaiSim() throws InterruptedException, IOException {
-               HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6666, "/", false, true);
-               testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
-               testServer.waitedStart(5000);
-               if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
-                       throw new IllegalStateException("cannot connect to port " + testServer.getPort());
-               return testServer;
-       }
-       
-       public static HttpServletServer buildSoSim() throws InterruptedException, IOException {
-               HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6667, "/", false, true);
-               testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
-               testServer.waitedStart(5000);
-               if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
-                       throw new IllegalStateException("cannot connect to port " + testServer.getPort());
-               return testServer;
-       }
-       
-       public static HttpServletServer buildVfcSim() throws InterruptedException, IOException {
-               HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6668, "/", false, true);
-               testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
-               testServer.waitedStart(5000);
-               if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
-                       throw new IllegalStateException("cannot connect to port " + testServer.getPort());
-               return testServer;
-       }
+  public static final String AAISIM_SERVER_NAME = "aaiSim";
+  public static final String SOSIM_SERVER_NAME = "soSim";
+  public static final String VFCSIM_SERVER_NAME = "vfcSim";
+
+  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 HttpServletServer buildAaiSim() throws InterruptedException, IOException {
+    final HttpServletServer testServer = HttpServletServer.factory.build(AAISIM_SERVER_NAME,
+        "localhost", AAISIM_SERVER_PORT, "/", false, true);
+    testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
+    testServer.waitedStart(5000);
+    if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+      throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+    return testServer;
+  }
+
+  public static HttpServletServer buildSoSim() throws InterruptedException, IOException {
+    final HttpServletServer testServer = HttpServletServer.factory.build(SOSIM_SERVER_NAME,
+        "localhost", SOSIM_SERVER_PORT, "/", false, true);
+    testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
+    testServer.waitedStart(5000);
+    if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+      throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+    return testServer;
+  }
+
+  public static HttpServletServer buildVfcSim() throws InterruptedException, IOException {
+    final HttpServletServer testServer = HttpServletServer.factory.build(VFCSIM_SERVER_NAME,
+        "localhost", VFCSIM_SERVER_PORT, "/", false, true);
+    testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
+    testServer.waitedStart(5000);
+    if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
+      throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+    return testServer;
+  }
 }
index f5d42c9..121a889 100644 (file)
@@ -40,67 +40,74 @@ import org.onap.policy.aai.AAINQQueryParameters;
 import org.onap.policy.aai.AAINQRequest;
 import org.onap.policy.aai.AAINQResponse;
 import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
 
 public class AaiSimulatorTest {
 
-       @BeforeClass
-       public static void setUpSimulator() {
-               try {
-                       Util.buildAaiSim();
-               } catch (Exception e) {
-                       fail(e.getMessage());
-               }
-       }
+  @BeforeClass
+  public static void setUpSimulator() {
+    LoggerUtil.setLevel("ROOT", "INFO");
+    LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+    try {
+      Util.buildAaiSim();
+    } catch (final Exception e) {
+      fail(e.getMessage());
+    }
+  }
 
-       @AfterClass
-       public static void tearDownSimulator() {
-               HttpServletServer.factory.destroy();
-       }
+  @AfterClass
+  public static void tearDownSimulator() {
+    HttpServletServer.factory.destroy();
+  }
 
-       @Test
-       public void testGet() {
-               AAIGETVnfResponse response = AAIManager.getQueryByVnfID("http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass", UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
-               assertNotNull(response);
-               assertNotNull(response.relationshipList);
-       }
+  @Test
+  public void testGet() {
+    final AAIGETVnfResponse response = AAIManager.getQueryByVnfID(
+        "http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass",
+        UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
+    assertNotNull(response);
+    assertNotNull(response.relationshipList);
+  }
 
-       @Test
-       public void testPost() {
-               AAINQRequest request = new AAINQRequest();
-               AAINQQueryParameters tempQueryParameters = new AAINQQueryParameters();
-               AAINQNamedQuery tempNamedQuery = new AAINQNamedQuery();
-               tempNamedQuery.namedQueryUUID = UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469");
-               tempQueryParameters.namedQuery = tempNamedQuery;
-               request.queryParameters = tempQueryParameters;
-               Map<String, String> tempInnerMap = new HashMap<>();
-               tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1");
-               Map<String, Map<String, String>> tempOuterMap = new HashMap<>();
-               tempOuterMap.put("vserver", tempInnerMap);
-               List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>();
-               tempInstanceFilter.add(tempOuterMap);
-               AAINQInstanceFilters tempInstanceFilters = new AAINQInstanceFilters();
-               tempInstanceFilters.instanceFilter = tempInstanceFilter;
-               request.instanceFilters = tempInstanceFilters;
-               
-               AAINQResponse response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID());
-               assertNotNull(response);
-               assertNotNull(response.inventoryResponseItems);
-               
-               tempNamedQuery.namedQueryUUID = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087");
-               tempQueryParameters.namedQuery = tempNamedQuery;
-               request.queryParameters = tempQueryParameters;
-               tempInnerMap = new HashMap<>();
-               tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb");
-               tempOuterMap = new HashMap<>();
-               tempOuterMap.put("generic-vnf", tempInnerMap);
-               tempInstanceFilter = new LinkedList<>();
-               tempInstanceFilter.add(tempOuterMap);
-               tempInstanceFilters = new AAINQInstanceFilters();
-               tempInstanceFilters.instanceFilter = tempInstanceFilter;
-               request.instanceFilters = tempInstanceFilters;
-               
-               response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request, UUID.randomUUID());
-               assertNotNull(response);
-               assertNotNull(response.inventoryResponseItems);
-       }
+  @Test
+  public void testPost() {
+    final AAINQRequest request = new AAINQRequest();
+    final AAINQQueryParameters tempQueryParameters = new AAINQQueryParameters();
+    final AAINQNamedQuery tempNamedQuery = new AAINQNamedQuery();
+    tempNamedQuery.namedQueryUUID = UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469");
+    tempQueryParameters.namedQuery = tempNamedQuery;
+    request.queryParameters = tempQueryParameters;
+    Map<String, String> tempInnerMap = new HashMap<>();
+    tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+    Map<String, Map<String, String>> tempOuterMap = new HashMap<>();
+    tempOuterMap.put("vserver", tempInnerMap);
+    List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>();
+    tempInstanceFilter.add(tempOuterMap);
+    AAINQInstanceFilters tempInstanceFilters = new AAINQInstanceFilters();
+    tempInstanceFilters.instanceFilter = tempInstanceFilter;
+    request.instanceFilters = tempInstanceFilters;
+
+    AAINQResponse response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass",
+        request, UUID.randomUUID());
+    assertNotNull(response);
+    assertNotNull(response.inventoryResponseItems);
+
+    tempNamedQuery.namedQueryUUID = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087");
+    tempQueryParameters.namedQuery = tempNamedQuery;
+    request.queryParameters = tempQueryParameters;
+    tempInnerMap = new HashMap<>();
+    tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb");
+    tempOuterMap = new HashMap<>();
+    tempOuterMap.put("generic-vnf", tempInnerMap);
+    tempInstanceFilter = new LinkedList<>();
+    tempInstanceFilter.add(tempOuterMap);
+    tempInstanceFilters = new AAINQInstanceFilters();
+    tempInstanceFilters.instanceFilter = tempInstanceFilter;
+    request.instanceFilters = tempInstanceFilters;
+
+    response = AAIManager.postQuery("http://localhost:6666", "testUser", "testPass", request,
+        UUID.randomUUID());
+    assertNotNull(response);
+    assertNotNull(response.inventoryResponseItems);
+  }
 }
index 2cf6b8e..683da86 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -20,7 +20,8 @@
 
 package org.onap.policy.simulators;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import java.util.HashMap;
 import java.util.UUID;
@@ -29,6 +30,9 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
+import org.onap.policy.rest.RESTManager;
+import org.onap.policy.rest.RESTManager.Pair;
 import org.onap.policy.so.SOCloudConfiguration;
 import org.onap.policy.so.SOModelInfo;
 import org.onap.policy.so.SORelatedInstance;
@@ -39,95 +43,105 @@ import org.onap.policy.so.SORequestInfo;
 import org.onap.policy.so.SORequestParameters;
 import org.onap.policy.so.SOResponse;
 import org.onap.policy.so.util.Serialization;
-import org.onap.policy.rest.RESTManager;
-import org.onap.policy.rest.RESTManager.Pair;
 
 public class SoSimulatorTest {
-       
-       @BeforeClass
-       public static void setUpSimulator() {
-               try {
-                       Util.buildSoSim();
-               } catch (Exception e) {
-                       fail(e.getMessage());
-               }
-       }
-       
-       @AfterClass
-       public static void tearDownSimulator() {
-               HttpServletServer.factory.destroy();
-       }
-       
-       /**
-        * Create dummy SO request for TestResponse() junit
-        */
-       private SORequest createTestRequest() {
-               
-               // Construct SO Request
-               SORequest request = new SORequest();
-               request.requestId = UUID.randomUUID();
-               request.requestDetails = new SORequestDetails();
-               request.requestDetails.modelInfo = new SOModelInfo();
-               request.requestDetails.cloudConfiguration = new SOCloudConfiguration();
-               request.requestDetails.requestInfo = new SORequestInfo();
-               request.requestDetails.requestParameters = new SORequestParameters();
-               request.requestDetails.requestParameters.userParams = null;
-               //
-               // cloudConfiguration
-               //
-               request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW";
-               request.requestDetails.cloudConfiguration.tenantId = "1015548";
-               //
-               // modelInfo
-               //
-               request.requestDetails.modelInfo.modelType = "vfModule";
-               request.requestDetails.modelInfo.modelInvariantId = "f32568ec-2f1c-458a-864b-0593d53d141a";
-               request.requestDetails.modelInfo.modelNameVersionId = "69615025-879d-4f0d-afe3-b7d1a7eeed1f";
-               request.requestDetails.modelInfo.modelName = "C15ce9e1E9144c8fB8bb..dnsscaling..module-1";
-               request.requestDetails.modelInfo.modelVersion = "1.0";
-               //
-               // requestInfo
-               //
-               request.requestDetails.requestInfo.instanceName = "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
-               request.requestDetails.requestInfo.source = "POLICY";
-               request.requestDetails.requestInfo.suppressRollback = false;
-               //
-               // relatedInstanceList
-               //
-               SORelatedInstanceListElement relatedInstanceListElement1 = new SORelatedInstanceListElement();
-               SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement();
-               relatedInstanceListElement1.relatedInstance = new SORelatedInstance();
-               relatedInstanceListElement2.relatedInstance = new SORelatedInstance();
-               //
-               relatedInstanceListElement1.relatedInstance.instanceId = "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5";
-               relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo();
-               relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
-               relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b";
-               relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = "5c996219-b2e2-4c76-9b43-7e8672a33c1d";
-               relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "8330e932-2a23-4943-8606";
-               relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "1.0";
-               //
-               relatedInstanceListElement2.relatedInstance.instanceId = "594e2fe0-48b8-41ff-82e2-3d4bab69b192";
-               relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
-               relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
-               relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "033a32ed-aa65-4764-a736-36f2942f1aa0";
-               relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "d4d072dc-4e21-4a03-9524-628985819a8e";
-               relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "c15ce9e1-e914-4c8f-b8bb";
-               relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1";
-               relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = "c15ce9e1-e914-4c8f-b8bb 1";
-               //      
-               request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
-               request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
-               
-               return request;
-       }
-       
-       @Test
-       public void testResponse(){
-               String request = Serialization.gsonPretty.toJson(createTestRequest());
-               Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username", "password", new HashMap<>(), "application/json", request);
-               assertNotNull(httpDetails);
-               SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
-               assertNotNull(response);
-       }
+
+  @BeforeClass
+  public static void setUpSimulator() {
+    LoggerUtil.setLevel("ROOT", "INFO");
+    LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+    try {
+      Util.buildSoSim();
+    } catch (final Exception e) {
+      fail(e.getMessage());
+    }
+  }
+
+  @AfterClass
+  public static void tearDownSimulator() {
+    HttpServletServer.factory.destroy();
+  }
+
+  /**
+   * Create dummy SO request for TestResponse() junit
+   */
+  private SORequest createTestRequest() {
+
+    // Construct SO Request
+    final SORequest request = new SORequest();
+    request.requestId = UUID.randomUUID();
+    request.requestDetails = new SORequestDetails();
+    request.requestDetails.modelInfo = new SOModelInfo();
+    request.requestDetails.cloudConfiguration = new SOCloudConfiguration();
+    request.requestDetails.requestInfo = new SORequestInfo();
+    request.requestDetails.requestParameters = new SORequestParameters();
+    request.requestDetails.requestParameters.userParams = null;
+    //
+    // cloudConfiguration
+    //
+    request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW";
+    request.requestDetails.cloudConfiguration.tenantId = "1015548";
+    //
+    // modelInfo
+    //
+    request.requestDetails.modelInfo.modelType = "vfModule";
+    request.requestDetails.modelInfo.modelInvariantId = "f32568ec-2f1c-458a-864b-0593d53d141a";
+    request.requestDetails.modelInfo.modelNameVersionId = "69615025-879d-4f0d-afe3-b7d1a7eeed1f";
+    request.requestDetails.modelInfo.modelName = "C15ce9e1E9144c8fB8bb..dnsscaling..module-1";
+    request.requestDetails.modelInfo.modelVersion = "1.0";
+    //
+    // requestInfo
+    //
+    request.requestDetails.requestInfo.instanceName =
+        "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
+    request.requestDetails.requestInfo.source = "POLICY";
+    request.requestDetails.requestInfo.suppressRollback = false;
+    //
+    // relatedInstanceList
+    //
+    final SORelatedInstanceListElement relatedInstanceListElement1 =
+        new SORelatedInstanceListElement();
+    final SORelatedInstanceListElement relatedInstanceListElement2 =
+        new SORelatedInstanceListElement();
+    relatedInstanceListElement1.relatedInstance = new SORelatedInstance();
+    relatedInstanceListElement2.relatedInstance = new SORelatedInstance();
+    //
+    relatedInstanceListElement1.relatedInstance.instanceId = "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5";
+    relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo();
+    relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+    relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId =
+        "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b";
+    relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId =
+        "5c996219-b2e2-4c76-9b43-7e8672a33c1d";
+    relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "8330e932-2a23-4943-8606";
+    relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "1.0";
+    //
+    relatedInstanceListElement2.relatedInstance.instanceId = "594e2fe0-48b8-41ff-82e2-3d4bab69b192";
+    relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
+    relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+    relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId =
+        "033a32ed-aa65-4764-a736-36f2942f1aa0";
+    relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId =
+        "d4d072dc-4e21-4a03-9524-628985819a8e";
+    relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "c15ce9e1-e914-4c8f-b8bb";
+    relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1";
+    relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName =
+        "c15ce9e1-e914-4c8f-b8bb 1";
+    //
+    request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+    request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+
+    return request;
+  }
+
+  @Test
+  public void testResponse() {
+    final String request = Serialization.gsonPretty.toJson(this.createTestRequest());
+    final Pair<Integer, String> httpDetails = RESTManager.post(
+        "http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username",
+        "password", new HashMap<>(), "application/json", request);
+    assertNotNull(httpDetails);
+    final SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
+    assertNotNull(response);
+  }
 }
index 7dadaad..a063277 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -21,8 +21,8 @@
 package org.onap.policy.simulators;
 
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.util.HashMap;
 
@@ -30,41 +30,50 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.utils.LoggerUtil;
 import org.onap.policy.rest.RESTManager;
 import org.onap.policy.rest.RESTManager.Pair;
 import org.onap.policy.vfc.VFCResponse;
 import org.onap.policy.vfc.util.Serialization;
 
 public class VfcSimulatorTest {
-       
-       @BeforeClass
-       public static void setUpSimulator() {
-               try {
-                       Util.buildVfcSim();
-               } catch (Exception e) {
-                       fail(e.getMessage());
-               }
-       }
-       
-       @AfterClass
-       public static void tearDownSimulator() {
-               HttpServletServer.factory.destroy();
-       }
-       
-       @Test
-       public void testPost(){
-               Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password", new HashMap<String, String>(), "application/json", "Some Request Here");
-               assertNotNull(httpDetails);
-                assertTrue(httpDetails.a == 202);
-               VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
-               assertNotNull(response);
-       }
-       
-       @Test
-       public void testGet(){
-               Pair<Integer, String> httpDetails = RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password", new HashMap<String, String>());
-               assertNotNull(httpDetails);
-               VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
-               assertNotNull(response);
-       }
+
+  @BeforeClass
+  public static void setUpSimulator() {
+    LoggerUtil.setLevel("ROOT", "INFO");
+    LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
+    try {
+      Util.buildVfcSim();
+    } catch (final Exception e) {
+      fail(e.getMessage());
+    }
+  }
+
+  @AfterClass
+  public static void tearDownSimulator() {
+    HttpServletServer.factory.destroy();
+  }
+
+  @Test
+  public void testPost() {
+    final Pair<Integer, String> httpDetails =
+        RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username",
+            "password", new HashMap<String, String>(), "application/json", "Some Request Here");
+    assertNotNull(httpDetails);
+    assertTrue(httpDetails.a == 202);
+    final VFCResponse response =
+        Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
+    assertNotNull(response);
+  }
+
+  @Test
+  public void testGet() {
+    final Pair<Integer, String> httpDetails =
+        RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password",
+            new HashMap<String, String>());
+    assertNotNull(httpDetails);
+    final VFCResponse response =
+        Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
+    assertNotNull(response);
+  }
 }
index f591bdc..8b3acdc 100644 (file)
                        <version>${project.version}</version>
                        <type>zip</type>
                </dependency>
+               <dependency>
+                       <groupId>org.onap.policy.drools-applications</groupId>
+                       <artifactId>feature-controlloop-utils</artifactId>
+                       <version>${project.version}</version>
+                       <type>zip</type>
+               </dependency>
        </dependencies>
 
 </project>