diff --git a/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/Configuration.java b/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/Configuration.java index 470b1cb81f0..320b956df86 100644 --- a/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/Configuration.java +++ b/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/Configuration.java @@ -28,9 +28,18 @@ @Target({ElementType.TYPE, ElementType.METHOD}) public @interface Configuration { /** - * You can configure the {@link org.eclipse.microprofile.config.Config} a - * @return + * If set to {@code true}, the existing (or default) MicroProfile configuration would be used. + * By default uses a configuration constructed using all {@link io.helidon.microprofile.tests.junit5.AddConfig} + * annotations and {@link #configSources()}. + * + * @return whether to use existing (or default) configuration, or customized one */ boolean useExisting() default false; + + /** + * Class path properties config sources to add to configuration of this test class or method. + * + * @return config sources to add + */ String[] configSources() default {}; } diff --git a/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/DisableDiscovery.java b/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/DisableDiscovery.java index 64d86ebbca3..2f25c9412d6 100644 --- a/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/DisableDiscovery.java +++ b/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/DisableDiscovery.java @@ -38,5 +38,13 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) public @interface DisableDiscovery { + /** + * By default if you annotate a class or a method, discovery gets disabled. + * If you want to override configuration on method to differ from class, you + * can configure the value to {@code false}, effectively enabling discovery. + * + * @return whether to disable discovery ({@code true}), or enable it ({@code false}). If this + * annotation is not present, discovery is enabled + */ boolean value() default true; } diff --git a/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/HelidonJunitExtension.java b/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/HelidonJunitExtension.java index 2ee6b74b145..866c40239e9 100644 --- a/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/HelidonJunitExtension.java +++ b/microprofile/tests/junit5/src/main/java/io/helidon/microprofile/tests/junit5/HelidonJunitExtension.java @@ -71,7 +71,6 @@ class HelidonJunitExtension implements BeforeAllCallback, private static final Set> HELIDON_TEST_ANNOTATIONS = Set.of(AddBean.class, AddConfig.class, AddExtension.class, Configuration.class); - private final List classLevelExtensions = new ArrayList<>(); private final List classLevelBeans = new ArrayList<>(); private final ConfigMeta classLevelConfigMeta = new ConfigMeta(); @@ -123,14 +122,13 @@ public void beforeAll(ExtensionContext context) { @Override public void beforeEach(ExtensionContext context) throws Exception { - if(resetPerTest) { + if (resetPerTest) { Method method = context.getRequiredTestMethod(); AddConfig[] configs = method.getAnnotationsByType(AddConfig.class); ConfigMeta methodLevelConfigMeta = classLevelConfigMeta.nextMethod(); methodLevelConfigMeta.addConfig(configs); methodLevelConfigMeta.configuration(method.getAnnotation(Configuration.class)); - configure(methodLevelConfigMeta); List methodLevelExtensions = new ArrayList<>(classLevelExtensions); diff --git a/microprofile/tests/junit5/src/test/resources/testConfigSources.properties b/microprofile/tests/junit5/src/test/resources/testConfigSources.properties index 95f2b33fae9..f89ba1dd864 100644 --- a/microprofile/tests/junit5/src/test/resources/testConfigSources.properties +++ b/microprofile/tests/junit5/src/test/resources/testConfigSources.properties @@ -14,4 +14,4 @@ # limitations under the License. # -some.key=some.value \ No newline at end of file +some.key=some.value