Fix timing and move tests 33/72833/2
authorliamfallon <liam.fallon@ericsson.com>
Thu, 15 Nov 2018 22:07:45 +0000 (22:07 +0000)
committerliamfallon <liam.fallon@ericsson.com>
Fri, 16 Nov 2018 11:14:01 +0000 (11:14 +0000)
The timings on the REST test are too short and time out on ONAP Jenkins

The tests of the Apex service and Apex model upgrade are not
benchmark tests so are moved to Integration.

Issue-ID: POLICY-1251
Change-Id: I2672d01042b33fe0cce5223005295e3b1aa26e7a
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
12 files changed:
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJRuby.json [new file with mode: 0644]
testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJava.json [new file with mode: 0644]
testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json [moved from testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEvent.json with 89% similarity]
testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJython.json [new file with mode: 0644]
testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventMvel.json [new file with mode: 0644]
testsuites/integration/integration-uservice-test/pom.xml
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java [moved from testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/runtime/ApexServiceModelUpdateTest.java with 80% similarity]
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java [moved from testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/runtime/ApexServiceTest.java with 85% similarity]
testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/utils/Utils.java [deleted file]

index aa82e1c..c39be64 100644 (file)
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 
 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.service.ModelService;
 import org.onap.policy.apex.model.utilities.TextFileUtils;
 import org.onap.policy.apex.service.engine.engdep.EngDepMessagingService;
 import org.onap.policy.apex.service.engine.runtime.EngineService;
@@ -32,6 +33,7 @@ import org.onap.policy.apex.service.engine.runtime.impl.EngineServiceImpl;
 import org.onap.policy.apex.service.parameters.ApexParameters;
 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+import org.onap.policy.common.parameters.ParameterService;
 import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 
@@ -179,6 +181,10 @@ public class ApexActivator {
             engineServiceHandler.terminate();
             engineServiceHandler = null;
         }
+
+        // Clear the services
+        ModelService.clear();
+        ParameterService.clear();
     }
 
     /**
diff --git a/testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJRuby.json b/testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJRuby.json
new file mode 100644 (file)
index 0000000..9d1c891
--- /dev/null
@@ -0,0 +1,45 @@
+{
+    "engineServiceParameters": {
+        "name": "MyApexEngine",
+        "version": "0.0.1",
+        "id": 45,
+        "instanceCount": 4,
+        "deploymentPort": 12561,
+        "policyModelFileName": "examples/models/SampleDomain/SamplePolicyModelJRUBY.xml",
+        "engineParameters": {
+            "executorParameters": {
+                "JRUBY": {
+                    "parameterClassName": "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
+                }
+            }
+        }
+    },
+    "eventInputParameters": {
+        "FirstConsumer": {
+            "carrierTechnologyParameters": {
+                "carrierTechnology": "RESTCLIENT",
+                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+                "parameters": {
+                    "url": "http://localhost:32801/EventGenerator/GetEvents"
+                }
+            },
+            "eventProtocolParameters": {
+                "eventProtocol": "JSON"
+            }
+        }
+    },
+    "eventOutputParameters": {
+        "FirstProducer": {
+            "carrierTechnologyParameters": {
+                "carrierTechnology": "RESTCLIENT",
+                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+                "parameters": {
+                    "url": "http://localhost:32801/EventGenerator/PostEvent"
+                }
+            },
+            "eventProtocolParameters": {
+                "eventProtocol": "JSON"
+            }
+        }
+    }
+}
diff --git a/testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJava.json b/testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJava.json
new file mode 100644 (file)
index 0000000..2602390
--- /dev/null
@@ -0,0 +1,45 @@
+{
+    "engineServiceParameters": {
+        "name": "MyApexEngine",
+        "version": "0.0.1",
+        "id": 45,
+        "instanceCount": 4,
+        "deploymentPort": 12561,
+        "policyModelFileName": "examples/models/SampleDomain/SamplePolicyModelJAVA.xml",
+        "engineParameters": {
+            "executorParameters": {
+                "JAVA": {
+                    "parameterClassName": "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
+                }
+            }
+        }
+    },
+    "eventInputParameters": {
+        "FirstConsumer": {
+            "carrierTechnologyParameters": {
+                "carrierTechnology": "RESTCLIENT",
+                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+                "parameters": {
+                    "url": "http://localhost:32801/EventGenerator/GetEvents"
+                }
+            },
+            "eventProtocolParameters": {
+                "eventProtocol": "JSON"
+            }
+        }
+    },
+    "eventOutputParameters": {
+        "FirstProducer": {
+            "carrierTechnologyParameters": {
+                "carrierTechnology": "RESTCLIENT",
+                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+                "parameters": {
+                    "url": "http://localhost:32801/EventGenerator/PostEvent"
+                }
+            },
+            "eventProtocolParameters": {
+                "eventProtocol": "JSON"
+            }
+        }
+    }
+}
@@ -20,7 +20,7 @@
                 "carrierTechnology": "RESTCLIENT",
                 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
                 "parameters": {
-                    "url": "http://localhost:32801/TestRest2REST/apex/event/GetEvent"
+                    "url": "http://localhost:32801/EventGenerator/GetEvents"
                 }
             },
             "eventProtocolParameters": {
@@ -34,7 +34,7 @@
                 "carrierTechnology": "RESTCLIENT",
                 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
                 "parameters": {
-                    "url": "http://localhost:32801/TestRest2REST/apex/event/PostEvent"
+                    "url": "http://localhost:32801/EventGenerator/PostEvent"
                 }
             },
             "eventProtocolParameters": {
diff --git a/testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJython.json b/testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventJython.json
new file mode 100644 (file)
index 0000000..0bd8c35
--- /dev/null
@@ -0,0 +1,45 @@
+{
+    "engineServiceParameters": {
+        "name": "MyApexEngine",
+        "version": "0.0.1",
+        "id": 45,
+        "instanceCount": 4,
+        "deploymentPort": 12561,
+        "policyModelFileName": "examples/models/SampleDomain/SamplePolicyModelJYTHON.xml",
+        "engineParameters": {
+            "executorParameters": {
+                "JYTHON": {
+                    "parameterClassName": "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
+                }
+            }
+        }
+    },
+    "eventInputParameters": {
+        "FirstConsumer": {
+            "carrierTechnologyParameters": {
+                "carrierTechnology": "RESTCLIENT",
+                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+                "parameters": {
+                    "url": "http://localhost:32801/EventGenerator/GetEvents"
+                }
+            },
+            "eventProtocolParameters": {
+                "eventProtocol": "JSON"
+            }
+        }
+    },
+    "eventOutputParameters": {
+        "FirstProducer": {
+            "carrierTechnologyParameters": {
+                "carrierTechnology": "RESTCLIENT",
+                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+                "parameters": {
+                    "url": "http://localhost:32801/EventGenerator/PostEvent"
+                }
+            },
+            "eventProtocolParameters": {
+                "eventProtocol": "JSON"
+            }
+        }
+    }
+}
diff --git a/testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventMvel.json b/testsuites/integration/integration-common/src/main/resources/examples/config/SampleDomain/REST2RESTJsonEventMvel.json
new file mode 100644 (file)
index 0000000..b62b93e
--- /dev/null
@@ -0,0 +1,45 @@
+{
+    "engineServiceParameters": {
+        "name": "MyApexEngine",
+        "version": "0.0.1",
+        "id": 45,
+        "instanceCount": 4,
+        "deploymentPort": 12561,
+        "policyModelFileName": "examples/models/SampleDomain/SamplePolicyModelMVEL.xml",
+        "engineParameters": {
+            "executorParameters": {
+                "MVEL": {
+                    "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
+                }
+            }
+        }
+    },
+    "eventInputParameters": {
+        "FirstConsumer": {
+            "carrierTechnologyParameters": {
+                "carrierTechnology": "RESTCLIENT",
+                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+                "parameters": {
+                    "url": "http://localhost:32801/EventGenerator/GetEvents"
+                }
+            },
+            "eventProtocolParameters": {
+                "eventProtocol": "JSON"
+            }
+        }
+    },
+    "eventOutputParameters": {
+        "FirstProducer": {
+            "carrierTechnologyParameters": {
+                "carrierTechnology": "RESTCLIENT",
+                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+                "parameters": {
+                    "url": "http://localhost:32801/EventGenerator/PostEvent"
+                }
+            },
+            "eventProtocolParameters": {
+                "eventProtocol": "JSON"
+            }
+        }
+    }
+}
index 5c595e5..b139f24 100644 (file)
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
+            <artifactId>plugins-executor-mvel</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
             <artifactId>plugins-context-distribution-infinispan</artifactId>
index 5c8eb7e..7afef53 100644 (file)
@@ -41,9 +41,9 @@ import org.onap.policy.apex.service.engine.main.ApexMain;
  * The Class TestKafka2Kafka tests Kafka event sending and reception.
  */
 public class TestKafka2Kafka {
-    private static final long MAX_TEST_LENGTH = 60000;
+    private static final long MAX_TEST_LENGTH = 300000;
 
-    private static final int EVENT_COUNT = 100;
+    private static final int EVENT_COUNT = 25;
     private static final int EVENT_INTERVAL = 20;
 
     /**
@@ -131,7 +131,7 @@ public class TestKafka2Kafka {
             ThreadUtilities.sleep(EVENT_INTERVAL);
         }
 
-        ThreadUtilities.sleep(1000);
+        ThreadUtilities.sleep(3000);
 
         apexMain.shutdown();
         subscriber.shutdown();
index 9a9b48b..69bcf87 100644 (file)
@@ -156,8 +156,8 @@ public class TestFile2Rest {
         Response response = null;
 
         // Wait for the required amount of events to be received or for 10 seconds
-        for (int i = 0; i < 100; i++) {
-            ThreadUtilities.sleep(100);
+        for (int i = 0; i < 20; i++) {
+            ThreadUtilities.sleep(300);
             response = client.target("http://localhost:32801/TestFile2Rest/apex/event/Stats")
                             .request("application/json").get();
 
@@ -169,7 +169,7 @@ public class TestFile2Rest {
 
             @SuppressWarnings("unchecked")
             final Map<String, Object> jsonMap = new Gson().fromJson(responseString, Map.class);
-            if ((double) jsonMap.get("PUT") == 100) {
+            if ((double) jsonMap.get("PUT") == 20) {
                 break;
             }
         }
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.testsuites.performance.benchmark.engine.runtime;
+package org.onap.policy.apex.testsuites.integration.uservice.engine;
 
 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.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Date;
 import java.util.HashMap;
@@ -33,11 +34,22 @@ import java.util.Map;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.DistributorParameters;
+import org.onap.policy.apex.context.parameters.LockManagerParameters;
+import org.onap.policy.apex.context.parameters.PersistorParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
+import org.onap.policy.apex.core.engine.EngineParameterConstants;
+import org.onap.policy.apex.core.engine.EngineParameters;
 import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
 import org.onap.policy.apex.model.basicmodel.service.ModelService;
 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
 import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters;
 import org.onap.policy.apex.service.engine.event.ApexEvent;
 import org.onap.policy.apex.service.engine.event.ApexEventException;
@@ -45,9 +57,10 @@ import org.onap.policy.apex.service.engine.runtime.ApexEventListener;
 import org.onap.policy.apex.service.engine.runtime.EngineService;
 import org.onap.policy.apex.service.engine.runtime.EngineServiceEventInterface;
 import org.onap.policy.apex.service.engine.runtime.impl.EngineServiceImpl;
+import org.onap.policy.apex.service.parameters.ApexParameterConstants;
 import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
 import org.onap.policy.apex.testsuites.integration.common.model.SampleDomainModelFactory;
-import org.onap.policy.apex.testsuites.performance.benchmark.engine.utils.Utils;
+import org.onap.policy.common.parameters.ParameterService;
 import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 
@@ -69,6 +82,37 @@ public class ApexServiceModelUpdateTest {
     private AxPolicyModel apexSamplePolicyModel = null;
     private String apexSampleModelString;
 
+    /**
+     * Set up parameters.
+     */
+    @Before
+    public void setupParameters() {
+        ParameterService.register(new SchemaParameters());
+        ParameterService.register(new ContextParameters());
+        ParameterService.register(new DistributorParameters());
+        ParameterService.register(new LockManagerParameters());
+        ParameterService.register(new PersistorParameters());
+        ParameterService.register(new EngineServiceParameters());
+
+        EngineParameters engineParameters = new EngineParameters();
+        engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
+        ParameterService.register(engineParameters);
+    }
+
+    /**
+     * Clear down parameters.
+     */
+    @After
+    public void teardownParameters() {
+        ParameterService.deregister(EngineParameterConstants.MAIN_GROUP_NAME);
+        ParameterService.deregister(ApexParameterConstants.ENGINE_SERVICE_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.MAIN_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+    }
+
     /**
      * Sets up the test by creating an engine and reading in the test policy.
      *
@@ -87,10 +131,10 @@ public class ApexServiceModelUpdateTest {
 
         LOGGER.debug("Running TestApexEngine. . .");
 
-        apexSamplePolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+        apexSamplePolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
         assertNotNull(apexSamplePolicyModel);
 
-        apexSampleModelString = Utils.getModelString(apexSamplePolicyModel);
+        apexSampleModelString = getModelString(apexSamplePolicyModel);
 
         // create engine
         listener = new TestListener();
@@ -133,7 +177,7 @@ public class ApexServiceModelUpdateTest {
     @Test
     public void testModelUpdateStringNewNoForce() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexSampleModelString, false);
-        service.startAll();
+
         assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
     }
 
@@ -145,7 +189,7 @@ public class ApexServiceModelUpdateTest {
     @Test
     public void testModelUpdateStringNewForce() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexSampleModelString, true);
-        service.startAll();
+
         assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
     }
 
@@ -157,7 +201,7 @@ public class ApexServiceModelUpdateTest {
     @Test
     public void testModelUpdateStringNewNewNoForce() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexSampleModelString, false);
-        service.startAll();
+
         assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
 
         sendEvents();
@@ -176,7 +220,7 @@ public class ApexServiceModelUpdateTest {
     @Test
     public void testModelUpdateIncoNoForce() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexSamplePolicyModel, false);
-        service.startAll();
+
         assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
 
         // Different model name, incompatible
@@ -189,8 +233,8 @@ public class ApexServiceModelUpdateTest {
         } catch (final Exception e) {
             System.err.println(e.getMessage());
             assertEquals("apex model update failed, supplied model with key \"INCOMPATIBLE:0.0.1\" is not a compatible "
-                            + "model update from the existing engine model with key \"SamplePolicyModelMVEL:0.0.1\"",
-                            e.getMessage());
+                            + "model update from the existing engine model "
+                            + "with key \"SamplePolicyModelJAVASCRIPT:0.0.1\"", e.getMessage());
         }
 
         // Still on old model
@@ -206,9 +250,9 @@ public class ApexServiceModelUpdateTest {
         } catch (final Exception e) {
             System.err.println(e.getMessage());
             e.printStackTrace();
-            assertEquals("apex model update failed, supplied model with key \"SamplePolicyModelMVEL:1.0.1\" is not "
-                            + "a compatible model update from the existing engine model with key "
-                            + "\"SamplePolicyModelMVEL:0.0.1\"", e.getMessage());
+            assertEquals("apex model update failed, supplied model with key \"SamplePolicyModelJAVASCRIPT:1.0.1\" "
+                            + "is not a compatible model update from the existing engine model with key "
+                            + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"", e.getMessage());
         }
 
         // Still on old model
@@ -240,7 +284,7 @@ public class ApexServiceModelUpdateTest {
     @Test
     public void testModelUpdateIncoForce() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexSamplePolicyModel, false);
-        service.startAll();
+
         assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
 
         // Different model name, incompatible
@@ -359,4 +403,20 @@ public class ApexServiceModelUpdateTest {
                             && ((byte) result.get("TestActCaseSelected") <= 3));
         }
     }
+    
+
+    /**
+     * Gets the model string.
+     *
+     * @param policyModel the eca policy model
+     * @return the model string
+     * @throws ApexModelException the apex model exception
+     * @throws IOException Signals that an I/O exception has occurred.
+     */
+    private String getModelString(final AxPolicyModel policyModel) throws ApexModelException, IOException {
+        try (final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream()) {
+            new ApexModelWriter<AxPolicyModel>(AxPolicyModel.class).write(policyModel, baOutputStream);
+            return baOutputStream.toString();
+        }
+    }
 }
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.testsuites.performance.benchmark.engine.runtime;
+package org.onap.policy.apex.testsuites.integration.uservice.engine;
 
 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.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.junit.After;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.DistributorParameters;
+import org.onap.policy.apex.context.parameters.LockManagerParameters;
+import org.onap.policy.apex.context.parameters.PersistorParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
+import org.onap.policy.apex.core.engine.EngineParameterConstants;
+import org.onap.policy.apex.core.engine.EngineParameters;
 import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
 import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters;
 import org.onap.policy.apex.service.engine.event.ApexEvent;
 import org.onap.policy.apex.service.engine.runtime.ApexEventListener;
 import org.onap.policy.apex.service.engine.runtime.EngineService;
 import org.onap.policy.apex.service.engine.runtime.EngineServiceEventInterface;
 import org.onap.policy.apex.service.engine.runtime.impl.EngineServiceImpl;
+import org.onap.policy.apex.service.parameters.ApexParameterConstants;
 import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
 import org.onap.policy.apex.testsuites.integration.common.model.SampleDomainModelFactory;
-import org.onap.policy.apex.testsuites.performance.benchmark.engine.utils.Utils;
+import org.onap.policy.common.parameters.ParameterService;
 import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 
@@ -90,16 +106,47 @@ public class ApexServiceTest {
 
         LOGGER.debug("Running TestApexEngine. . .");
 
-        apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+        apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
         assertNotNull(apexPolicyModel);
 
-        apexModelString = Utils.getModelString(apexPolicyModel);
+        apexModelString = getModelString(apexPolicyModel);
 
         // create engine
         listener = new TestListener();
         service.registerActionListener("Listener", listener);
     }
 
+    /**
+     * Set up parameters.
+     */
+    @Before
+    public void setupParameters() {
+        ParameterService.register(new SchemaParameters());
+        ParameterService.register(new ContextParameters());
+        ParameterService.register(new DistributorParameters());
+        ParameterService.register(new LockManagerParameters());
+        ParameterService.register(new PersistorParameters());
+        ParameterService.register(new EngineServiceParameters());
+        
+        EngineParameters engineParameters = new EngineParameters();
+        engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
+        ParameterService.register(engineParameters);
+    }
+    
+    /**
+     * Clear down parameters.
+     */
+    @After
+    public void teardownParameters() {
+        ParameterService.deregister(EngineParameterConstants.MAIN_GROUP_NAME);
+        ParameterService.deregister(ApexParameterConstants.ENGINE_SERVICE_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.MAIN_GROUP_NAME);
+        ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+    }
+    
     /**
      * Update the engine then test the engine with 2 sample events.
      *
@@ -108,8 +155,7 @@ public class ApexServiceTest {
     @Test
     public void testExecutionSet1() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexModelString, true);
-        // Start the service
-        service.startAll();
+
         final long starttime = System.currentTimeMillis();
         for (final AxArtifactKey engineKey : service.getEngineKeys()) {
             LOGGER.info("{}", service.getStatus(engineKey));
@@ -172,8 +218,7 @@ public class ApexServiceTest {
     @Test
     public void testExecutionSet1Sync() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexModelString, true);
-        // Start the service
-        service.startAll();
+
         final long starttime = System.currentTimeMillis();
         for (final AxArtifactKey engineKey : service.getEngineKeys()) {
             LOGGER.info("{}", service.getStatus(engineKey));
@@ -261,8 +306,7 @@ public class ApexServiceTest {
     @Test
     public void testExecutionSet2() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexModelString, true);
-        // Start the service
-        service.startAll();
+
         final long starttime = System.currentTimeMillis();
         for (final AxArtifactKey engineKey : service.getEngineKeys()) {
             LOGGER.info("{}", service.getStatus(engineKey));
@@ -324,8 +368,7 @@ public class ApexServiceTest {
     @Test
     public void testExecutionSet2Sync() throws ApexException {
         service.updateModel(parameters.getEngineKey(), apexModelString, true);
-        // Start the service
-        service.startAll();
+
         final long starttime = System.currentTimeMillis();
         for (final AxArtifactKey engineKey : service.getEngineKeys()) {
             LOGGER.info("{}", service.getStatus(engineKey));
@@ -474,4 +517,19 @@ public class ApexServiceTest {
                     ((byte) result.get("TestActCaseSelected")) >= 0 && ((byte) result.get("TestActCaseSelected") <= 3));
         }
     }
+
+    /**
+     * Gets the model string.
+     *
+     * @param policyModel the eca policy model
+     * @return the model string
+     * @throws ApexModelException the apex model exception
+     * @throws IOException Signals that an I/O exception has occurred.
+     */
+    private static String getModelString(final AxPolicyModel policyModel) throws ApexModelException, IOException {
+        try (final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream()) {
+            new ApexModelWriter<AxPolicyModel>(AxPolicyModel.class).write(policyModel, baOutputStream);
+            return baOutputStream.toString();
+        }
+    }
 }
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/utils/Utils.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/utils/Utils.java
deleted file mode 100644 (file)
index 0d239a8..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Ericsson. 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.
- * 
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.testsuites.performance.benchmark.engine.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-
-/**
- * The Class Utils.
- */
-public class Utils {
-
-    /**
-     * Instantiates a new utils.
-     */
-    private Utils() {}
-
-    /**
-     * Gets the model string.
-     *
-     * @param ecaPolicyModel the eca policy model
-     * @return the model string
-     * @throws ApexModelException the apex model exception
-     * @throws IOException Signals that an I/O exception has occurred.
-     */
-    public static String getModelString(final AxPolicyModel ecaPolicyModel) throws ApexModelException, IOException {
-        try (final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream()) {
-            new ApexModelWriter<AxPolicyModel>(AxPolicyModel.class).write(ecaPolicyModel, baOutputStream);
-            return baOutputStream.toString();
-        }
-    }
-
-}