1 package org.jacorb.test.common.launch; 2 3 23 24 import java.io.*; 25 import java.util.*; 26 import java.text.*; 27 28 import org.jacorb.test.common.*; 29 30 53 public class TestLauncher 54 { 55 private static String [] args = null; 56 private static PrintWriter outFile = null; 57 private static Date testDate = new java.util.Date (); 58 59 private static DateFormat idFormatter = 60 new SimpleDateFormat ("yyyy-MM-dd.HH-mm-ss"); 61 62 private static DateFormat dateStringFormatter = 63 new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss Z"); 64 65 private static class Listener extends Thread 66 { 67 private BufferedReader in = null; 68 69 public Listener (InputStream in) 70 { 71 this.in = new BufferedReader (new InputStreamReader (in)); 72 } 73 74 public void run() 75 { 76 try 77 { 78 while (true) 79 { 80 String line = in.readLine(); 81 if (line == null) break; 82 System.out.println (line); 83 outFile.println (line); 84 } 85 } 86 catch (Exception ex) 87 { 88 System.out.println ("exception reading from test client: " 89 + ex.toString()); 90 } 91 } 92 93 } 94 95 public static void printTestHeader (PrintWriter out) 96 { 97 out.println ("-------------------------------------------------------------------------------"); 98 out.println(); 99 out.println (" JacORB Regression Test Report"); 100 out.println(); 101 out.println (" Suite: " + getSuiteName()); 102 out.println (""); 103 out.println (" Date: " + getTestDateString()); 104 out.println (" User: " + getTestUser()); 105 out.println (" Platform: " + getTestPlatform()); 106 out.println(); 107 out.println (" Client Version: " + getClientVersion()); 108 out.println (" Server Version: " + getServerVersion()); 109 out.println (" Coverage: " + (getCoverage() ? "yes" : "no")); 110 out.println(); 111 out.println ("-------------------------------------------------------------------------------"); 112 } 113 114 public static void printTestHeader (PrintStream out) 115 { 116 PrintWriter x = new PrintWriter (out); 117 printTestHeader(x); 118 x.flush(); 119 } 120 121 public static String getSuiteName() 122 { 123 return args[0]; 124 } 125 126 public static Date getTestDate() 127 { 128 return testDate; 129 } 130 131 public static String getTestID() 132 { 133 return idFormatter.format (getTestDate()); 134 } 135 136 public static String getTestDateString() 137 { 138 return dateStringFormatter.format (getTestDate()); 139 } 140 141 public static boolean getCoverage() 142 { 143 String cs = System.getProperty("jacorb.test.coverage", "false"); 144 return cs.equals("true") || cs.equals("on") || cs.equals("yes"); 145 } 146 147 public static String getClientVersion() 148 { 149 return System.getProperty ("jacorb.test.client.version", "cvs"); 150 } 151 152 public static String getServerVersion() 153 { 154 return System.getProperty ("jacorb.test.server.version", "cvs"); 155 } 156 157 public static String getTestUser() 158 { 159 return System.getProperty ("user.name", "<unknown>"); 160 } 161 162 public static String getTestPlatform() 163 { 164 return "java " + System.getProperty ("java.version") 165 + " (" + System.getProperty ("java.vendor") + ") " 166 + System.getProperty ("os.name") + " " 167 + System.getProperty ("os.version") + " (" 168 + System.getProperty ("os.arch") + ")"; 169 } 170 171 public static String getOutFilename() 172 { 173 String dir = TestUtils.testHome() + "/output/" + getTestID(); 174 File dirF = new File (dir); 175 if (!dirF.exists()) dirF.mkdir(); 176 return dir + "/report.txt"; 177 } 178 179 public static void main(String [] args) throws Exception 180 { 181 TestLauncher.args = args; 182 outFile = new PrintWriter (new FileWriter (getOutFilename())); 183 printTestHeader (outFile); 184 printTestHeader (System.out); 185 186 String mainClass = "junit.textui.TestRunner"; 187 188 String classpath = TestUtils.testHome() + "/classes:" 189 + TestUtils.testHome() + "/lib/junit.jar:" 190 + TestUtils.testHome() + "/lib/easymock-1.1.jar"; 191 192 Properties props = new Properties(); 193 props.put("jacorb.test.id", getTestID()); 194 props.put("jacorb.test.coverage", getCoverage() ? "true" : "false"); 195 props.put("jacorb.test.client.version", getClientVersion()); 196 props.put("jacorb.test.server.version", getServerVersion()); 197 props.put("javax.rmi.CORBA.UtilClass", 198 "org.jacorb.test.orb.rmi.FixSunDelegateBug"); 199 200 JacORBLauncher launcher = JacORBLauncher.getLauncher 201 ( 202 getClientVersion(), getCoverage() 203 ); 204 205 if (getCoverage()) 206 props.put ("emma.coverage.out.file", 207 launcher.getJacorbHome() 208 + "/test/regression/output/" 209 + getTestID() + "/coverage-client.ec"); 210 211 Process p = launcher.launch(classpath, props, mainClass, args); 212 213 Listener outL = new Listener(p.getInputStream()); 214 outL.start(); 215 Listener errL = new Listener(p.getErrorStream()); 216 errL.start(); 217 218 p.waitFor(); 219 220 outFile.close(); 221 } 222 } 223 | Popular Tags |