1 21 22 package org.apache.derbyTesting.unitTests.harness; 23 24 import org.apache.derby.iapi.services.monitor.ModuleControl; 25 import org.apache.derby.iapi.services.monitor.Monitor; 26 27 import org.apache.derbyTesting.unitTests.harness.UnitTest; 28 import org.apache.derbyTesting.unitTests.harness.UnitTestConstants; 29 import org.apache.derby.iapi.services.stream.HeaderPrintWriter; 30 import org.apache.derby.iapi.services.sanity.SanityManager; 31 import org.apache.derby.iapi.error.StandardException; 32 import org.apache.derby.iapi.services.sanity.SanityManager; 33 34 import java.util.Properties ; 35 36 48 public abstract class T_Generic implements UnitTest, ModuleControl 49 { 50 54 protected String shortModuleToTestName; 55 56 59 protected Properties startParams; 60 61 65 protected HeaderPrintWriter out; 66 67 protected T_Generic() 68 { 69 } 70 71 74 75 81 public void boot(boolean create, Properties startParams) 82 throws StandardException 83 { 84 shortModuleToTestName = 85 getModuleToTestProtocolName() 86 .substring(getModuleToTestProtocolName().lastIndexOf('.')+1); 87 88 this.startParams = startParams; 89 } 90 91 96 public void stop() { 97 } 98 99 102 107 public boolean Execute(HeaderPrintWriter out) 108 { 109 this.out = out; 110 111 String myClass = this.getClass().getName(); 112 String testName = myClass.substring(myClass.lastIndexOf('.') + 1); 113 114 System.out.println("-- Unit Test " + testName + " starting"); 115 116 try 117 { 118 runTests(); 119 } 120 121 catch (Throwable t) 122 { 123 124 while (t != null) { 125 FAIL(t.toString()); 126 t.printStackTrace(out.getPrintWriter()); 127 if (t instanceof StandardException) { 128 t = ((StandardException) t).getNestedException(); 129 continue; 130 } 131 break; 132 } 133 return false; 134 } 135 136 System.out.println("-- Unit Test " + testName + " finished"); 137 138 return true; 139 } 140 141 148 public int UnitTestDuration() { 149 return UnitTestConstants.DURATION_MICRO; 150 } 151 152 159 public int UnitTestType() { 160 return UnitTestConstants.TYPE_COMMON; 161 } 162 163 171 protected boolean FAIL(String msg) { 172 out.println("[" + Thread.currentThread().getName() + "] FAIL - " + msg); 173 return false; 174 } 175 176 185 protected boolean PASS(String testName) { 186 out.println("[" + Thread.currentThread().getName() + "] Pass - "+shortModuleToTestName +" " + testName); 187 return true; 188 } 189 190 194 public void REPORT(String msg) { 195 out.println("[" + Thread.currentThread().getName() + "] " + msg); 196 } 197 198 199 202 203 209 protected abstract void runTests() throws Exception ; 210 211 219 protected abstract String getModuleToTestProtocolName(); 220 } 221 | Popular Tags |