1 21 22 package org.apache.derby.impl.tools.ij; 23 24 import java.util.Vector ; 25 import java.io.IOException ; 26 import java.io.FileNotFoundException ; 27 import java.io.BufferedInputStream ; 28 import java.util.Date ; 29 30 import org.apache.derby.iapi.tools.i18n.LocalizedOutput; 31 32 37 public class mtTester implements Runnable 38 { 39 private mtTestSuite suite; 40 private String name; 41 private LocalizedOutput log; 42 private LocalizedOutput out; 43 private boolean stop = false; 44 private boolean testOK = false; 45 46 public mtTester(String name, mtTestSuite suite, LocalizedOutput out, LocalizedOutput log) 47 { 48 this.name = name; 49 this.suite = suite; 50 this.log = log; 51 this.out = out; 52 log.println("...initialized "+ name + " at " + new Date ()); 53 } 54 55 61 public void run() 62 { 63 int numIterations = 0; 64 65 try 66 { 67 mtTestCase testCase; 68 BufferedInputStream in; 69 70 while (!stop) 73 { 74 numIterations++; 75 testCase = suite.grabTestCase(); 76 try 77 { 78 in = testCase.initialize(suite.getRoot()); 79 } catch (FileNotFoundException e) 80 { 81 System.out.println(e); 82 return; 83 } 84 catch (IOException e) 85 { 86 System.out.println(e); 87 return; 88 } 89 90 log.println(name + ": "+ testCase.getName() + " " + new Date ()); 91 testCase.runMe(log, out, in); 92 } 93 } 94 catch (ijFatalException e) 95 { 96 97 104 if (e.getSQLState() == null || !(e.getSQLState().equals("XJ010"))) 105 { 106 log.println(name + ": TERMINATING due to unexpected error:\n"+e); 107 throw new ThreadDeath (); 108 } 109 } 110 if (stop) 111 { 112 log.println(name + ": stopping on request after " + numIterations + 113 " iterations"); 114 testOK = true; 115 } 116 } 117 118 public void stop() 119 { 120 stop = true; 121 } 122 public boolean noFailure() 123 { 124 return testOK; 125 } 126 } 127 | Popular Tags |