< prev index next >

test/java/rmi/testlibrary/JavaVM.java

Print this page

        

*** 19,28 **** --- 19,29 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; import java.util.StringTokenizer;
*** 32,50 **** * RMI regression test utility class that uses Runtime.exec to spawn a * java process that will run a named java class. */ public class JavaVM { 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 String policyFileName = null; private StreamPipe outPipe; private StreamPipe errPipe; private static void mesg(Object mesg) { --- 33,66 ---- * RMI regression test utility class that uses Runtime.exec to spawn a * java process that will run a named java class. */ public class JavaVM { + 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 CachedOutputStream outputStream = new CachedOutputStream(System.out); ! private CachedOutputStream errorStream = new CachedOutputStream(System.err); private String policyFileName = null; private StreamPipe outPipe; private StreamPipe errPipe; private static void mesg(Object mesg) {
*** 71,82 **** public JavaVM(String classname, String options, String args, OutputStream out, OutputStream err) { this(classname, options, args); ! this.outputStream = out; ! this.errorStream = err; } // Prepends passed opts array to current options public void addOptions(String... opts) { String newOpts = ""; --- 87,98 ---- public JavaVM(String classname, String options, String args, OutputStream out, OutputStream err) { this(classname, options, args); ! this.outputStream = new CachedOutputStream(out); ! this.errorStream = new CachedOutputStream(err); } // Prepends passed opts array to current options public void addOptions(String... opts) { String newOpts = "";
*** 108,117 **** --- 124,146 ---- */ protected static String getCodeCoverageOptions() { 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. */ public void start() throws IOException {
< prev index next >