summaryrefslogtreecommitdiffstats
path: root/common/onap-common-configuration-management
diff options
context:
space:
mode:
Diffstat (limited to 'common/onap-common-configuration-management')
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/impl/ConfigurationRepositoryTest.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/impl/ConfigurationRepositoryTest.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/impl/ConfigurationRepositoryTest.java
index d604d1e757..a045ecdff3 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/impl/ConfigurationRepositoryTest.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/impl/ConfigurationRepositoryTest.java
@@ -22,24 +22,53 @@
package org.onap.config.impl;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Paths;
+import java.util.Properties;
import java.util.Set;
import org.apache.commons.configuration2.BaseConfiguration;
import org.apache.commons.configuration2.Configuration;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.config.Constants;
+import org.onap.config.util.ConfigTestConstant;
+import org.onap.config.util.TestUtil;
public class ConfigurationRepositoryTest {
private static final String[] EMPTY_ARRAY_OF_STRING = new String[0];
private static final String TEST_NAME_SPACE = "testNameSpace";
+ private static final String TEST_CONFIG_FILE = TestUtil.jsonSchemaLoc + "config.properties";
private ConfigurationRepository repository;
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties props = new Properties();
+ props.setProperty(ConfigTestConstant.ARTIFACT_MAXSIZE, "10240");
+ File dir = new File(TestUtil.jsonSchemaLoc);
+ dir.mkdirs();
+ File f = new File(TEST_CONFIG_FILE);
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Config Property at Conventional Resource");
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws IOException {
+ TestUtil.deleteTestDirsStrucuture(Paths.get(TestUtil.jsonSchemaLoc));
+ }
+
@Before
public void init() {
repository = ConfigurationRepository.lookup();
@@ -80,4 +109,23 @@ public class ConfigurationRepositoryTest {
// then
assertEquals(inputConfig, outputConfig);
}
+
+ @Test
+ public void testPopulateOverrideConfiguration() throws Exception {
+ // given
+ BaseConfiguration inputConfig = new BaseConfiguration();
+ repository.populateConfiguration(Constants.DEFAULT_TENANT + Constants.KEY_ELEMENTS_DELIMITER
+ + TEST_NAME_SPACE, inputConfig);
+
+ // when
+ repository.populateOverrideConfiguration(Constants.DEFAULT_TENANT + Constants.KEY_ELEMENTS_DELIMITER
+ + TEST_NAME_SPACE, new File(TEST_CONFIG_FILE));
+ final Configuration outputConfig = repository.getConfigurationFor(Constants.DEFAULT_TENANT, TEST_NAME_SPACE);
+
+ // then
+ assertNotEquals(inputConfig, outputConfig);
+ assertEquals(0, inputConfig.size());
+ assertEquals(1, outputConfig.size());
+ assertEquals("10240", outputConfig.getString(ConfigTestConstant.ARTIFACT_MAXSIZE));
+ }
}