- Timestamp:
- 07/10/13 22:41:02 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/test/java/com/framsticks/test/TestConfiguration.java
r98 r99 17 17 import com.framsticks.util.dispatching.ExceptionResultHandler; 18 18 19 import static org.fest.assertions.Assertions.*;19 // import static org.fest.assertions.Assertions.*; 20 20 21 21 public class TestConfiguration { … … 31 31 private final List<AssertionError> asyncAssertions = new LinkedList<>(); 32 32 33 public static AssertionError wrapInAssertion(Throwable throwable) { 34 if (throwable instanceof AssertionError) { 35 return (AssertionError) throwable; 36 } 37 38 AssertionError ae = new AssertionError(); 39 ae.initCause(throwable); 40 return ae; 41 } 42 43 public void addAsyncAssertion(Throwable throwable) { 44 synchronized (asyncAssertions) { 45 asyncAssertions.add(wrapInAssertion(throwable)); 46 } 47 } 48 33 49 public ExceptionHandler createExceptionHandler() { 34 50 return new ExceptionHandler() { 35 51 @Override 36 52 public boolean handle(Dispatcher<?> dispatcher, Throwable throwable) { 37 AssertionError ae; 38 if (AssertionError.class.isInstance(throwable)) { 39 ae = AssertionError.class.cast(throwable); 40 } else { 41 ae = new AssertionError(); 42 ae.initCause(throwable); 43 } 44 synchronized (asyncAssertions) { 45 asyncAssertions.add(ae); 46 } 53 addAsyncAssertion(throwable); 47 54 return true; 48 55 } … … 83 90 84 91 protected Dispatching.Waiter produceWaiter(double timeOut) { 85 Waiter waiter = new Waiter(timeOut );92 Waiter waiter = new Waiter(timeOut, failOnException); 86 93 waiters.add(waiter); 87 94 return waiter; 88 95 } 89 96 90 public staticfinal ExceptionResultHandler failOnException = new ExceptionResultHandler() {97 public final ExceptionResultHandler failOnException = new ExceptionResultHandler() { 91 98 @Override 92 99 public void handle(FramsticksException e) { 93 e.printStackTrace();94 a ssertThat(e).isNull();100 log.error("passing exception as assertion in " + TestConfiguration.this.getClass(), e); 101 addAsyncAssertion(e); 95 102 } 96 103 };
Note: See TracChangeset
for help on using the changeset viewer.