示例#1
0
 @Override
 public void failed(Throwable e, Description desc) {
   System.out.println("FAILED TEST " + desc.getMethodName() + ": " + e.getMessage());
   e.printStackTrace(System.err);
   if (Debug.isDebug() && !(e instanceof OutOfMemoryError)) {
     Debug.record(
         0,
         "EXCEPTION IN THREAD "
             + Thread.currentThread().getName()
             + ": "
             + e
             + " - "
             + Arrays.toString(e.getStackTrace()));
     Debug.dumpRecorder("~/quasar.dump");
   }
 }
示例#2
0
  @Test
  public void testBlockingChannelSendingFiber() throws Exception {
    assumeThat(policy, is(OverflowPolicy.BLOCK));
    final Channel<Integer> ch = newChannel();

    Fiber<Integer> receiver =
        new Fiber<Integer>(
                fjPool,
                new SuspendableCallable<Integer>() {
                  @Override
                  public Integer run() throws SuspendExecution, InterruptedException {
                    int i = 0;
                    while (ch.receive() != null) {
                      i++;
                      Fiber.sleep(50);
                    }
                    return i;
                  }
                })
            .start();

    Fiber<Void> sender =
        new Fiber<Void>(
                fjPool,
                new SuspendableRunnable() {
                  @Override
                  public void run() throws SuspendExecution, InterruptedException {
                    for (int i = 0; i < 10; i++) ch.send(i);
                    ch.close();
                  }
                })
            .start();

    try {
      assertThat(receiver.get(), is(10));
      sender.join();
    } catch (Throwable t) {
      Debug.dumpRecorder("channels.log");
      throw t;
    }
  }