--- old/test/java/rmi/testlibrary/JavaVM.java 2016-09-27 02:08:12.391933989 -0700 +++ new/test/java/rmi/testlibrary/JavaVM.java 2016-09-27 02:08:12.224017986 -0700 @@ -21,6 +21,7 @@ * questions. */ +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -34,15 +35,30 @@ */ public class JavaVM { - public static final long POLLTIME_MS = 100L; + static class CachedOutputStream extends OutputStream { + ByteArrayOutputStream ba; + OutputStream os; + + public CachedOutputStream(OutputStream os) { + this.os = os; + this.ba = new ByteArrayOutputStream(); + } + + public void write(int b) throws IOException { + ba.write(b); + os.write(b); + } + } + + public static final long POLLTIME_MS = 100L; protected Process vm = null; private String classname = ""; private String args = ""; private String options = ""; - private OutputStream outputStream = System.out; - private OutputStream errorStream = System.err; + private CachedOutputStream outputStream = new CachedOutputStream(System.out); + private CachedOutputStream errorStream = new CachedOutputStream(System.err); private String policyFileName = null; private StreamPipe outPipe; private StreamPipe errPipe; @@ -73,8 +89,8 @@ String options, String args, OutputStream out, OutputStream err) { this(classname, options, args); - this.outputStream = out; - this.errorStream = err; + this.outputStream = new CachedOutputStream(out); + this.errorStream = new CachedOutputStream(err); } // Prepends passed opts array to current options @@ -110,6 +126,19 @@ return TestLibrary.getExtraProperty("jcov.options",""); } + public boolean outputContains(String str) { + return outputStream.ba.toString().indexOf(str) != -1 + || errorStream.ba.toString().indexOf(str) != -1; + } + + private String outputString() { + return outputStream.ba.toString(); + } + + private String errorString() { + return errorStream.ba.toString(); + } + /** * Exec the VM as specified in this object's constructor. */