diff options
Diffstat (limited to 'context/context-test-utils/src/test')
6 files changed, 223 insertions, 30 deletions
diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java index 5487a0934..6b9ba15ad 100644 --- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java +++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextAlbumUpdate.java @@ -22,11 +22,16 @@ package org.onap.policy.apex.context.test.distribution; import java.io.IOException; import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor; +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.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; +import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -34,11 +39,44 @@ public class TestContextAlbumUpdate { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestContextAlbumUpdate.class); + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + + @Before + public void beforeTest() { + 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()); + + schemaParameters = new SchemaParameters(); + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(schemaParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + } + @Test public void testContextAlbumUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextAlbumUpdateJVMLocalVarSet test . . ."); - final ContextParameters contextParameters = new ContextParameters(); contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName()); new ContextAlbumUpdate().testContextAlbumUpdate(); @@ -49,15 +87,8 @@ public class TestContextAlbumUpdate { public void testContextAlbumUpdateJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextAlbumUpdateJVMLocalVarNotSet test . . ."); - new ContextParameters(); new ContextAlbumUpdate().testContextAlbumUpdate(); logger.debug("Ran testContextAlbumUpdateJVMLocalVarNotSet test"); } - - /** - * Test context update cleardown. - */ - @After - public void testContextAlbumUpdateCleardown() {} } diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java index 409033ad4..b10bc685c 100644 --- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java +++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextInstantiation.java @@ -25,9 +25,13 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor; +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.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; +import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -40,20 +44,44 @@ public class TestContextInstantiation { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestContextInstantiation.class); + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + @Before - public void beforeTest() {} + public void beforeTest() { + 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()); + + schemaParameters = new SchemaParameters(); + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + } - /** - * Test context instantiation clear down. - */ @After - public void afterTest() {} + public void afterTest() { + ParameterService.deregister(schemaParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + } @Test public void testContextInstantiationJVMLocalVarSet() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextInstantiationJVMLocalVarSet test . . ."); - final ContextParameters contextParameters = new ContextParameters(); contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName()); new ContextInstantiation().testContextInstantiation(); @@ -64,10 +92,8 @@ public class TestContextInstantiation { public void testContextInstantiationJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextInstantiationJVMLocalVarNotSet test . . ."); - new ContextParameters(); new ContextInstantiation().testContextInstantiation(); logger.debug("Ran testContextInstantiationJVMLocalVarNotSet test"); } - } diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java index 1a9bc29f1..07a0cbe47 100644 --- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java +++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestContextUpdate.java @@ -22,11 +22,17 @@ package org.onap.policy.apex.context.test.distribution; import java.io.IOException; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor; +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.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; +import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -38,12 +44,45 @@ import org.slf4j.ext.XLoggerFactory; public class TestContextUpdate { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdate.class); + + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + + @Before + public void beforeTest() { + 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()); + + schemaParameters = new SchemaParameters(); + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(schemaParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + } @Test public void testContextUpdateJVMLocalVarSet() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextUpdateJVMLocalVarSet test . . ."); - final ContextParameters contextParameters = new ContextParameters(); contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName()); new ContextUpdate().testContextUpdate(); @@ -54,7 +93,6 @@ public class TestContextUpdate { public void testContextUpdateJVMLocalVarNotSet() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextUpdateJVMLocalVarNotSet test . . ."); - new ContextParameters(); new ContextUpdate().testContextUpdate(); logger.debug("Ran testContextUpdateJVMLocalVarNotSet test"); diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java index 6e7430756..b37c8eafa 100644 --- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java +++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/distribution/TestSequentialContextInstantiation.java @@ -25,9 +25,13 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor; +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.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; +import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -39,20 +43,48 @@ import org.slf4j.ext.XLoggerFactory; public class TestSequentialContextInstantiation { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestSequentialContextInstantiation.class); + + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; @Before - public void beforeTest() {} + public void beforeTest() { + 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()); + + schemaParameters = new SchemaParameters(); + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + } @After - public void afterTest() {} + public void afterTest() { + ParameterService.deregister(schemaParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + } @Test public void testSequentialContextInstantiationJVMLocalVarSet() throws ApexModelException, IOException, ApexException { logger.debug("Running testSequentialContextInstantiationJVMLocalVarSet test . . ."); - final ContextParameters contextParameters = new ContextParameters(); contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName()); + new SequentialContextInstantiation().testSequentialContextInstantiation(); logger.debug("Ran testSequentialContextInstantiationJVMLocalVarSet test"); diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java index 9d0210e38..8fca90b07 100644 --- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java +++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/locking/TestConcurrentContext.java @@ -28,14 +28,20 @@ import static org.onap.policy.apex.context.test.utils.Constants.TEST_VALUE; import java.util.Map; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor; import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager; +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.context.test.concepts.TestContextLongItem; import org.onap.policy.apex.context.test.utils.ConfigrationProvider; import org.onap.policy.apex.context.test.utils.ConfigrationProviderImpl; import org.onap.policy.apex.context.test.utils.Constants; +import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -57,11 +63,44 @@ public class TestConcurrentContext { private static final int TEST_THREAD_COUNT_MULTI_JVM = 20; private static final int TEST_THREAD_LOOPS = 100; + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; + + @Before + public void beforeTest() { + 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()); + + schemaParameters = new SchemaParameters(); + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + } + + @After + public void afterTest() { + ParameterService.deregister(schemaParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + } + @Test public void testConcurrentContextJVMLocalVarSet() throws Exception { logger.debug("Running testConcurrentContextJVMLocalVarSet test . . ."); - final ContextParameters contextParameters = new ContextParameters(); contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName()); final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalVarSet", @@ -84,7 +123,6 @@ public class TestConcurrentContext { public void testConcurrentContextJVMLocalNoVarSet() throws Exception { logger.debug("Running testConcurrentContextJVMLocalNoVarSet test . . ."); - new ContextParameters(); final ConfigrationProvider configrationProvider = getConfigrationProvider("JVMLocalNoVarSet", TEST_JVM_COUNT_SINGLE_JVM, TEST_THREAD_COUNT_SINGLE_JVM, TEST_THREAD_LOOPS); @@ -104,7 +142,6 @@ public class TestConcurrentContext { public void testConcurrentContextMultiJVMNoLock() throws Exception { logger.debug("Running testConcurrentContextMultiJVMNoLock test . . ."); - final ContextParameters contextParameters = new ContextParameters(); contextParameters.getDistributorParameters().setPluginClass(JVMLocalDistributor.class.getCanonicalName()); contextParameters.getLockManagerParameters().setPluginClass(JVMLocalLockManager.class.getCanonicalName()); diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java index 80f06ead7..d3a8ba163 100644 --- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java +++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java @@ -38,8 +38,10 @@ import org.junit.Test; import org.onap.policy.apex.context.ContextAlbum; import org.onap.policy.apex.context.Distributor; import org.onap.policy.apex.context.impl.distribution.DistributorFactory; +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.PersistorParameters; +import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.context.test.concepts.TestContextDateItem; import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem; import org.onap.policy.apex.context.test.concepts.TestContextLongItem; @@ -53,6 +55,7 @@ import org.onap.policy.apex.model.basicmodel.dao.DAOParameters; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum; import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel; +import org.onap.policy.common.parameters.ParameterService; /** * The Class TestContextInstantiation. @@ -65,6 +68,8 @@ public class TestPersistentContextInstantiation { // XLoggerFactory.getXLogger(TestPersistentContextInstantiation.class); private Connection connection; + private SchemaParameters schemaParameters; + private ContextParameters contextParameters; @Before public void setup() throws Exception { @@ -78,15 +83,40 @@ public class TestPersistentContextInstantiation { new File("derby.log").delete(); } + @Before + public void beforeTest() { + 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()); + + schemaParameters = new SchemaParameters(); + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters()); + + ParameterService.register(schemaParameters); + } + @After - public void afterTest() throws IOException {} + public void afterTest() { + ParameterService.deregister(schemaParameters); + + ParameterService.deregister(contextParameters.getDistributorParameters()); + ParameterService.deregister(contextParameters.getLockManagerParameters()); + ParameterService.deregister(contextParameters.getPersistorParameters()); + ParameterService.deregister(contextParameters); + } @Test public void testContextPersistentInstantiation() throws ApexModelException, IOException, ApexException { - final ContextParameters contextParameters = new ContextParameters(); - contextParameters.setPersistorParameters(new PersistorParameters()); - final AxArtifactKey distributorKey = new AxArtifactKey("AbstractDistributor", "0.0.1"); final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey); @@ -181,6 +211,5 @@ public class TestPersistentContextInstantiation { contextAlbumForLong.flush(); contextDistributor.clear(); - } } |