Register runtime hints for OutputCapture

Closes gh-32870
pull/32880/head
Moritz Halbritter 2 years ago
parent f11945b961
commit 35abc3a6dc

@ -21,14 +21,19 @@ import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Predicate;
import org.springframework.aot.hint.ExecutableMode;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.TypeReference;
import org.springframework.boot.ansi.AnsiOutput;
import org.springframework.boot.ansi.AnsiOutput.Enabled;
import org.springframework.test.context.aot.TestRuntimeHintsRegistrar;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@ -339,4 +344,15 @@ class OutputCapture implements CapturedOutput {
}
static class OutputCaptureRuntimeHints implements TestRuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints runtimeHints, Class<?> testClass, ClassLoader classLoader) {
runtimeHints.reflection().registerType(TypeReference.of(OutputCapture.class),
(hint) -> hint.onReachableType(OutputCaptureExtension.class)
.withConstructor(Collections.emptyList(), ExecutableMode.INVOKE));
}
}
}

@ -0,0 +1,3 @@
# Runtime hints for tests
org.springframework.test.context.aot.TestRuntimeHintsRegistrar=\
org.springframework.boot.test.system.OutputCapture.OutputCaptureRuntimeHints
Loading…
Cancel
Save