1 19 package org.netbeans.test.editor.app.tests; 20 21 import java.io.PrintStream ; 22 import java.io.PrintWriter ; 23 import java.security.PermissionCollection ; 24 import java.security.Permissions ; 25 import java.security.AllPermission ; 26 27 import java.lang.reflect.Method ; 28 import java.lang.reflect.Constructor ; 29 import org.netbeans.test.editor.app.Main; 30 31 import org.netbeans.test.editor.app.util.WriterOutputStream; 32 import org.openide.filesystems.Repository; 34 35 36 public class CallTestGeneric { 37 38 private static final boolean debug = true; 39 40 private PrintWriter log = null; 41 42 protected void log(String what) { 43 if (log != null) { 44 log.println(what); 45 log.flush(); 46 } else { 47 System.err.println(what); 48 System.err.flush(); 49 } 50 } 51 52 public void runTest(String [] args, final PrintWriter log, final PrintWriter ref) throws Exception { 53 PrintStream oout = System.out; 54 PrintStream oerr = System.err; 55 56 try { 57 if (debug) 58 System.err.println("Testing internal execution!"); 59 if (Repository.getDefault() == null) { 60 throw new IllegalStateException ("Repository.getDefault() == null, probably not internal execution."); 61 } 62 63 if (debug) 64 System.err.println("Redirecting System.err and System.out."); 65 System.setErr(new PrintStream (new WriterOutputStream(log))); 66 System.setOut(new PrintStream (new WriterOutputStream(ref))); 67 68 System.err.println("Before trying to execute:"); 69 Main.main(args); 70 82 } catch (Exception e) { 83 e.printStackTrace(log); 84 throw e; 85 } finally { 86 System.err.flush(); 87 System.out.flush(); 88 System.setOut(oout); 89 System.setErr(oerr); 90 } 91 } 92 93 public static final void main(String [] args) throws Exception { 94 String [] arguments = new String [] { 95 "/org/netbeans/test/editor/app/tests/javadoc_test.xml", 96 "Javadoc_writting.Common_Java_settings", 97 "/org/netbeans/test/editor/app/tests/javadoc_test.xml", 98 "Javadoc_writting.JavaDoc_inside", 99 }; 100 PrintWriter log = new PrintWriter (System.err); 101 PrintWriter ref = new PrintWriter (System.out); 102 103 new CallTestGeneric().runTest(arguments, log, ref); 104 105 log.close(); 106 ref.close(); 107 } 108 } 109 | Popular Tags |