Package java.util

Examples of java.util.Timer.cancel()


        exception = true;
      }
      assertTrue(
          "Scheduling a null task should throw NullPointerException",
          exception);
      t.cancel();

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


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

      // Ensure a task is run at least twice
      t = new Timer();
      d = new Date(System.currentTimeMillis() + 100);
      testTask = new TimerTestTask();
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();

      // Ensure multiple tasks are run
      t = new Timer();
      testTask = new TimerTestTask();
      testTask.incrementCount(true);
View Full Code Here

      } catch (InterruptedException e) {
      }
      assertTrue(
          "Multiple tasks should have incremented counter 24 times not "
              + timerCounter, timerCounter >= 24);
      t.cancel();
    } finally {
      if (t != null)
        t.cancel();
    }
  }
View Full Code Here

          "Multiple tasks should have incremented counter 24 times not "
              + timerCounter, timerCounter >= 24);
      t.cancel();
    } finally {
      if (t != null)
        t.cancel();
    }
  }

  /**
   * @tests java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, long,
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;
      try {
        t.scheduleAtFixedRate(testTask, 100, 100);
      } catch (IllegalStateException e) {
        exception = true;
View Full Code Here

        exception = true;
      }
      assertTrue(
          "scheduleAtFixedRate with negative delay 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 task is run at least twice
      t = new Timer();
      testTask = new TimerTestTask();
      t.scheduleAtFixedRate(testTask, 100, 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", slowThenFastTask.lastDelta < 300);
      t.cancel();
    } finally {
      if (t != null)
        t.cancel();
    }
  }
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.