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();
      exception = false;
      try {
View Full Code Here


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

      // Ensure a task is run at least twice
      t = new Timer();
      testTask = new TimerTestTask();
      t.schedule(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();

      // 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#schedule(java.util.TimerTask, java.util.Date,
View Full Code Here

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

        exception = true;
      }
      assertTrue(
          "Scheduling a task after cancelling it should throw exception",
          exception);
      t.cancel();

      // Ensure a Timer throws an IllegalArgumentException if delay is
      // negative
      t = new Timer();
      d = new Date(-100);
View Full Code Here

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

      // Ensure a Timer throws an IllegalArgumentException if period is
      // negative
      t = new Timer();
      d = new Date(System.currentTimeMillis() + 100);
View Full Code Here

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

      // Ensure a Timer throws a NullPointerException if the task is null
      t = new Timer();
      d = new Date(System.currentTimeMillis() + 100);
      exception = false;
View Full Code Here

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

      // Ensure a Timer throws a NullPointerException if the date is null
      t = new Timer();
      testTask = new TimerTestTask();
      exception = false;
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.