Ejemplo n.º 1
0
 public final void run() {
   try {
     realRun();
     threadShouldThrow("InterruptedException");
   } catch (InterruptedException success) {
     threadAssertFalse(Thread.interrupted());
   } catch (Throwable t) {
     threadUnexpectedException(t);
   }
 }
Ejemplo n.º 2
0
 public final T call() {
   try {
     T result = realCall();
     threadShouldThrow("InterruptedException");
     return result;
   } catch (InterruptedException success) {
     threadAssertFalse(Thread.interrupted());
   } catch (Throwable t) {
     threadUnexpectedException(t);
   }
   return null;
 }
Ejemplo n.º 3
0
  /**
   * Extra checks that get done for all test cases.
   *
   * <p>Triggers test case failure if any thread assertions have failed, by rethrowing, in the test
   * harness thread, any exception recorded earlier by threadRecordFailure.
   *
   * <p>Triggers test case failure if interrupt status is set in the main thread.
   */
  public void tearDown() throws Exception {
    Throwable t = threadFailure.getAndSet(null);
    if (t != null) {
      if (t instanceof Error) throw (Error) t;
      else if (t instanceof RuntimeException) throw (RuntimeException) t;
      else if (t instanceof Exception) throw (Exception) t;
      else {
        AssertionFailedError afe = new AssertionFailedError(t.toString());
        afe.initCause(t);
        throw afe;
      }
    }

    if (Thread.interrupted()) throw new AssertionFailedError("interrupt status set in main thread");
  }