-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Milestone
Description
Describe the bug
since 3.18 it is not possible any more to get config in a junit-extension
public class JUnitExtensionUsingConfig implements BeforeEachCallback, AfterEachCallback {
@Override
public void afterEach(ExtensionContext extensionContext) { //FIXME this doesn't work
Config config = ConfigProvider.getConfig();
Optional<String> value = config.getOptionalValue("quarkus.http.root-path", String.class);
value.get(); //exception here, no value set
}
@Override
public void beforeEach(ExtensionContext extensionContext) {//FIXME this doesn't work
Config config = ConfigProvider.getConfig();
Optional<String> value = config.getOptionalValue("quarkus.http.root-path", String.class);
value.get(); //exception here, no value set
}
}
java.util.NoSuchElementException: No value present
at java.base/java.util.Optional.get(Optional.java:143)
at org.acme.JUnitExtensionUsingConfig.beforeEach(JUnitExtensionUsingConfig.java:24)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Suppressed: java.util.NoSuchElementException: No value present
at java.base/java.util.Optional.get(Optional.java:143)
at org.acme.JUnitExtensionUsingConfig.afterEach(JUnitExtensionUsingConfig.java:17)
... 2 more
Expected behavior
should work ConfigProvider.getConfig()
or at least with ConfigProvider.getConfig(SomeWellDocumented.class.getClassLoader())
Actual behavior
fails with java.util.NoSuchElementException: No value present
How to Reproduce?
https://github.com/flyinfish/quarkus--configprovider-junitext
follow readme
Output of uname -a
or ver
Linux C70C7391 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk 21.0.6 2025-01-21 LTS
Quarkus version or git rev
3.18.*
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Additional information
No response