Package com.google.code.tempusfugit.temporal

Examples of com.google.code.tempusfugit.temporal.Condition


            }
        };
    }

  public static Condition condition(final Callable<Boolean> callable ) {
    return new Condition() {
      @Override
      public boolean isSatisfied() {
        try {
          return callable.call();
        } catch (Exception e ) {
View Full Code Here


        THREADS.add(Thread.currentThread().getName());
        waitToForceCachedThreadPoolToCreateNewThread();
    }

    private void waitToForceCachedThreadPoolToCreateNewThread() throws InterruptedException, TimeoutException {
        waitOrTimeout(new Condition() {
            public boolean isSatisfied() {
                return THREADS.size() == getConcurrentCount();
            }
        }, timeout(seconds(1)));
    }
View Full Code Here

    }

    private void assertInterruptedWithin(Duration duration) throws TimeoutException {
        assertDurationIsAlotBiggerThanWaitForSleepPeriod(duration);
        try {
            waitOrTimeout(new Condition() {
                public boolean isSatisfied() {
                    return interrupted;
                }
            }, timeout(duration));
        } catch (InterruptedException e) {
View Full Code Here

    private Condition forDeadlockDetected() {
        return forDeadlockDetected(0);
    }

    private Condition forDeadlockDetected(final int stackDepth) {
        return new Condition() {
            @Override
            public boolean isSatisfied() {
                DeadlockDetector.printDeadlocks(deadlocks, stackDepth);
                return deadlocks.detected();
            }
View Full Code Here

        try {
            new DefaultTimeoutableCompletionService(new ExecutorCompletionService(newSingleThreadExecutor()), millis(1), new RealClock()).submit(asList(callable));
            fail("didn't timeout");
        } catch (TimeoutException e) {
            waitOrTimeout(new Condition() {
                public boolean isSatisfied() {
                    return interrupted.get();
                }
            }, timeout(seconds(10)));
        }
View Full Code Here

    }

  @Test
  public void callableToConditionWorksReturningTrue() throws Exception {
    callableWill(returnValue(true));
    Condition condition = condition(callable);
    assertThat(condition.isSatisfied(), is(true));
  }
View Full Code Here

  }

  @Test
  public void callableToConditionWorksReturningFalse() throws Exception {
    callableWill(returnValue(false));
    Condition condition = condition(callable);
    assertThat(condition.isSatisfied(), is(false));
  }
View Full Code Here

  }

  @Test
  public void callableToConditionReturnsFalseWhenCallableThrowsException() throws Exception {
    callableWill(throwException(new Exception()));
    Condition condition = condition(callable);
    assertThat(condition.isSatisfied(), is(false));
  }
View Full Code Here

        waitOrTimeout(probe(stateOfTheEconomy(), is("Out of recession!")), timeout(millis(250)));
    }

    @Test
    public void isSatisfied() {
        Condition condition = new SelfDescribingMatcherCondition<String>(lambda("the best"), is("the best"));
        assertThat(condition.isSatisfied(), is(true));
    }
View Full Code Here

        assertThat(condition.isSatisfied(), is(true));
    }

    @Test
    public void isNotSatisfied() {
        Condition condition = new SelfDescribingMatcherCondition<String>(lambda("the worst"), is("the best"));
        assertThat(condition.isSatisfied(), is(false));
    }
View Full Code Here

TOP

Related Classes of com.google.code.tempusfugit.temporal.Condition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.