Package java.util

Examples of java.util.Timer.cancel()


      assertTrue("Fixed Rate Schedule should catch up, but is off by "
          + lastDelta + " ms", slowThenFastTask.lastDelta < 300);
      t.cancel();
    } finally {
      if (t != null)
        t.cancel();
    }
  }

  /**
   * @tests java.util.Timer#scheduleAtFixedRate(java.util.TimerTask,
View Full Code Here


    Timer t = null;
    try {
      // Ensure a Timer throws an IllegalStateException after cancelled
      t = new Timer();
      TimerTestTask testTask = new TimerTestTask();
      t.cancel();
      boolean exception = false;
      Date d = new Date(System.currentTimeMillis() + 100);
      try {
        t.scheduleAtFixedRate(testTask, d, 100);
      } catch (IllegalStateException e) {
View Full Code Here

        exception = true;
      }
      assertTrue(
          "scheduleAtFixedRate with negative Date should throw IllegalArgumentException",
          exception);
      t.cancel();

      // Ensure a Timer throws an IllegalArgumentException if period is
      // negative
      t = new Timer();
      testTask = new TimerTestTask();
View Full Code Here

        exception = true;
      }
      assertTrue(
          "scheduleAtFixedRate with negative period should throw IllegalArgumentException",
          exception);
      t.cancel();

      // Ensure a Timer throws an NullPointerException if date is Null
      t = new Timer();
      testTask = new TimerTestTask();
      exception = false;
View Full Code Here

        exception = true;
      }
      assertTrue(
          "scheduleAtFixedRate with null date should throw NullPointerException",
          exception);
      t.cancel();

      // Ensure proper sequence of exceptions
      t = new Timer();
      exception = false;
      d = new Date(-100);
View Full Code Here

        exception = true;
      }
      assertTrue(
          "Scheduling a null task with negative date should throw IllegalArgumentException first",
          exception);
      t.cancel();

      // Ensure proper sequence of exceptions
      t = new Timer();
      exception = false;
      try {
View Full Code Here

        exception = true;
      }
      assertTrue(
          "Scheduling a null task & null date & negative period should throw IllegalArgumentException first",
          exception);
      t.cancel();

      // Ensure a task is run at least twice
      t = new Timer();
      testTask = new TimerTestTask();
      d = new Date(System.currentTimeMillis() + 100);
View Full Code Here

      } catch (InterruptedException e) {
      }
      assertTrue(
          "TimerTask.run() method should have been called at least twice ("
              + testTask.wasRun() + ")", testTask.wasRun() >= 2);
      t.cancel();

      class SlowThenFastTask extends TimerTask {
        int wasRun = 0;

        long startedAt;
View Full Code Here

      } catch (InterruptedException e) {
      }
      long lastDelta = slowThenFastTask.lastDelta();
      assertTrue("Fixed Rate Schedule should catch up, but is off by "
          + lastDelta + " ms", lastDelta < 300);
      t.cancel();
    } finally {
      if (t != null)
        t.cancel();
    }
  }
View Full Code Here

      assertTrue("Fixed Rate Schedule should catch up, but is off by "
          + lastDelta + " ms", lastDelta < 300);
      t.cancel();
    } finally {
      if (t != null)
        t.cancel();
    }
  }

  protected void setUp() {
    timerCounter = 0;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.