diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-08-30 09:37:29 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-08-31 19:23:41 +0100 |
commit | f32508381ce0b555fc14978cbaa458aa4e2d91c5 (patch) | |
tree | 1cab66e5372b6467f288ae1351ce836e4eba2d03 /testsuites/integration/integration-executor-test/src | |
parent | 052038c7a7e0b385462b3b653b7d06094d472df3 (diff) |
Use parameter service in apex
Switch parameter handling in apex to use
the ONAP PF common parameter service
Change-Id: Id318d19c726b18b1a69c630fa81ca7d695355e9c
Issue-ID: POLICY-954
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'testsuites/integration/integration-executor-test/src')
8 files changed, 395 insertions, 33 deletions
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java index 8b1cc0b04..3c0e9f984 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java @@ -22,12 +22,60 @@ package org.onap.policy.apex.plugins.executor.test.script.engine; import java.io.IOException; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters; +import org.onap.policy.common.parameters.ParameterService; public class TestApexEngineJRuby { + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + private EngineParameters engineParameters; + + @Before + public void beforeTest() { + schemaParameters = new SchemaParameters(); + + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + + contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + engineParameters = new EngineParameters(); + engineParameters.getExecutorParameterMap().put("JRUBY", new JrubyExecutorParameters()); + ParameterService.register(engineParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(engineParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + + ParameterService.deregister(schemaParameters); + } /** * Test apex engine. @@ -38,10 +86,7 @@ public class TestApexEngineJRuby { */ @Test public void testApexEngineJRuby() throws ApexException, InterruptedException, IOException { - final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("JRUBY", new JrubyExecutorParameters()); - - new TestApexEngine("JRUBY", parameters); - new TestApexEngine("JRUBY", parameters); + new TestApexEngine("JRUBY", engineParameters); + new TestApexEngine("JRUBY", engineParameters); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java index 44593a0a2..c1d68760d 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java @@ -22,10 +22,17 @@ package org.onap.policy.apex.plugins.executor.test.script.engine; import java.io.IOException; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters; +import org.onap.policy.common.parameters.ParameterService; /** * The Class TestApexEngine_Java. @@ -33,6 +40,47 @@ import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters; * @author Liam Fallon (liam.fallon@ericsson.com) */ public class TestApexEngineJava { + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + private EngineParameters engineParameters; + + @Before + public void beforeTest() { + schemaParameters = new SchemaParameters(); + + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + + contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + engineParameters = new EngineParameters(); + engineParameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters()); + ParameterService.register(engineParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(engineParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + + ParameterService.deregister(schemaParameters); + } /** * Test apex engine. @@ -43,10 +91,7 @@ public class TestApexEngineJava { */ @Test public void testApexEngineJava() throws InterruptedException, IOException, ApexException { - final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters()); - - new TestApexEngine("JAVA", parameters); - new TestApexEngine("JAVA", parameters); + new TestApexEngine("JAVA", engineParameters); + new TestApexEngine("JAVA", engineParameters); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java index 1f55f8458..1f5c1d4b8 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java @@ -22,12 +22,60 @@ package org.onap.policy.apex.plugins.executor.test.script.engine; import java.io.IOException; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters; +import org.onap.policy.common.parameters.ParameterService; public class TestApexEngineJavascript { + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + private EngineParameters engineParameters; + + @Before + public void beforeTest() { + schemaParameters = new SchemaParameters(); + + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + + contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + engineParameters = new EngineParameters(); + engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters()); + ParameterService.register(engineParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(engineParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + + ParameterService.deregister(schemaParameters); + } /** * Test apex engine. @@ -38,10 +86,8 @@ public class TestApexEngineJavascript { */ @Test public void testApexEngineJavascript() throws ApexException, InterruptedException, IOException { - final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters()); - new TestApexEngine("JAVASCRIPT", parameters); - new TestApexEngine("JAVASCRIPT", parameters); + new TestApexEngine("JAVASCRIPT", engineParameters); + new TestApexEngine("JAVASCRIPT", engineParameters); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java index eabe63dfb..b5b0f9a78 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java @@ -22,12 +22,60 @@ package org.onap.policy.apex.plugins.executor.test.script.engine; import java.io.IOException; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters; +import org.onap.policy.common.parameters.ParameterService; public class TestApexEngineJython { + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + private EngineParameters engineParameters; + + @Before + public void beforeTest() { + schemaParameters = new SchemaParameters(); + + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + + contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + engineParameters = new EngineParameters(); + engineParameters.getExecutorParameterMap().put("JYTHON", new JythonExecutorParameters()); + ParameterService.register(engineParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(engineParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + + ParameterService.deregister(schemaParameters); + } /** * Test apex engine. @@ -38,10 +86,7 @@ public class TestApexEngineJython { */ @Test public void testApexEngineJython() throws ApexException, InterruptedException, IOException { - final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("JYTHON", new JythonExecutorParameters()); - - new TestApexEngine("JYTHON", parameters); - new TestApexEngine("JYTHON", parameters); + new TestApexEngine("JYTHON", engineParameters); + new TestApexEngine("JYTHON", engineParameters); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java index aea7cecc6..e500c9d3b 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java @@ -22,12 +22,60 @@ package org.onap.policy.apex.plugins.executor.test.script.engine; import java.io.IOException; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.common.parameters.ParameterService; public class TestApexEngineMVEL { + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + private EngineParameters engineParameters; + + @Before + public void beforeTest() { + schemaParameters = new SchemaParameters(); + + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + + contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + engineParameters = new EngineParameters(); + engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + ParameterService.register(engineParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(engineParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + + ParameterService.deregister(schemaParameters); + } /** * Test apex engine. @@ -38,10 +86,7 @@ public class TestApexEngineMVEL { */ @Test public void testApexEngineMVEL() throws ApexException, InterruptedException, IOException { - final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); - - new TestApexEngine("MVEL", parameters); - new TestApexEngine("MVEL", parameters); + new TestApexEngine("MVEL", engineParameters); + new TestApexEngine("MVEL", engineParameters); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java index 0ed78a13f..07a374926 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java @@ -30,7 +30,13 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.core.engine.engine.ApexEngine; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; @@ -41,6 +47,7 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; import org.onap.policy.apex.test.common.model.SampleDomainModelFactory; +import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -53,6 +60,48 @@ public class TestEventInstantiation { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestEventInstantiation.class); + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + private EngineParameters engineParameters; + + @Before + public void beforeTest() { + schemaParameters = new SchemaParameters(); + + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + + contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + engineParameters = new EngineParameters(); + engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + ParameterService.register(engineParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(engineParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + + ParameterService.deregister(schemaParameters); + } + /** * Test event instantiation. * @@ -69,9 +118,6 @@ public class TestEventInstantiation { final AxPolicyModel apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL"); assertNotNull(apexPolicyModel); - final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); - final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(apexPolicyModel.getKey()); apexEngine.updateModel(apexPolicyModel); apexEngine.start(); diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java index 5ca71cf33..83e69c98f 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java @@ -27,8 +27,14 @@ import static org.junit.Assert.fail; import java.io.IOException; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.context.ContextAlbum; +import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl; @@ -38,6 +44,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; import org.onap.policy.apex.plugins.executor.test.script.engine.TestApexActionListener; import org.onap.policy.apex.test.common.model.SampleDomainModelFactory; +import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -50,6 +57,48 @@ public class TestContextUpdateDifferentModels { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateDifferentModels.class); + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + private EngineParameters engineParameters; + + @Before + public void beforeTest() { + schemaParameters = new SchemaParameters(); + + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + + contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + engineParameters = new EngineParameters(); + engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + ParameterService.register(engineParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(engineParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + + ParameterService.deregister(schemaParameters); + } + @Test public void testContextUpdateDifferentModels() throws ApexException, InterruptedException, IOException { logger.debug("Running test testContextUpdateDifferentModels . . ."); @@ -57,9 +106,6 @@ public class TestContextUpdateDifferentModels { final AxPolicyModel apexModelSample = new SampleDomainModelFactory().getSamplePolicyModel("MVEL"); assertNotNull(apexModelSample); - final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); - final ApexEngineImpl apexEngine = (ApexEngineImpl) new ApexEngineFactory().createApexEngine(new AxArtifactKey("TestApexEngine", "0.0.1")); final TestApexActionListener listener = new TestApexActionListener("Test"); diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java index e78d4c5bb..7aaa1e585 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java @@ -30,8 +30,13 @@ import java.util.HashMap; import java.util.Map; import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.context.ContextException; +import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.ContextParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.core.engine.engine.ApexEngine; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; @@ -42,6 +47,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; import org.onap.policy.apex.plugins.executor.test.script.engine.TestApexActionListener; import org.onap.policy.apex.test.common.model.SampleDomainModelFactory; +import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -54,14 +60,52 @@ public class TestContextUpdateModel { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateModel.class); + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + private EngineParameters engineParameters; + + @Before + public void beforeTest() { + schemaParameters = new SchemaParameters(); + + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + + contextParameters = new ContextParameters(); + + contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); + contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME); + contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME); + + ParameterService.register(contextParameters); + ParameterService.register(contextParameters.getDistributorParameters()); + ParameterService.register(contextParameters.getLockManagerParameters()); + ParameterService.register(contextParameters.getPersistorParameters()); + + engineParameters = new EngineParameters(); + engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + ParameterService.register(engineParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(engineParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + + ParameterService.deregister(schemaParameters); + } @Test public void testContextUpdateModel() throws ApexException, InterruptedException, IOException { final AxArtifactKey key = new AxArtifactKey("TestApexEngine", "0.0.1"); - final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); - final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(key); final TestApexActionListener listener = new TestApexActionListener("Test"); apexEngine.addEventListener("listener", listener); |