diff --git a/config-test/src/main/java/com/powsybl/config/test/TestPlatformConfigProvider.java b/config-test/src/main/java/com/powsybl/config/test/TestPlatformConfigProvider.java index 91e9f860a0c..08abd246cf1 100644 --- a/config-test/src/main/java/com/powsybl/config/test/TestPlatformConfigProvider.java +++ b/config-test/src/main/java/com/powsybl/config/test/TestPlatformConfigProvider.java @@ -74,6 +74,7 @@ public PlatformConfig getPlatformConfig() { // The resources have relative paths (no leading slash) with full package path. Path dest = cfgDir.resolve(resource); LOGGER.info("Copying classpath resource: {} -> {}", resource, dest); + Files.createDirectories(dest.getParent()); Files.copy(TestPlatformConfigProvider.class.getResourceAsStream(resource), dest); } } catch (IOException e) { diff --git a/config-test/src/test/java/com/powsybl/config/test/TestPlatformConfigProviderTest.java b/config-test/src/test/java/com/powsybl/config/test/TestPlatformConfigProviderTest.java index 3b28bbed509..3545bd0ada0 100644 --- a/config-test/src/test/java/com/powsybl/config/test/TestPlatformConfigProviderTest.java +++ b/config-test/src/test/java/com/powsybl/config/test/TestPlatformConfigProviderTest.java @@ -30,11 +30,16 @@ void test() throws IOException { assertEquals("/work/" + TestPlatformConfigProvider.CONFIG_DIR, platformConfig.getConfigDir().map(Path::toString).orElse(null)); - Path testPath = platformConfig.getConfigDir().map(p -> p.resolve("other.txt")).orElse(null); + checkFileContent(platformConfig, "other.txt", "conf"); + checkFileContent(platformConfig, "subfolder/subfolder_file.txt", "subfile content"); + assertEquals("baz", platformConfig.getOptionalModuleConfig("foo").flatMap(c -> c.getOptionalStringProperty("bar")).orElse("")); + } + + private void checkFileContent(PlatformConfig platformConfig, String file, String content) throws IOException { + Path testPath = platformConfig.getConfigDir().map(p -> p.resolve(file)).orElse(null); assertNotNull(testPath); String testContent = Files.readAllLines(testPath, StandardCharsets.UTF_8).get(0); - assertEquals("conf", testContent); - assertEquals("baz", platformConfig.getOptionalModuleConfig("foo").flatMap(c -> c.getOptionalStringProperty("bar")).orElse("")); + assertEquals(content, testContent); } @Test diff --git a/config-test/src/test/resources/com/powsybl/config/test/filelist.txt b/config-test/src/test/resources/com/powsybl/config/test/filelist.txt index 8c98f97de36..4e6ac675e5d 100644 --- a/config-test/src/test/resources/com/powsybl/config/test/filelist.txt +++ b/config-test/src/test/resources/com/powsybl/config/test/filelist.txt @@ -1,3 +1,4 @@ config.yml other.txt base-voltages.yml +subfolder/subfolder_file.txt diff --git a/config-test/src/test/resources/com/powsybl/config/test/subfolder/subfolder_file.txt b/config-test/src/test/resources/com/powsybl/config/test/subfolder/subfolder_file.txt new file mode 100644 index 00000000000..7b98f0ca009 --- /dev/null +++ b/config-test/src/test/resources/com/powsybl/config/test/subfolder/subfolder_file.txt @@ -0,0 +1 @@ +subfile content \ No newline at end of file