From 8857e8e8ff21f0d3c9a7f51aeef830de8625d0a3 Mon Sep 17 00:00:00 2001 From: Adam Kwiatek Date: Sat, 12 Oct 2019 19:01:57 +0200 Subject: [PATCH] Add a missing assertion to `TransformerTest` --- .../kohsuke/file_leak_detector/TransformerTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/kohsuke/file_leak_detector/TransformerTest.java b/src/test/java/org/kohsuke/file_leak_detector/TransformerTest.java index ecb631f..c8bd5a1 100644 --- a/src/test/java/org/kohsuke/file_leak_detector/TransformerTest.java +++ b/src/test/java/org/kohsuke/file_leak_detector/TransformerTest.java @@ -10,10 +10,13 @@ import org.kohsuke.file_leak_detector.transform.ClassTransformSpec; import org.kohsuke.file_leak_detector.transform.TransformerImpl; +import java.io.ByteArrayOutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; -import java.util.zip.ZipFile; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertTrue; /** * @author Kohsuke Kawaguchi @@ -42,7 +45,13 @@ public void testInstrumentations() throws Exception { // o.write(data2); // o.close(); - CheckClassAdapter.verify(new ClassReader(data2), false, new PrintWriter(System.err)); + String errors; + ClassReader classReader = new ClassReader(data2); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + CheckClassAdapter.verify(classReader, false, new PrintWriter(baos)); + errors = new String(baos.toByteArray(), UTF_8); + } + assertTrue("Verification failed for " + c + "\n" + errors, errors.isEmpty()); } @Parameters