From 933cdbd4c20f18fe47f253bd721baf6ae996e906 Mon Sep 17 00:00:00 2001 From: vempo Date: Thu, 25 Oct 2018 19:27:22 +0300 Subject: Code formatting of configuration framework Fixed code formatting, removed meaningless Javadoc comments, added copyright headers, minor (and safe) static analysis fixes. Change-Id: I3eda1f242905da5b80e024cf30a69ff59381fc43 Issue-ID: SDC-1867 Signed-off-by: vempo --- .../org/onap/config/ConfigurationUtilsTest.java | 1 + .../src/test/java/org/onap/config/TestCMSuite.java | 38 +++---- .../onap/config/test/CLIFallbackAndLookupTest.java | 83 -------------- .../onap/config/test/CliFallbackAndLookupTest.java | 97 ++++++++++++++++ .../onap/config/test/ConfigSourceLocationTest.java | 35 ++++-- .../org/onap/config/test/FallbackConfigTest.java | 35 ++++-- .../onap/config/test/FallbackToGlobalNSTest.java | 42 ------- .../config/test/FallbackToGlobalNamespaceTest.java | 58 ++++++++++ .../onap/config/test/GlobalAndNSConfigTest.java | 43 -------- .../config/test/GlobalAndNamespaceConfigTest.java | 56 ++++++++++ .../onap/config/test/JAVAPropertiesConfigTest.java | 40 ------- .../java/org/onap/config/test/JSONConfigTest.java | 40 ------- .../onap/config/test/JavaPropertiesConfigTest.java | 53 +++++++++ .../java/org/onap/config/test/JsonConfigTest.java | 52 +++++++++ .../config/test/LoadOrderMergeAndOverrideTest.java | 34 ++++-- .../org/onap/config/test/ModeAsConfigPropTest.java | 122 +++++++++++---------- .../onap/config/test/MultiTenancyConfigTest.java | 34 ++++-- .../onap/config/test/ValidateDefaultModeTest.java | 44 +++++--- .../java/org/onap/config/test/XMLConfigTest.java | 40 ------- .../java/org/onap/config/test/XmlConfigTest.java | 52 +++++++++ .../java/org/onap/config/test/YAMLConfigTest.java | 40 ------- .../java/org/onap/config/test/YamlConfigTest.java | 51 +++++++++ .../org/onap/config/util/ConfigTestConstant.java | 56 +++++++--- .../test/java/org/onap/config/util/TestUtil.java | 54 ++++----- 24 files changed, 691 insertions(+), 509 deletions(-) delete mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/CLIFallbackAndLookupTest.java create mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/CliFallbackAndLookupTest.java delete mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackToGlobalNSTest.java create mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackToGlobalNamespaceTest.java delete mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/GlobalAndNSConfigTest.java create mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/GlobalAndNamespaceConfigTest.java delete mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JAVAPropertiesConfigTest.java delete mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JSONConfigTest.java create mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JavaPropertiesConfigTest.java create mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JsonConfigTest.java delete mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/XMLConfigTest.java create mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/XmlConfigTest.java delete mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/YAMLConfigTest.java create mode 100644 common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/YamlConfigTest.java (limited to 'common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config') diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/ConfigurationUtilsTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/ConfigurationUtilsTest.java index 71b2a01c71..94ac71d1f2 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/ConfigurationUtilsTest.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/ConfigurationUtilsTest.java @@ -25,6 +25,7 @@ import java.util.List; import org.junit.Test; public class ConfigurationUtilsTest { + @Test public void testCommaList() { List list = Arrays.asList("1", "2", 3); diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/TestCMSuite.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/TestCMSuite.java index 9360ce1673..6c460160d0 100755 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/TestCMSuite.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/TestCMSuite.java @@ -18,44 +18,32 @@ package org.onap.config; import org.junit.runner.RunWith; import org.junit.runners.Suite; -import org.onap.config.test.CLIFallbackAndLookupTest; +import org.onap.config.test.CliFallbackAndLookupTest; import org.onap.config.test.CliTest; import org.onap.config.test.ConfigSourceLocationTest; import org.onap.config.test.FallbackConfigTest; -import org.onap.config.test.FallbackToGlobalNSTest; -import org.onap.config.test.GlobalAndNSConfigTest; -import org.onap.config.test.JAVAPropertiesConfigTest; -import org.onap.config.test.JSONConfigTest; +import org.onap.config.test.FallbackToGlobalNamespaceTest; +import org.onap.config.test.GlobalAndNamespaceConfigTest; +import org.onap.config.test.JavaPropertiesConfigTest; +import org.onap.config.test.JsonConfigTest; import org.onap.config.test.LoadOrderMergeAndOverrideTest; import org.onap.config.test.ModeAsConfigPropTest; import org.onap.config.test.MultiTenancyConfigTest; import org.onap.config.test.NodeSpecificCliTest; import org.onap.config.test.ValidateDefaultModeTest; -import org.onap.config.test.XMLConfigTest; -import org.onap.config.test.YAMLConfigTest; +import org.onap.config.test.XmlConfigTest; +import org.onap.config.test.YamlConfigTest; /** * Created by sheetalm on 10/25/2016. */ - @RunWith(Suite.class) -@Suite.SuiteClasses({ - ConfigurationUtilsTest.class, - JAVAPropertiesConfigTest.class, - JSONConfigTest.class, - XMLConfigTest.class, - YAMLConfigTest.class, - CLIFallbackAndLookupTest.class, - CliTest.class, - ConfigSourceLocationTest.class, - FallbackConfigTest.class, - FallbackToGlobalNSTest.class, - GlobalAndNSConfigTest.class, - ModeAsConfigPropTest.class, - MultiTenancyConfigTest.class, - NodeSpecificCliTest.class, - ValidateDefaultModeTest.class, - LoadOrderMergeAndOverrideTest.class}) +@Suite.SuiteClasses( + {ConfigurationUtilsTest.class, JavaPropertiesConfigTest.class, JsonConfigTest.class, XmlConfigTest.class, + YamlConfigTest.class, CliFallbackAndLookupTest.class, CliTest.class, ConfigSourceLocationTest.class, + FallbackConfigTest.class, FallbackToGlobalNamespaceTest.class, GlobalAndNamespaceConfigTest.class, + ModeAsConfigPropTest.class, MultiTenancyConfigTest.class, NodeSpecificCliTest.class, + ValidateDefaultModeTest.class, LoadOrderMergeAndOverrideTest.class}) public class TestCMSuite extends junit.framework.TestSuite { private TestCMSuite() { diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/CLIFallbackAndLookupTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/CLIFallbackAndLookupTest.java deleted file mode 100644 index d5990c8dac..0000000000 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/CLIFallbackAndLookupTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.onap.config.test; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.onap.config.Constants; -import org.onap.config.api.ConfigurationManager; -import org.onap.config.util.ConfigTestConstant; -import org.onap.config.util.TestUtil; - -import javax.management.JMX; -import javax.management.MBeanServerConnection; -import javax.management.ObjectName; -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.util.HashMap; -import java.util.Map; - - - -/** - * Created by sheetalm on 10/18/2016. - * Scenario 21, Scenario 23 - * 21 - Verify the CLI fetches only the current value unless the fallback option is specified - * 23 - Fetch value using CLI for a key with underlying resource - */ -public class CLIFallbackAndLookupTest { - - public final static String NAMESPACE = "CLIFallback"; - public final static String TENANT = "OPENECOMP"; - - @Before - public void setUp() throws IOException { - String data = "{name:\"SCM\"}"; - TestUtil.writeFile(data); - } - - @Test - public void testCLIFallbackAndLookup() throws Exception{ - - //Verify without fallback - Map input = new HashMap<>(); - input.put("ImplClass", "org.onap.config.type.ConfigurationQuery"); - input.put("tenant", TENANT); - input.put("namespace", NAMESPACE); - input.put("key", ConfigTestConstant.ARTIFACT_MAXSIZE); - - MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer(); - ObjectName mbeanName = new ObjectName(Constants.MBEAN_NAME); - ConfigurationManager conf = JMX.newMBeanProxy(mbsc, mbeanName, ConfigurationManager.class, true); - String maxSizeWithNoFallback = conf.getConfigurationValue(input); - Assert.assertEquals("",maxSizeWithNoFallback); - - //Verify underlying resource without lookup switch - input.put("key", ConfigTestConstant.ARTIFACT_JSON_SCHEMA); - String jsonSchema = conf.getConfigurationValue(input); - System.out.println("jsonSchema=="+jsonSchema); - Assert.assertEquals("@"+System.getProperty("user.home")+"/TestResources/GeneratorsList.json" , jsonSchema); - - //Verify underlying resource with lookup switch - input.put("externalLookup", true); - jsonSchema = conf.getConfigurationValue(input); - System.out.println("jsonSchema=="+jsonSchema); - Assert.assertEquals("{name:\"SCM\"}" , jsonSchema); - - //Verify with fallback - Map fallbackInput = new HashMap<>(); - fallbackInput.put("ImplClass", "org.onap.config.type.ConfigurationQuery"); - fallbackInput.put("fallback", true); - fallbackInput.put("tenant", TENANT); - fallbackInput.put("namespace", NAMESPACE); - fallbackInput.put("key", ConfigTestConstant.ARTIFACT_MAXSIZE); - - String maxSizeWithFallback = conf.getConfigurationValue(fallbackInput); - Assert.assertEquals("1024",maxSizeWithFallback); - } - - @After - public void tearDown() throws Exception { - TestUtil.cleanUp(); - } -} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/CliFallbackAndLookupTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/CliFallbackAndLookupTest.java new file mode 100644 index 0000000000..48aecf4adc --- /dev/null +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/CliFallbackAndLookupTest.java @@ -0,0 +1,97 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + +package org.onap.config.test; + +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.util.HashMap; +import java.util.Map; +import javax.management.JMX; +import javax.management.MBeanServerConnection; +import javax.management.ObjectName; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.onap.config.Constants; +import org.onap.config.api.ConfigurationManager; +import org.onap.config.util.ConfigTestConstant; +import org.onap.config.util.TestUtil; + + +/** + * Created by sheetalm on 10/18/2016. + * Scenario 21, Scenario 23 + * 21 - Verify the CLI fetches only the current value unless the fallback option is specified + * 23 - Fetch value using CLI for a key with underlying resource + */ +public class CliFallbackAndLookupTest { + + private static final String NAMESPACE = "CLIFallback"; + private static final String TENANT = "OPENECOMP"; + + @Before + public void setUp() throws IOException { + String data = "{name:\"SCM\"}"; + TestUtil.writeFile(data); + } + + @Test + public void testCliFallbackAndLookup() throws Exception { + + //Verify without fallback + Map input = new HashMap<>(); + input.put("ImplClass", "org.onap.config.type.ConfigurationQuery"); + input.put("tenant", TENANT); + input.put("namespace", NAMESPACE); + input.put("key", ConfigTestConstant.ARTIFACT_MAXSIZE); + + MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer(); + ObjectName mbeanName = new ObjectName(Constants.MBEAN_NAME); + ConfigurationManager conf = JMX.newMBeanProxy(mbsc, mbeanName, ConfigurationManager.class, true); + String maxSizeWithNoFallback = conf.getConfigurationValue(input); + Assert.assertEquals("", maxSizeWithNoFallback); + + //Verify underlying resource without lookup switch + input.put("key", ConfigTestConstant.ARTIFACT_JSON_SCHEMA); + String jsonSchema = conf.getConfigurationValue(input); + System.out.println("jsonSchema==" + jsonSchema); + Assert.assertEquals("@" + System.getProperty("user.home") + "/TestResources/GeneratorsList.json", jsonSchema); + + //Verify underlying resource with lookup switch + input.put("externalLookup", true); + jsonSchema = conf.getConfigurationValue(input); + System.out.println("jsonSchema==" + jsonSchema); + Assert.assertEquals("{name:\"SCM\"}", jsonSchema); + + //Verify with fallback + Map fallbackInput = new HashMap<>(); + fallbackInput.put("ImplClass", "org.onap.config.type.ConfigurationQuery"); + fallbackInput.put("fallback", true); + fallbackInput.put("tenant", TENANT); + fallbackInput.put("namespace", NAMESPACE); + fallbackInput.put("key", ConfigTestConstant.ARTIFACT_MAXSIZE); + + String maxSizeWithFallback = conf.getConfigurationValue(fallbackInput); + Assert.assertEquals("1024", maxSizeWithFallback); + } + + @After + public void tearDown() throws Exception { + TestUtil.cleanUp(); + } +} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ConfigSourceLocationTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ConfigSourceLocationTest.java index c997e09f8e..f291f8e0b8 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ConfigSourceLocationTest.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ConfigSourceLocationTest.java @@ -1,5 +1,26 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.onap.config.test; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Properties; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -9,21 +30,15 @@ import org.onap.config.api.ConfigurationManager; import org.onap.config.util.ConfigTestConstant; import org.onap.config.util.TestUtil; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Properties; - /** * Created by sheetalm on 10/14/2016. * Scenario 11 - * Validate conventional and configurational source location - * + * Validate conventional and configurational source location. * Pre-requisite - set -Dconfig.location=${"user.home"}/TestResources/ while running test */ public class ConfigSourceLocationTest { - public final static String NAMESPACE = "SourceLocation"; + + private static final String NAMESPACE = "SourceLocation"; @Before public void setUp() throws IOException { @@ -40,7 +55,7 @@ public class ConfigSourceLocationTest { } @Test - public void testMergeStrategyInConfig() throws IOException, InterruptedException { + public void testMergeStrategyInConfig() { Configuration config = ConfigurationManager.lookup(); Assert.assertEquals("a-zA-Z_0-9", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER)); Assert.assertEquals("1024", config.getAsString(ConfigTestConstant.ARTIFACT_MAXSIZE)); diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackConfigTest.java index 17b4aee8b0..876aed098d 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackConfigTest.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackConfigTest.java @@ -1,22 +1,36 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.onap.config.test; +import static org.onap.config.util.TestUtil.validateConfiguration; +import static org.onap.config.util.TestUtil.writeFile; + +import java.io.IOException; import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.io.IOException; - -import static org.onap.config.util.TestUtil.validateConfiguraton; -import static org.onap.config.util.TestUtil.writeFile; - /** * Created by ARR on 10/14/2016. - * - * Validate configuration with properties,xml,json,yaml file format with mode + * Validate configuration with properties,xml,json,yaml file format with mode. */ public class FallbackConfigTest { - public static final String NAMESPACE = "fallback"; + private static final String NAMESPACE = "fallback"; @Before public void setUp() throws IOException { @@ -25,14 +39,13 @@ public class FallbackConfigTest { } @Test - public void testConfigurationWithFallbackFileFormat(){ - validateConfiguraton(NAMESPACE); + public void testConfigurationWithFallbackFileFormat() { + validateConfiguration(NAMESPACE); } @After public void tearDown() throws Exception { String data = "{name:\"SCM\"}"; writeFile(data); - //ConfigurationUtils.executeDDLSQL("truncate dox.configuration"); } } diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackToGlobalNSTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackToGlobalNSTest.java deleted file mode 100644 index b70247b040..0000000000 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackToGlobalNSTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.onap.config.test; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.onap.config.api.Configuration; -import org.onap.config.api.ConfigurationManager; -import org.onap.config.util.ConfigTestConstant; -import org.onap.config.util.TestUtil; - -import java.io.IOException; - -/** - * Scenario 12 - * Verify configuration value fallback to the global namespace if the configuraton property doesnot exist in the namespace configuration - * Created by sheetalm on 10/14/2016. - */ -public class FallbackToGlobalNSTest { - - public final static String NAMESPACE = "FallbackToGlobalNS"; - - @Before - public void setUp() throws IOException { - String data = "{name:\"SCM\"}"; - TestUtil.writeFile(data); - } - - @Test - public void testFallbackToGlobalNS() throws IOException, InterruptedException { - Configuration config = ConfigurationManager.lookup(); - Assert.assertEquals("14",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH)); - Assert.assertEquals("1024",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_MAXSIZE)); - } - - @After - public void tearDown() throws Exception { - TestUtil.cleanUp(); - } - - -} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackToGlobalNamespaceTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackToGlobalNamespaceTest.java new file mode 100644 index 0000000000..b398a700ff --- /dev/null +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/FallbackToGlobalNamespaceTest.java @@ -0,0 +1,58 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + +package org.onap.config.test; + +import java.io.IOException; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.onap.config.api.Configuration; +import org.onap.config.api.ConfigurationManager; +import org.onap.config.util.ConfigTestConstant; +import org.onap.config.util.TestUtil; + +/** + * Scenario 12 + * Verify configuration value fallback to the global namespace if the configuration property does + * not exist in the namespace configuration. + * Created by sheetalm on 10/14/2016. + */ +public class FallbackToGlobalNamespaceTest { + + private static final String NAMESPACE = "FallbackToGlobalNS"; + + @Before + public void setUp() throws IOException { + String data = "{name:\"SCM\"}"; + TestUtil.writeFile(data); + } + + @Test + public void testFallbackToGlobalNamespace() { + Configuration config = ConfigurationManager.lookup(); + Assert.assertEquals("14", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH)); + Assert.assertEquals("1024", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_MAXSIZE)); + } + + @After + public void tearDown() throws Exception { + TestUtil.cleanUp(); + } + + +} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/GlobalAndNSConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/GlobalAndNSConfigTest.java deleted file mode 100644 index e4a511064e..0000000000 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/GlobalAndNSConfigTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.onap.config.test; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.onap.config.api.Configuration; -import org.onap.config.api.ConfigurationManager; -import org.onap.config.util.ConfigTestConstant; -import org.onap.config.util.TestUtil; - -import java.io.IOException; - -/** - * Created by sheetalm on 10/13/2016. - * Scenario 10 Verify configuration present in both global and defined namespace - */ -public class GlobalAndNSConfigTest { - - public final static String NAMESPACE = "GlobalAndNSConfig"; - - @Before - public void setUp() throws IOException { - String data = "{name:\"SCM\"}"; - TestUtil.writeFile(data); - } - - @Test - public void testNamespaceInConfig() throws IOException, InterruptedException { - Configuration config = ConfigurationManager.lookup(); - Assert.assertEquals("a-zA-Z",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER )); - Assert.assertEquals("a-zA-Z_0-9",config.getAsString(ConfigTestConstant.ARTIFACT_NAME_UPPER )); - } - - @After - public void tearDown() throws Exception { - TestUtil.cleanUp(); - } - - - - -} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/GlobalAndNamespaceConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/GlobalAndNamespaceConfigTest.java new file mode 100644 index 0000000000..d66165c762 --- /dev/null +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/GlobalAndNamespaceConfigTest.java @@ -0,0 +1,56 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + +package org.onap.config.test; + +import java.io.IOException; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.onap.config.api.Configuration; +import org.onap.config.api.ConfigurationManager; +import org.onap.config.util.ConfigTestConstant; +import org.onap.config.util.TestUtil; + +/** + * Created by sheetalm on 10/13/2016. + * Scenario 10 Verify configuration present in both global and defined namespace + */ +public class GlobalAndNamespaceConfigTest { + + private static final String NAMESPACE = "GlobalAndNSConfig"; + + @Before + public void setUp() throws IOException { + String data = "{name:\"SCM\"}"; + TestUtil.writeFile(data); + } + + @Test + public void testNamespaceInConfig() { + Configuration config = ConfigurationManager.lookup(); + Assert.assertEquals("a-zA-Z", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER)); + Assert.assertEquals("a-zA-Z_0-9", config.getAsString(ConfigTestConstant.ARTIFACT_NAME_UPPER)); + } + + @After + public void tearDown() throws Exception { + TestUtil.cleanUp(); + } + + +} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JAVAPropertiesConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JAVAPropertiesConfigTest.java deleted file mode 100644 index 994bd7260b..0000000000 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JAVAPropertiesConfigTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.onap.config.test; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.config.util.TestUtil; - -import java.io.IOException; - -import static org.onap.config.util.TestUtil.validateConfiguraton; -import static org.onap.config.util.TestUtil.writeFile; - -/** - * Created by ARR on 10/13/2016. - * - * Scenario 1 - * Validate configuration with Java Properties file format with mode - */ -public class JAVAPropertiesConfigTest { - - public static final String NAMESPACE = "javaProperties"; - - @Before - public void setUp() throws IOException { - String data = "{name:\"SCM\"}"; - writeFile(data); - } - - @Test - public void testConfigurationWithPropertiesFileFormat(){ - validateConfiguraton(NAMESPACE); - } - - - - @After - public void tearDown() throws Exception { - TestUtil.cleanUp(); - } -} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JSONConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JSONConfigTest.java deleted file mode 100644 index bf6ea5c243..0000000000 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JSONConfigTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.onap.config.test; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.config.util.TestUtil; - -import java.io.IOException; - -import static org.onap.config.util.TestUtil.validateConfiguraton; -import static org.onap.config.util.TestUtil.writeFile; - -/** - * Created by ARR on 10/14/2016. - * - * Scenario 3 - * Validate configuration with JSON file format with mode - */ -public class JSONConfigTest { - - public static final String NAMESPACE = "JSONConfig"; - - @Before - public void setUp() throws IOException { - String data = "{name:\"SCM\"}"; - writeFile(data); - } - - @Test - public void testConfigurationWithJSONFileFormat(){ - validateConfiguraton(NAMESPACE); - } - - - - @After - public void tearDown() throws Exception { - TestUtil.cleanUp(); - } -} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JavaPropertiesConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JavaPropertiesConfigTest.java new file mode 100644 index 0000000000..0c82fe4219 --- /dev/null +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JavaPropertiesConfigTest.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + +package org.onap.config.test; + +import static org.onap.config.util.TestUtil.validateConfiguration; +import static org.onap.config.util.TestUtil.writeFile; + +import java.io.IOException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.config.util.TestUtil; + +/** + * Created by ARR on 10/13/2016. + * Scenario 1 + * Validate configuration with Java Properties file format with mode + */ +public class JavaPropertiesConfigTest { + + private static final String NAMESPACE = "javaProperties"; + + @Before + public void setUp() throws IOException { + String data = "{name:\"SCM\"}"; + writeFile(data); + } + + @Test + public void testConfigurationWithPropertiesFileFormat() { + validateConfiguration(NAMESPACE); + } + + + @After + public void tearDown() throws Exception { + TestUtil.cleanUp(); + } +} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JsonConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JsonConfigTest.java new file mode 100644 index 0000000000..cd3eb6a06f --- /dev/null +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/JsonConfigTest.java @@ -0,0 +1,52 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + +package org.onap.config.test; + +import static org.onap.config.util.TestUtil.validateConfiguration; +import static org.onap.config.util.TestUtil.writeFile; + +import java.io.IOException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.config.util.TestUtil; + +/** + * Created by ARR on 10/14/2016. + * Scenario 3 Validate configuration with JSON file format with mode. + */ +public class JsonConfigTest { + + private static final String NAMESPACE = "JSONConfig"; + + @Before + public void setUp() throws IOException { + String data = "{name:\"SCM\"}"; + writeFile(data); + } + + @Test + public void testConfigurationWithJsonFileFormat() { + validateConfiguration(NAMESPACE); + } + + + @After + public void tearDown() throws Exception { + TestUtil.cleanUp(); + } +} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/LoadOrderMergeAndOverrideTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/LoadOrderMergeAndOverrideTest.java index d179edfcfb..6d189a0d30 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/LoadOrderMergeAndOverrideTest.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/LoadOrderMergeAndOverrideTest.java @@ -1,5 +1,24 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.onap.config.test; +import static org.onap.config.util.TestUtil.writeFile; + +import java.io.IOException; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -9,18 +28,14 @@ import org.onap.config.api.ConfigurationManager; import org.onap.config.util.ConfigTestConstant; import org.onap.config.util.TestUtil; -import java.io.IOException; - -import static org.onap.config.util.TestUtil.writeFile; - /** * Scenario - * Check loadorder for merge and overide. Higher loadorder takes precedence for override - * LoWer loadorder takes precedence for merge. + * Check load order for merge and override. Higher load order takes precedence for override + * Lower load order takes precedence for merge. */ public class LoadOrderMergeAndOverrideTest { - public static final String NAMESPACE = "LoadOrderConfiguration"; + private static final String NAMESPACE = "LoadOrderConfiguration"; @Before public void setUp() throws IOException { @@ -29,16 +44,15 @@ public class LoadOrderMergeAndOverrideTest { } @Test - public void testConfigurationWithPropertiesFileFormat(){ + public void testConfigurationWithPropertiesFileFormat() { Configuration config = ConfigurationManager.lookup(); - Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH ), "14"); + Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH), "14"); Assert.assertEquals("5", config.getAsString(NAMESPACE, "artifact.length")); Assert.assertEquals("56", config.getAsString(NAMESPACE, "artifact.size")); } - @After public void tearDown() throws Exception { TestUtil.cleanUp(); diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ModeAsConfigPropTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ModeAsConfigPropTest.java index e8fe363dfd..57f632a8e4 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ModeAsConfigPropTest.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ModeAsConfigPropTest.java @@ -1,5 +1,24 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.onap.config.test; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -9,79 +28,72 @@ import org.onap.config.api.ConfigurationManager; import org.onap.config.util.ConfigTestConstant; import org.onap.config.util.TestUtil; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - /** - * Scenario 8 - * Validate configuration with mode specified as a configuration property + * Scenario 8 Validate configuration with mode specified as a configuration property. */ - public class ModeAsConfigPropTest { - String newValue = null; - - public final static String NAMESPACE = "ModeAsConfigProp"; - - @Before - public void setUp() throws IOException { - String data = "{name:\"SCM\"}"; - TestUtil.writeFile(data); - } + private static final String NAMESPACE = "ModeAsConfigProp"; + + @Before + public void setUp() throws IOException { + String data = "{name:\"SCM\"}"; + TestUtil.writeFile(data); + } - @Test - public void testMergeStrategyInConfig() throws IOException, InterruptedException { - Configuration config = ConfigurationManager.lookup(); + @Test + public void testMergeStrategyInConfig() { + Configuration config = ConfigurationManager.lookup(); - Assert.assertEquals("14",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH)); + Assert.assertEquals("14", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH)); - Assert.assertEquals("1048",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_MAXSIZE)); + Assert.assertEquals("1048", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_MAXSIZE)); - List expectedExtList = new ArrayList(); - expectedExtList.add("pdf"); - expectedExtList.add("zip"); - expectedExtList.add("xml"); - expectedExtList.add("pdf"); - expectedExtList.add("tgz"); - expectedExtList.add("xls"); - List extList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_EXT); - Assert.assertEquals(expectedExtList, extList); + List expectedExtList = new ArrayList<>(); + expectedExtList.add("pdf"); + expectedExtList.add("zip"); + expectedExtList.add("xml"); + expectedExtList.add("pdf"); + expectedExtList.add("tgz"); + expectedExtList.add("xls"); + List extList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_EXT); + Assert.assertEquals(expectedExtList, extList); - List expectedEncList = new ArrayList(); - expectedEncList.add("Base64"); - expectedEncList.add("MD5"); - List encList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_ENC); - Assert.assertEquals(expectedEncList, encList); + List expectedEncList = new ArrayList<>(); + expectedEncList.add("Base64"); + expectedEncList.add("MD5"); + List encList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_ENC); + Assert.assertEquals(expectedEncList, encList); - String newValue = config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_JSON_SCHEMA); - Assert.assertEquals("{name:\"SCM\"}",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_JSON_SCHEMA)); + Assert.assertEquals("{name:\"SCM\"}", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_JSON_SCHEMA)); - Assert.assertEquals("a-zA-Z_0-9",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER )); + Assert.assertEquals("a-zA-Z_0-9", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER)); - Assert.assertEquals("Deleted",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_STATUS) ); + Assert.assertEquals("Deleted", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_STATUS)); - List expectedLocList = new ArrayList(); - expectedLocList.add("/opt/spool"); - expectedLocList.add(System.getProperty("user.home")+"/asdc"); - List locList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_LOC); - Assert.assertEquals(expectedLocList, locList); + List expectedLocList = new ArrayList<>(); + expectedLocList.add("/opt/spool"); + expectedLocList.add(System.getProperty("user.home") + "/asdc"); + List locList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_LOC); + Assert.assertEquals(expectedLocList, locList); - Assert.assertEquals("@"+TestUtil.getenv(ConfigTestConstant.PATH)+"/myschema.json",config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_XML_SCHEMA)); + Assert.assertEquals("@" + TestUtil.getenv(ConfigTestConstant.PATH) + "/myschema.json", + config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_XML_SCHEMA)); - List artifactConsumer = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER ); - Assert.assertEquals(config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER_APPC ), artifactConsumer); + List artifactConsumer = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER); + Assert.assertEquals(config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER_APPC), + artifactConsumer); - Assert.assertEquals(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_MANDATORY_NAME ), true); + Assert.assertEquals(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_MANDATORY_NAME), true); - Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH ), "6"); + Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH), "6"); - Assert.assertEquals(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_ENCODED ), true); - } + Assert.assertEquals(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_ENCODED), true); + } - @After - public void tearDown() throws Exception { - TestUtil.cleanUp(); - } + @After + public void tearDown() throws Exception { + TestUtil.cleanUp(); + } } diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/MultiTenancyConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/MultiTenancyConfigTest.java index 5765c4de2f..03c63569fb 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/MultiTenancyConfigTest.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/MultiTenancyConfigTest.java @@ -1,5 +1,22 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.onap.config.test; +import java.io.IOException; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -9,17 +26,13 @@ import org.onap.config.api.ConfigurationManager; import org.onap.config.util.ConfigTestConstant; import org.onap.config.util.TestUtil; -import java.io.IOException; - /** * Created by ARR on 10/14/2016. - * - * Scenario 17 - * Verify Configuration management System - Support for Multi-Tenancy + * Scenario 17 - Verify Configuration management System - Support for Multi-Tenancy. */ public class MultiTenancyConfigTest { - public static final String NAMESPACE = "tenancy"; + private static final String NAMESPACE = "tenancy"; @Before public void setUp() throws IOException { @@ -28,14 +41,15 @@ public class MultiTenancyConfigTest { } @Test - public void testConfigurationWithMultiTenancyFileFormat(){ + public void testConfigurationWithMultiTenancyFileFormat() { Configuration config = ConfigurationManager.lookup(); - Assert.assertEquals(config.getAsString("OPENECOMP",NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH ), "20"); + Assert.assertEquals(config.getAsString("OPENECOMP", NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH), + "20"); - Assert.assertEquals(config.getAsString("Telefonica",NAMESPACE, ConfigTestConstant.ARTIFACT_STATUS ), "Deleted"); + Assert.assertEquals(config.getAsString("Telefonica", NAMESPACE, ConfigTestConstant.ARTIFACT_STATUS), "Deleted"); - Assert.assertEquals(config.getAsString("TID",NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH ), "14"); + Assert.assertEquals(config.getAsString("TID", NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH), "14"); } diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ValidateDefaultModeTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ValidateDefaultModeTest.java index 3711322056..d53bf27100 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ValidateDefaultModeTest.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/ValidateDefaultModeTest.java @@ -1,5 +1,26 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.onap.config.test; +import static org.onap.config.util.TestUtil.writeFile; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -8,21 +29,13 @@ import org.onap.config.api.Configuration; import org.onap.config.api.ConfigurationManager; import org.onap.config.util.ConfigTestConstant; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import static org.onap.config.util.TestUtil.writeFile; - /** * Created by ARR on 10/17/2016. - * - * Scenario 22 - * Validate the default mode if the mode is not set + * Scenario 22 - Validate the default mode if the mode is not set */ public class ValidateDefaultModeTest { - public static final String NAMESPACE = "defaultmode"; + private static final String NAMESPACE = "defaultmode"; @Before public void setUp() throws IOException { @@ -31,21 +44,21 @@ public class ValidateDefaultModeTest { } @Test - public void testConfigurationWithValidateDefaultMode(){ + public void testConfigurationWithValidateDefaultMode() { Configuration config = ConfigurationManager.lookup(); - Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH ), "14"); + Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH), "14"); - Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_MAXSIZE ), "1048"); + Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_MAXSIZE), "1048"); - List expectedExtList = new ArrayList(); + List expectedExtList = new ArrayList<>(); expectedExtList.add("pdf"); expectedExtList.add("tgz"); expectedExtList.add("xls"); List extList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_EXT); Assert.assertEquals(expectedExtList, extList); - Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH ), "6"); + Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH), "6"); } @@ -53,6 +66,5 @@ public class ValidateDefaultModeTest { public void tearDown() throws Exception { String data = "{name:\"SCM\"}"; writeFile(data); - // ConfigurationUtils.executeDDLSQL("truncate dox.configuration"); } } diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/XMLConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/XMLConfigTest.java deleted file mode 100644 index 22832d378c..0000000000 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/XMLConfigTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.onap.config.test; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.config.util.TestUtil; - -import java.io.IOException; - -import static org.onap.config.util.TestUtil.validateConfiguraton; -import static org.onap.config.util.TestUtil.writeFile; - -/** - * Created by ARR on 10/14/2016. - * - * Scenario 2 - * Validate configuration with XML file format with mode - */ -public class XMLConfigTest { - - public static final String NAMESPACE = "XMLConfig"; - - @Before - public void setUp() throws IOException { - String data = "{name:\"SCM\"}"; - writeFile(data); - } - - @Test - public void testConfigurationWithXMLFileFormat(){ - validateConfiguraton(NAMESPACE); - } - - - - @After - public void tearDown() throws Exception { - TestUtil.cleanUp(); - } -} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/XmlConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/XmlConfigTest.java new file mode 100644 index 0000000000..79a917d1d1 --- /dev/null +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/XmlConfigTest.java @@ -0,0 +1,52 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + +package org.onap.config.test; + +import static org.onap.config.util.TestUtil.validateConfiguration; +import static org.onap.config.util.TestUtil.writeFile; + +import java.io.IOException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.config.util.TestUtil; + +/** + * Created by ARR on 10/14/2016. + * Scenario 2 - Validate configuration with XML file format with mode + */ +public class XmlConfigTest { + + private static final String NAMESPACE = "XMLConfig"; + + @Before + public void setUp() throws IOException { + String data = "{name:\"SCM\"}"; + writeFile(data); + } + + @Test + public void testConfigurationWithXmlFileFormat() { + validateConfiguration(NAMESPACE); + } + + + @After + public void tearDown() throws Exception { + TestUtil.cleanUp(); + } +} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/YAMLConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/YAMLConfigTest.java deleted file mode 100644 index f0e7ec54f7..0000000000 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/YAMLConfigTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.onap.config.test; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.config.util.TestUtil; - -import java.io.IOException; - -import static org.onap.config.util.TestUtil.validateConfiguraton; -import static org.onap.config.util.TestUtil.writeFile; - -/** - * Created by ARR on 10/14/2016. - * - * Scenario 4 - * Validate configuration with YAML file format with mode - */ -public class YAMLConfigTest { - - public static final String NAMESPACE = "YAMLConfig"; - - @Before - public void setUp() throws IOException { - String data = "{name:\"SCM\"}"; - writeFile(data); - } - - @Test - public void testConfigurationWithYAMLFileFormat(){ - validateConfiguraton(NAMESPACE); - } - - - - @After - public void tearDown() throws Exception { - TestUtil.cleanUp(); - } -} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/YamlConfigTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/YamlConfigTest.java new file mode 100644 index 0000000000..b2954f1e49 --- /dev/null +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/test/YamlConfigTest.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + +package org.onap.config.test; + +import static org.onap.config.util.TestUtil.validateConfiguration; +import static org.onap.config.util.TestUtil.writeFile; + +import java.io.IOException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.config.util.TestUtil; + +/** + * Created by ARR on 10/14/2016. + * Scenario 4 - Validate configuration with YAML file format with mode + */ +public class YamlConfigTest { + + private static final String NAMESPACE = "YAMLConfig"; + + @Before + public void setUp() throws IOException { + String data = "{name:\"SCM\"}"; + writeFile(data); + } + + @Test + public void testConfigurationWithYamlFileFormat() { + validateConfiguration(NAMESPACE); + } + + @After + public void tearDown() throws Exception { + TestUtil.cleanUp(); + } +} diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/util/ConfigTestConstant.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/util/ConfigTestConstant.java index 828c92ea73..434c7d3fbd 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/util/ConfigTestConstant.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/util/ConfigTestConstant.java @@ -1,24 +1,44 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.onap.config.util; public class ConfigTestConstant { - - public static final String ARTIFACT_NAME_MAXLENGTH = "artifact.name.maxlength"; - public static final String ARTIFACT_MAXSIZE = "artifact.maxsize"; - public static final String ARTIFACT_EXT = "artifact.extension"; - public static final String ARTIFACT_ENC = "artifact.supportedEncryption"; - public static final String ARTIFACT_NAME_UPPER = "artifact.name.allowedChar"; - public static final String ARTIFACT_NAME_LOWER = "artifact.name.allowedchar"; - public static final String ARTIFACT_STATUS = "artifact.status"; - public static final String ARTIFACT_LOC = "artifact.persistLocation"; - public static final String ARTIFACT_JSON_SCHEMA = "artifact.jsonSchema"; - public static final String ARTIFACT_XML_SCHEMA = "artifact.xmlSchema"; - public static final String ARTIFACT_CONSUMER_APPC = "artifact.consumerAPPC"; - public static final String ARTIFACT_CONSUMER = "artifact.consumer"; - public static final String ARTIFACT_MANDATORY_NAME = "artifact.mandatory.name"; - public static final String ARTIFACT_NAME_MINLENGTH = "artifact.name.minlength"; - public static final String ARTIFACT_ENCODED = "artifact.encoded"; - public static final String PATH = "PATH"; - public static final String ONBOARDING_NAMESPACE = "onboarding"; + public static final String ARTIFACT_NAME_MAXLENGTH = "artifact.name.maxlength"; + public static final String ARTIFACT_MAXSIZE = "artifact.maxsize"; + public static final String ARTIFACT_EXT = "artifact.extension"; + public static final String ARTIFACT_ENC = "artifact.supportedEncryption"; + public static final String ARTIFACT_NAME_UPPER = "artifact.name.allowedChar"; + public static final String ARTIFACT_NAME_LOWER = "artifact.name.allowedchar"; + public static final String ARTIFACT_STATUS = "artifact.status"; + public static final String ARTIFACT_LOC = "artifact.persistLocation"; + public static final String ARTIFACT_JSON_SCHEMA = "artifact.jsonSchema"; + public static final String ARTIFACT_XML_SCHEMA = "artifact.xmlSchema"; + public static final String ARTIFACT_CONSUMER_APPC = "artifact.consumerAPPC"; + public static final String ARTIFACT_CONSUMER = "artifact.consumer"; + public static final String ARTIFACT_MANDATORY_NAME = "artifact.mandatory.name"; + public static final String ARTIFACT_NAME_MINLENGTH = "artifact.name.minlength"; + public static final String ARTIFACT_ENCODED = "artifact.encoded"; + + public static final String PATH = "PATH"; + public static final String ONBOARDING_NAMESPACE = "onboarding"; + + private ConfigTestConstant() { + // prevent instantiation + } } diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/util/TestUtil.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/util/TestUtil.java index 514f52899a..87ff4ba394 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/util/TestUtil.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/util/TestUtil.java @@ -30,33 +30,32 @@ import org.onap.config.api.ConfigurationManager; */ public class TestUtil { - public final static String jsonSchemaLoc = System.getProperty("user.home")+"/TestResources/"; - public static FileWriter fileWriter ; + public static final String jsonSchemaLoc = System.getProperty("user.home") + "/TestResources/"; + + public static void cleanUp() throws Exception { + String data = "{name:\"SCM\"}"; + TestUtil.writeFile(data); + } public static void writeFile(String data) throws IOException { File dir = new File(jsonSchemaLoc); dir.mkdirs(); - File file = new File(jsonSchemaLoc+"/GeneratorsList.json"); + File file = new File(jsonSchemaLoc + "/GeneratorsList.json"); file.createNewFile(); - fileWriter = new FileWriter(file); + FileWriter fileWriter = new FileWriter(file); fileWriter.write(data); fileWriter.close(); } - public static void cleanUp() throws Exception { - String data = "{name:\"SCM\"}"; - TestUtil.writeFile(data); - } - - public static void validateConfiguraton(String nameSpace) { + public static void validateConfiguration(String nameSpace) { Configuration config = ConfigurationManager.lookup(); - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH ), "14"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH), "14"); // First value from list is picked from Merge properties - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_MAXSIZE ), "1048576"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_MAXSIZE), "1048576"); - List expectedExtList = new ArrayList(); + List expectedExtList = new ArrayList<>(); expectedExtList.add("pdf"); expectedExtList.add("zip"); expectedExtList.add("xml"); @@ -66,32 +65,35 @@ public class TestUtil { List extList = config.getAsStringValues(nameSpace, ConfigTestConstant.ARTIFACT_EXT); Assert.assertEquals(expectedExtList, extList); - List expectedEncList = new ArrayList(); + List expectedEncList = new ArrayList<>(); expectedEncList.add("Base64"); expectedEncList.add("MD5"); List encList = config.getAsStringValues(nameSpace, ConfigTestConstant.ARTIFACT_ENC); Assert.assertEquals(expectedEncList, encList); - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_NAME_UPPER ), "a-zA-Z_0-9"); - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_NAME_LOWER ), "a-zA-Z"); - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_STATUS ), "deleted"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_NAME_UPPER), "a-zA-Z_0-9"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_NAME_LOWER), "a-zA-Z"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_STATUS), "deleted"); - List expectedLocList = new ArrayList(); + List expectedLocList = new ArrayList<>(); expectedLocList.add("/opt/spool"); - expectedLocList.add(System.getProperty("user.home")+"/asdc"); + expectedLocList.add(System.getProperty("user.home") + "/asdc"); List locList = config.getAsStringValues(nameSpace, ConfigTestConstant.ARTIFACT_LOC); Assert.assertEquals(expectedLocList, locList); - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_JSON_SCHEMA ), "@GeneratorList.json"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_JSON_SCHEMA), + "@GeneratorList.json"); - Assert.assertEquals("@"+getenv(ConfigTestConstant.PATH)+"/myschema.json",config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_XML_SCHEMA)); + Assert.assertEquals("@" + getenv(ConfigTestConstant.PATH) + "/myschema.json", + config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_XML_SCHEMA)); - List artifactConsumer = config.getAsStringValues(nameSpace, ConfigTestConstant.ARTIFACT_CONSUMER ); - Assert.assertEquals(config.getAsStringValues(nameSpace, ConfigTestConstant.ARTIFACT_CONSUMER_APPC ), artifactConsumer); + List artifactConsumer = config.getAsStringValues(nameSpace, ConfigTestConstant.ARTIFACT_CONSUMER); + Assert.assertEquals(config.getAsStringValues(nameSpace, ConfigTestConstant.ARTIFACT_CONSUMER_APPC), + artifactConsumer); - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH ), "6"); - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_MANDATORY_NAME ), "true"); - Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_ENCODED ), "true"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH), "6"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_MANDATORY_NAME), "true"); + Assert.assertEquals(config.getAsString(nameSpace, ConfigTestConstant.ARTIFACT_ENCODED), "true"); } /** -- cgit 1.2.3-korg