Fix broken clm job 29/143629/2 master
authorFiete Ostkamp <fiete.ostkamp@telekom.de>
Thu, 19 Mar 2026 07:36:40 +0000 (08:36 +0100)
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Thu, 19 Mar 2026 11:47:53 +0000 (11:47 +0000)
- make sure ConfigurationRepositoryTest uses it's own temporary
  file to read and write config to
- this makes this test independent of other tests that were previously
  modifying the same file on disk

Issue-ID: SDC-4810
Change-Id: I96069806af3b4d17b0a9c37615f50ca4103d91ee
Signed-off-by: Fiete Ostkamp <fiete.ostkamp@telekom.de>
common/onap-common-configuration-management/onap-configuration-management-core/src/test/java/org/onap/config/impl/ConfigurationRepositoryTest.java

index a045ecd..1939883 100644 (file)
@@ -30,7 +30,9 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.nio.file.Paths;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Comparator;
 import java.util.Properties;
 import java.util.Set;
 
@@ -42,23 +44,24 @@ 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 static Path tempDir;
+    private static String testConfigFile;
 
     private ConfigurationRepository repository;
 
     @BeforeClass
     public static void setUp() throws Exception {
+        tempDir = Files.createTempDirectory("config-repo-test");
+        testConfigFile = tempDir.resolve("config.properties").toString();
         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);
+        File f = new File(testConfigFile);
         try (OutputStream out = new FileOutputStream(f)) {
             props.store(out, "Config Property at Conventional Resource");
         }
@@ -66,7 +69,12 @@ public class ConfigurationRepositoryTest {
 
     @AfterClass
     public static void tearDown() throws IOException {
-        TestUtil.deleteTestDirsStrucuture(Paths.get(TestUtil.jsonSchemaLoc));
+        if (tempDir != null) {
+            Files.walk(tempDir)
+                .sorted(Comparator.reverseOrder())
+                .map(Path::toFile)
+                .forEach(File::delete);
+        }
     }
 
     @Before
@@ -119,7 +127,7 @@ public class ConfigurationRepositoryTest {
 
         // when
         repository.populateOverrideConfiguration(Constants.DEFAULT_TENANT + Constants.KEY_ELEMENTS_DELIMITER
-                + TEST_NAME_SPACE, new File(TEST_CONFIG_FILE));
+                + TEST_NAME_SPACE, new File(testConfigFile));
         final Configuration outputConfig = repository.getConfigurationFor(Constants.DEFAULT_TENANT, TEST_NAME_SPACE);
 
         // then