예제 #1
1
  /**
   * Test the same robot trying to wait twice (not allowed in single thread mode)
   *
   * @throws Throwable
   */
  @Test(expectedExceptions = IllegalArgumentException.class, timeOut = 3000)
  public void testMutipleWaitsSameRobot() throws Throwable {

    TU.addListener(332);

    Callable<Boolean> second =
        new Callable<Boolean>() {

          @Override
          public Boolean call() throws Exception {
            TU.waitFor(332, 4, "testMutipleWaitsSameRobot-second");
            return true;
          }
        };

    FutureTask<Boolean> secondTask = new FutureTask<>(second);
    Thread secondThread = new Thread(secondTask, "Fake second robot");
    secondThread.start();

    while (secondThread.getState() != State.WAITING) {
      Thread.yield();
    }

    TU.waitFor(
        332,
        2,
        "testMutipleWaitsSameRobot"); // should fail since fake second should be blocked already
    try {
      secondTask.get();
    } catch (ExecutionException exc) {
      throw exc.getCause();
    }
    fail("Should throw exception");
  }
예제 #2
0
 /** Tests signalling a robot that's not registered */
 @Test(expectedExceptions = IllegalArgumentException.class)
 public void testNotRegisteredSignal() {
   TU.waitFor(123, 3, "testNotRegisteredSignal");
 }