diff --git a/testsuite/extra/.env b/testsuite/extra/.env new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/extra/config/application.properties b/testsuite/extra/config/application.properties new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/extra/config/application.yaml b/testsuite/extra/config/application.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/extra/config/application.yml b/testsuite/extra/config/application.yml new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/extra/src/test/java/io/smallrye/config/test/location/PropertiesLocationTest.java b/testsuite/extra/src/test/java/io/smallrye/config/test/location/PropertiesLocationTest.java index 9c6b2fb18..656bee8c6 100644 --- a/testsuite/extra/src/test/java/io/smallrye/config/test/location/PropertiesLocationTest.java +++ b/testsuite/extra/src/test/java/io/smallrye/config/test/location/PropertiesLocationTest.java @@ -24,10 +24,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import io.smallrye.config.PropertiesConfigSource; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; -import io.smallrye.config.source.yaml.YamlConfigSource; public class PropertiesLocationTest { @Test @@ -56,7 +54,7 @@ void multipleResourcesInClassPath(@TempDir Path tempDir) throws Exception { assertEquals("1234", config.getRawValue("my.prop.one")); assertEquals("5678", config.getRawValue("my.prop.two")); - assertEquals(2, countSources(config, PropertiesConfigSource.class)); + assertEquals(2, countSources(config, "resources.properties")); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } @@ -93,7 +91,7 @@ void multipleResourcesInClassPathYaml(@TempDir Path tempDir) throws Exception { assertEquals("1234", config.getRawValue("my.prop.one")); assertEquals("5678", config.getRawValue("my.prop.two")); - assertEquals(2, countSources(config, YamlConfigSource.class)); + assertEquals(2, countSources(config, "resources.yml")); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } @@ -115,7 +113,7 @@ void jar(@TempDir Path tempDir) throws Exception { SmallRyeConfig config = buildConfig("jar:" + filePathOne.toUri() + "!/resources.properties"); assertEquals("1234", config.getRawValue("my.prop.one")); - assertEquals(1, countSources(config, PropertiesConfigSource.class)); + assertEquals(1, countSources(config, "resources.properties")); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } @@ -141,7 +139,7 @@ void jarYaml(@TempDir Path tempDir) throws Exception { SmallRyeConfig config = buildConfig("jar:" + filePathOne.toUri() + "!/resources.yml"); assertEquals("1234", config.getRawValue("my.prop.one")); - assertEquals(1, countSources(config, YamlConfigSource.class)); + assertEquals(1, countSources(config, "resources.yml")); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } @@ -206,9 +204,13 @@ void priorityLoadOrder(@TempDir Path tempDir) throws Exception { assertEquals("main", config.getRawValue("my.prop.common")); // This should be loaded by the first discovered source in the classpath assertEquals("1", config.getRawValue("my.prop.jar.common")); - assertEquals(4, countSources(config, PropertiesConfigSource.class)); + assertEquals(3, countSources(config, "microprofile-config.properties")); + assertEquals(1, countSources(config, "fallback.properties")); assertTrue(stream(config.getConfigSources().spliterator(), false) - .filter(PropertiesConfigSource.class::isInstance) + .filter(configSource -> configSource.getName().contains("microprofile-config.properties")) + .allMatch(configSource -> configSource.getOrdinal() == 100)); + assertTrue(stream(config.getConfigSources().spliterator(), false) + .filter(configSource -> configSource.getName().contains("fallback.properties")) .allMatch(configSource -> configSource.getOrdinal() == 100)); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); @@ -384,8 +386,10 @@ void mixedProfiles(@TempDir Path tempDir) throws Exception { assertEquals("common-file", config.getRawValue("my.prop.common")); assertEquals("dev-file", config.getRawValue("my.prop.profile")); - final List sources = stream(config.getConfigSources().spliterator(), false) - .filter(PropertiesConfigSource.class::isInstance).collect(toList()); + List sources = stream(config.getConfigSources().spliterator(), false) + .filter(configSource -> configSource.getName().contains("config.properties") + || configSource.getName().contains("config-")) + .collect(toList()); assertEquals(6, sources.size()); assertEquals("1", sources.get(0).getValue("order")); assertEquals("2", sources.get(1).getValue("order")); @@ -457,7 +461,7 @@ void mixedExtensions(@TempDir Path tempDir) throws Exception { .build(); assertEquals("5678", config.getRawValue("my.prop.one")); - assertEquals(2, countSources(config, YamlConfigSource.class)); + assertEquals(2, countSources(config, "resources")); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } @@ -481,8 +485,9 @@ private static SmallRyeConfig buildConfig(String... locations) { .build(); } - private static int countSources(SmallRyeConfig config, Class configSource) { - return (int) stream(config.getConfigSources().spliterator(), false).filter(configSource::isInstance) + private static int countSources(SmallRyeConfig config, String name) { + return (int) stream(config.getConfigSources().spliterator(), false) + .filter(configSource -> configSource.getName().contains(name)) .count(); } } diff --git a/testsuite/extra/src/test/java/io/smallrye/config/test/source/OrdinalSourceTest.java b/testsuite/extra/src/test/java/io/smallrye/config/test/source/OrdinalSourceTest.java index 7767f2b8b..6d9f1ef51 100644 --- a/testsuite/extra/src/test/java/io/smallrye/config/test/source/OrdinalSourceTest.java +++ b/testsuite/extra/src/test/java/io/smallrye/config/test/source/OrdinalSourceTest.java @@ -30,7 +30,7 @@ static WebArchive deploy() { @Test void ordinal() { for (ConfigSource configSource : config.getConfigSources()) { - if (configSource.getName().startsWith("PropertiesConfigSource")) { + if (configSource.getName().contains("microprofile-config.properties")) { assertEquals(1234, configSource.getOrdinal()); } } diff --git a/testsuite/extra/src/test/java/io/smallrye/config/test/source/SmallRyeConfigTest.java b/testsuite/extra/src/test/java/io/smallrye/config/test/source/SmallRyeConfigTest.java index 55c7a5008..614f724d2 100644 --- a/testsuite/extra/src/test/java/io/smallrye/config/test/source/SmallRyeConfigTest.java +++ b/testsuite/extra/src/test/java/io/smallrye/config/test/source/SmallRyeConfigTest.java @@ -21,7 +21,6 @@ import io.smallrye.config.DefaultValuesConfigSource; import io.smallrye.config.EnvConfigSource; -import io.smallrye.config.PropertiesConfigSource; import io.smallrye.config.SysPropConfigSource; @ExtendWith(ArquillianExtension.class) @@ -45,10 +44,17 @@ void config() { void sources() { List sources = StreamSupport.stream(config.getConfigSources().spliterator(), false).collect(toList()); - assertEquals(4, sources.size()); + assertEquals(11, sources.size()); assertTrue(sources.get(0) instanceof SysPropConfigSource); assertTrue(sources.get(1) instanceof EnvConfigSource); - assertTrue(sources.get(2) instanceof PropertiesConfigSource); - assertTrue(sources.get(3) instanceof DefaultValuesConfigSource); + assertTrue(sources.get(2).getName().contains(".env")); + assertTrue(sources.get(3).getName().contains("config/application.yaml")); + assertTrue(sources.get(4).getName().contains("config/application.yml")); + assertTrue(sources.get(5).getName().contains("config/application.properties")); + assertTrue(sources.get(6).getName().contains("application.yaml")); + assertTrue(sources.get(7).getName().contains("application.yml")); + assertTrue(sources.get(8).getName().contains("application.properties")); + assertTrue(sources.get(9).getName().contains("microprofile-config.properties")); + assertTrue(sources.get(10) instanceof DefaultValuesConfigSource); } } diff --git a/testsuite/extra/src/test/resources/application.properties b/testsuite/extra/src/test/resources/application.properties new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/extra/src/test/resources/application.yaml b/testsuite/extra/src/test/resources/application.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/extra/src/test/resources/application.yml b/testsuite/extra/src/test/resources/application.yml new file mode 100644 index 000000000..e69de29bb