Skip to content

Commit 05c0723

Browse files
committed
Use debug() instead of System.out.println for missing annotations warnings
1 parent 97cced1 commit 05c0723

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

common/junit-platform-native/src/main/java/org/graalvm/junit/platform/config/jupiter/JupiterConfigProvider.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ public void onTestClassRegistered(Class<?> testClass, NativeImageConfiguration r
8787
AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, EnabledIf.class, JupiterConfigProvider::handleEnabledIf);
8888
AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, DisabledIf.class, JupiterConfigProvider::handleDisabledIf);
8989
} catch (NoClassDefFoundError e) {
90-
AnnotationUtils.printMissingAnnotationsWarning("org.junit.jupiter.api", List.of("TestMethodOrder", "ExtendWith", "DisplayNameGeneration", "IndicativeSentencesGeneration", "EnabledIf", "DisabledIf"));
90+
debug("Cannot register annotations %s from %s. Please verify that you have dependency that includes %s if you want to use these annotations.",
91+
List.of("TestMethodOrder", "ExtendWith", "DisplayNameGeneration", "IndicativeSentencesGeneration", "EnabledIf", "DisabledIf"),
92+
"org.junit.jupiter.api",
93+
"org.junit.jupiter.api");
9194
}
9295

9396
/* Annotations from org.junit.jupiter.params */
@@ -102,11 +105,14 @@ public void onTestClassRegistered(Class<?> testClass, NativeImageConfiguration r
102105
try {
103106
AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, FieldSource.class, JupiterConfigProvider::handleFieldSource);
104107
} catch (NoClassDefFoundError e) {
105-
System.out.println("[junit-platform-native] Cannot register @FieldSource annotation from org.junit.jupiter.params." +
108+
debug("Cannot register @FieldSource annotation from org.junit.jupiter.params." +
106109
" Please verify that you have this dependency (with version greater than JUnit 5.13) if you want to use this annotation.");
107110
}
108111
} catch (NoClassDefFoundError e) {
109-
AnnotationUtils.printMissingAnnotationsWarning("org.junit.jupiter.params", List.of("ArgumentsSource", "ConvertWith", "AggregateWith", "EnumSource", "MethodSource", "FieldSource"));
112+
debug("Cannot register annotations %s from %s. Please verify that you have dependency that includes %s if you want to use these annotations.",
113+
List.of("ArgumentsSource", "ConvertWith", "AggregateWith", "EnumSource", "MethodSource", "FieldSource"),
114+
"org.junit.jupiter.params",
115+
"org.junit.jupiter.params");
110116
}
111117

112118
}

common/junit-platform-native/src/main/java/org/graalvm/junit/platform/config/util/AnnotationUtils.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,4 @@ public static <T extends Annotation> void registerClassesFromAnnotationForReflec
125125
config.registerAllClassMembersForReflection(reflectivelyAccessedClass);
126126
});
127127
}
128-
129-
public static void printMissingAnnotationsWarning(String packageName, List<String> annotations) {
130-
System.out.printf("[junit-platform-native] Cannot register annotations %s from %s. " +
131-
"Please verify that you have dependency that includes %s if you want to use these annotations.",
132-
annotations,
133-
packageName,
134-
packageName);
135-
}
136128
}

common/junit-platform-native/src/main/java/org/graalvm/junit/platform/config/vintage/VintageConfigProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import org.graalvm.nativeimage.hosted.RuntimeReflection;
4747
import org.graalvm.nativeimage.hosted.RuntimeSerialization;
4848

49+
import static org.graalvm.junit.platform.JUnitPlatformFeature.debug;
50+
4951
public class VintageConfigProvider extends PluginConfigProvider {
5052

5153
@Override
@@ -54,7 +56,7 @@ public void onLoad(NativeImageConfiguration config) {
5456
RuntimeSerialization.register(Class.forName("org.junit.runner.Result").getDeclaredClasses());
5557
RuntimeReflection.register(Class.forName("org.junit.runner.Description").getDeclaredFields());
5658
} catch (ClassNotFoundException e) {
57-
System.out.println("Cannot register declared classes of org.junit.runner.Result for serialization or fields of org.junit.runner.Description for reflection. Vintage JUnit not available.");
59+
debug("Cannot register declared classes of org.junit.runner.Result for serialization or fields of org.junit.runner.Description for reflection. Vintage JUnit not available.");
5860
}
5961
}
6062

0 commit comments

Comments
 (0)