1 8 9 package com.sleepycat.je.junit; 10 11 import junit.framework.Assert; 12 13 39 public class JUnitThread extends Thread { 40 private Throwable errorReturn; 41 42 45 public JUnitThread(String name) { 46 super(name); 47 } 48 49 public void run() { 50 try { 51 testBody(); 52 } catch (Throwable T) { 53 errorReturn = T; 54 } 55 } 56 57 62 public void testBody() 63 throws Throwable { 64 65 } 66 67 72 public void doTest() 73 throws Throwable { 74 75 start(); 76 finishTest(); 77 } 78 79 83 public void finishTest() 84 throws Throwable { 85 86 try { 87 join(); 88 } catch (InterruptedException IE) { 89 Assert.fail("caught unexpected InterruptedException"); 90 } 91 if (errorReturn != null) { 92 throw errorReturn; 93 } 94 } 95 96 public String toString() { 97 return "<JUnitThread: " + super.toString() + ">"; 98 } 99 } 100 | Popular Tags |