diff options
Diffstat (limited to 'services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java')
-rw-r--r-- | services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java | 162 |
1 files changed, 90 insertions, 72 deletions
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java index 37f15777b..bfda220a5 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java @@ -39,7 +39,8 @@ public class ContextParameterTests { @Test public void noParamsTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextNoParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextNoParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { @@ -47,14 +48,15 @@ public class ContextParameterTests { fail("This test should throw an exception"); } catch (final ParameterException e) { assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextNoParams.json\"\n" - + "(ParameterRuntimeException):could not find field \"parameterClassName\" in " - + "\"contextParameters\" entry", e.getMessage()); + + "(ParameterRuntimeException):could not find field \"parameterClassName\" in " + + "\"contextParameters\" entry", e.getMessage()); } } @Test public void badParamsTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextBadParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { @@ -62,15 +64,16 @@ public class ContextParameterTests { fail("This test should throw an exception"); } catch (final ParameterException e) { assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextBadParams.json\"" - + "\n(ParameterRuntimeException):failed to deserialize the parameters for " - + "\"contextParameters\" to parameter class \"hello\"\njava.lang.ClassNotFoundException: hello", - e.getMessage()); + + "\n(ParameterRuntimeException):failed to deserialize the parameters for " + + "\"contextParameters\" to parameter class \"hello\"\njava.lang.ClassNotFoundException: hello", + e.getMessage()); } } @Test public void badPluginParamNameTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadPluginNameParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextBadPluginNameParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { @@ -78,33 +81,34 @@ public class ContextParameterTests { fail("This test should throw an exception"); } catch (final ParameterException e) { assertEquals("error reading parameters from " - + "\"src/test/resources/parameters/serviceContextBadPluginNameParams.json\"\n" - + "(ParameterRuntimeException):could not find field \"parameterClassName\" in " - + "\"contextParameters\" entry", e.getMessage()); + + "\"src/test/resources/parameters/serviceContextBadPluginNameParams.json\"\n" + + "(ParameterRuntimeException):could not find field \"parameterClassName\" in " + + "\"contextParameters\" entry", e.getMessage()); } } @Test public void badClassParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadClassParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextBadClassParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { new ApexParameterHandler().getParameters(arguments); fail("This test should throw an exception"); } catch (final ParameterException e) { - assertEquals( - "error reading parameters from \"src/test/resources/parameters/serviceContextBadClassParams.json\"" - + "\n(ParameterRuntimeException):failed to deserialize the parameters for \"contextParameters\"" - + " to parameter class \"java.lang.Integer\"\ncom.google.gson.JsonSyntaxException: " - + "java.lang.IllegalStateException: Expected NUMBER but was BEGIN_OBJECT at path $", - e.getMessage()); + assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextBadClassParams.json\"" + + "\n(ParameterRuntimeException):failed to deserialize the parameters for \"contextParameters\"" + + " to parameter class \"java.lang.Integer\"\ncom.google.gson.JsonSyntaxException: " + + "java.lang.IllegalStateException: Expected NUMBER but was BEGIN_OBJECT at path $", + e.getMessage()); } } @Test public void badPluginClassTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadPluginClassParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextBadPluginClassParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { @@ -112,24 +116,27 @@ public class ContextParameterTests { fail("This test should throw an exception"); } catch (final ParameterException e) { assertEquals("error reading parameters from " - + "\"src/test/resources/parameters/serviceContextBadPluginClassParams.json\"" - + "\n(ClassCastException):org.onap.policy.apex.service.engine.parameters.dummyclasses." - + "SuperDooperExecutorParameters" - + " cannot be cast to org.onap.policy.apex.context.parameters.ContextParameters", e.getMessage()); + + "\"src/test/resources/parameters/serviceContextBadPluginClassParams.json\"" + + "\n(ClassCastException):org.onap.policy.apex.service.engine.parameters.dummyclasses." + + "SuperDooperExecutorParameters" + + " cannot be cast to org.onap.policy.apex.context.parameters.ContextParameters", + e.getMessage()); } } @Test public void okFlushParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextOKFlushParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextOKFlushParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getClass().getCanonicalName()); assertEquals(123456, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getFlushPeriod()); + .getPersistorParameters().getFlushPeriod()); } catch (final ParameterException e) { fail("This test should not throw any exception: " + e.getMessage()); } @@ -137,15 +144,17 @@ public class ContextParameterTests { @Test public void okDefaultParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextOKDefaultParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextOKDefaultParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getClass().getCanonicalName()); assertEquals(300000, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getFlushPeriod()); + .getPersistorParameters().getFlushPeriod()); } catch (final ParameterException e) { fail("This test should not throw any exception: " + e.getMessage()); } @@ -153,16 +162,18 @@ public class ContextParameterTests { @Test public void okDistParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextOKDistParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextOKDistParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getClass().getCanonicalName()); assertEquals("org.onap.policy.apex.context.parameters.DistributorParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getDistributorParameters().getClass().getCanonicalName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getDistributorParameters().getClass().getCanonicalName()); } catch (final ParameterException e) { fail("This test should not throw any exception: " + e.getMessage()); } @@ -170,24 +181,26 @@ public class ContextParameterTests { @Test public void okFullDefaultParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/goodParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getClass().getCanonicalName()); assertEquals("org.onap.policy.apex.context.parameters.DistributorParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getDistributorParameters().getClass().getCanonicalName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getDistributorParameters().getClass().getCanonicalName()); assertEquals("org.onap.policy.apex.context.parameters.LockManagerParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getLockManagerParameters().getClass().getCanonicalName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getLockManagerParameters().getClass().getCanonicalName()); assertEquals("org.onap.policy.apex.context.parameters.PersistorParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getClass().getCanonicalName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getPersistorParameters().getClass().getCanonicalName()); assertEquals(300000, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getFlushPeriod()); + .getPersistorParameters().getFlushPeriod()); } catch (final ParameterException e) { fail("This test should not throw any exception: " + e.getMessage()); } @@ -195,31 +208,33 @@ public class ContextParameterTests { @Test public void okFullParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextOKFullParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextOKFullParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getCanonicalName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getClass().getCanonicalName()); assertEquals("org.onap.policy.apex.context.parameters.LockManagerParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getLockManagerParameters().getClass().getCanonicalName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getLockManagerParameters().getClass().getCanonicalName()); assertEquals("org.onap.policy.apex.context.parameters.PersistorParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getClass().getCanonicalName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getPersistorParameters().getClass().getCanonicalName()); assertEquals(123456, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getFlushPeriod()); + .getPersistorParameters().getFlushPeriod()); - final SuperDooperDistributorParameters infinispanParameters = - (SuperDooperDistributorParameters) parameters.getEngineServiceParameters().getEngineParameters() - .getContextParameters().getDistributorParameters(); + final SuperDooperDistributorParameters infinispanParameters = (SuperDooperDistributorParameters) parameters + .getEngineServiceParameters().getEngineParameters().getContextParameters() + .getDistributorParameters(); assertEquals("org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperDistributorParameters", - infinispanParameters.getClass().getCanonicalName()); + infinispanParameters.getClass().getCanonicalName()); assertEquals("my/lovely/configFile.xml", infinispanParameters.getConfigFile()); assertEquals("holy/stone.xml", infinispanParameters.getJgroupsFile()); - assertEquals(false, infinispanParameters.preferIPv4Stack()); - assertEquals("fatherted", infinispanParameters.getjGroupsBindAddress()); + assertEquals(false, infinispanParameters.isPreferIPv4Stack()); + assertEquals("fatherted", infinispanParameters.getJgroupsBindAddress()); } catch (final ParameterException e) { fail("This test should not throw any exception: " + e.getMessage()); @@ -228,7 +243,8 @@ public class ContextParameterTests { @Test public void badClassDistParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadClassDistParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextBadClassDistParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { @@ -236,15 +252,16 @@ public class ContextParameterTests { fail("This test should throw an exception"); } catch (final ParameterException e) { assertEquals("error reading parameters from " - + "\"src/test/resources/parameters/serviceContextBadClassDistParams.json\"\n" - + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" - + " org.onap.policy.apex.context.parameters.DistributorParameters", e.getMessage()); + + "\"src/test/resources/parameters/serviceContextBadClassDistParams.json\"\n" + + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + + " org.onap.policy.apex.context.parameters.DistributorParameters", e.getMessage()); } } @Test public void badClassLockParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadClassLockParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextBadClassLockParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { @@ -252,15 +269,16 @@ public class ContextParameterTests { fail("This test should throw an exception"); } catch (final ParameterException e) { assertEquals("error reading parameters from " - + "\"src/test/resources/parameters/serviceContextBadClassLockParams.json\"\n" - + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" - + " org.onap.policy.apex.context.parameters.LockManagerParameters", e.getMessage()); + + "\"src/test/resources/parameters/serviceContextBadClassLockParams.json\"\n" + + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + + " org.onap.policy.apex.context.parameters.LockManagerParameters", e.getMessage()); } } @Test public void badClassPersistParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadClassPersistParams.json"}; + final String[] args = + { "-c", "src/test/resources/parameters/serviceContextBadClassPersistParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); try { @@ -268,9 +286,9 @@ public class ContextParameterTests { fail("This test should throw an exception"); } catch (final ParameterException e) { assertEquals("error reading parameters from " - + "\"src/test/resources/parameters/serviceContextBadClassPersistParams.json\"\n" - + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" - + " org.onap.policy.apex.context.parameters.PersistorParameters", e.getMessage()); + + "\"src/test/resources/parameters/serviceContextBadClassPersistParams.json\"\n" + + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + + " org.onap.policy.apex.context.parameters.PersistorParameters", e.getMessage()); } } } |