Пример #1
0
  @Test
  public void testChangingCondition() throws Exception {
    Condition cond =
        new Condition() {
          private int intValue = 10;

          public boolean getValue() {
            return (--intValue <= 0);
          }
        };

    Condition.waitForCondition(5000L, cond);
    assertTrue(cond.getValue());
  }
Пример #2
0
 @Test
 public void testListener() {
   myHousing.setVisible(true);
   Condition.waitForCondition(
       5000,
       new Condition() {
         public boolean getValue() {
           return myHousing.isVisible();
         }
       });
   assertTrue(myHousing.isVisible());
   WindowListener listener = myHousing.getWindowListener();
   WindowEvent event = new WindowEvent(myHousing, WindowEvent.WINDOW_CLOSING);
   listener.windowClosing(event);
   myHousing.setVisible(false);
   Condition.waitForCondition(
       10000,
       new Condition() {
         public boolean getValue() {
           return !myHousing.isVisible();
         }
       });
   assertFalse(myHousing.isVisible());
 }
Пример #3
0
 @Test
 public void testTimeout() throws Exception {
   Condition.waitForCondition(1000L, falseCondition);
   assertTrue(!falseCondition.getValue());
   assertTrue(true, "Condition timed out");
 }
Пример #4
0
 @Test
 public void testAlwaysTrue() throws Exception {
   Condition.waitForCondition(Long.MAX_VALUE, trueCondition);
   assertTrue(true, "Condition became true");
 }
Пример #5
0
  @Test
  public void testGetValue() throws Exception {

    assertTrue(trueCondition.getValue());
  }