Пример #1
1
 /**
  * Executes the test.
  *
  * @since 1.00
  */
 private static void execute() {
   try {
     Thread.sleep(2000);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   ThreadedTest listener = new ThreadedTest();
   r1 = new Runnable1(listener, 0 /*8 * MILLI_SEC*/);
   Thread t1 = new Thread(r1);
   r2 = new Runnable2(listener, 0 /*19 * MILLI_SEC*/);
   Thread t2 = new Thread(r2);
   r3 = new Runnable3(listener, 0 /*25 * MILLI_SEC*/);
   Thread t3 = new Thread(r3);
   TestEnvironment.notice("Starting runnable 1");
   t1.start();
   TestEnvironment.notice("Starting runnable 2");
   t2.start();
   TestEnvironment.notice("Starting runnable 3");
   t3.start();
   while (finished < 3 || t1.isAlive() || t2.isAlive() || t3.isAlive()) {
     try {
       Thread.sleep(1000);
     } catch (InterruptedException e) {
     }
   }
 }
Пример #2
0
  /**
   * Executes the test.
   *
   * @since 1.00
   */
  private static void execute() {
    // start and stop in one step
    long start = System.currentTimeMillis();
    timerInOneMethod();
    long end = System.currentTimeMillis();
    timeStartStopOneStep = end - start;
    recIdStartStopOneStep = TestEnvironment.storeTimerData(ID_TIMER_START_FINISH);
    TestEnvironment.notice("should be approx. 2000 (vs. real time " + timeStartStopOneStep + ")");

    // start and stop in two steps
    start = System.currentTimeMillis();
    startProcessing();
    endProcessing();
    end = System.currentTimeMillis();
    timeStartStopTwoSteps = end - start;
    recIdStartStopTwoSteps = TestEnvironment.storeTimerData(ID_TIMER_START_FINISH2);
    TestEnvironment.notice("should be approx. 2000 (vs. real time " + timeStartStopTwoSteps + ")");

    // restart, stop and resume in two steps
    start = System.currentTimeMillis();
    startProcessing();
    interruptProcessing();
    continueProcessing();
    endProcessing();
    end = System.currentTimeMillis();
    timeRestartStopResumeTwoSteps = end - start;
    recIdRestartStopResumeTwoSteps = TestEnvironment.storeTimerData(ID_TIMER_START_FINISH2);
    TestEnvironment.notice(
        "should be approx. 2000 (vs. real time " + timeRestartStopResumeTwoSteps + ")");

    // restart and stop and resume in one step
    start = System.currentTimeMillis();
    startProcessing();
    interruptAndContinueProcessing();
    endProcessing();
    end = System.currentTimeMillis();
    timeRestartStopResumeOneStep = end - start;
    recIdRestartStopResumeOneStep = TestEnvironment.storeTimerData(ID_TIMER_START_FINISH2);
    TestEnvironment.notice(
        "should be approx. 2000 (vs. real time " + timeRestartStopResumeOneStep + ")");
  }
Пример #3
0
 /**
  * Starts the test.
  *
  * @param args ignored
  * @since 1.00
  */
 @StartSystem
 @EndSystem(invoke = "asserts")
 public static void main(String[] args) {
   TestEnvironment.notice(ThreadedTest.class.getName());
   if (args.length > 0) {
     if (args[0].equals("continue")) {
       for (int i = 0; i < 15; i++) {
         execute();
       }
     } else {
       System.out.println("invalid parameter: " + args[0]);
     }
   } else {
     execute();
     /*            try {
         Thread.sleep(1000);
     } catch (InterruptedException e) {
     }*/
   }
   TestEnvironment.notice("------------------ done: ThreadedTest");
 }
Пример #4
0
 /**
  * Starts the test.
  *
  * @param args command line arguments (ignored)
  * @since 1.00
  */
 @StartSystem
 @EndSystem(invoke = "asserts")
 public static void main(String[] args) {
   TestEnvironment.initialize(); // explicit due to events
   TestEnvironment.notice(TimerTest.class.getName());
   if (args.length > 0) {
     if (args[0].equals("continue")) {
       for (int i = 0; i < 15; i++) {
         execute();
         try {
           Thread.sleep(2000);
         } catch (InterruptedException e) {
           e.printStackTrace();
         }
       }
     } else {
       System.out.println("invalid parameter: " + args[0]);
     }
   } else {
     execute();
   }
   TestEnvironment.notice("------------------ done: TimerTest");
 }