Package com.facebook.testing

Examples of com.facebook.testing.AnnotatedRunnable


    // submit three tasks
    executorFront2.execute(slowTask);
    executorFront2.execute(countTask);
    executorFront2.execute(slowTask);
    Assert.assertEquals(mockExecutor.getNumPendingTasks(), 2);
    AnnotatedRunnable drainer2 = mockExecutor.getRunnableList().get(1);

    mockExecutor.removeHead().run();

    // Drainer1 expires after the 1st task completes,
    // and is rescheduled to the end of the pending list.
    Assert.assertEquals(mockExecutor.getNumPendingTasks(), 2);

    // Drainer2 should be on the head of the pending list   
    Assert.assertSame(drainer2, mockExecutor.getRunnableList().get(0));

    mockExecutor.removeHead().run();

    // Drainer2 expires after the 2nd and 3rd task complete.    
    AnnotatedRunnable drainer1 = mockExecutor.getRunnableList().get(0);

    // Drainer1 should be on the head of the pending list
    Assert.assertNotSame(drainer1, drainer2);

    // should have 2 slow tasks and 1 count tasks
View Full Code Here


      Thread t = TestUtils.runInThread(
        new Runnable() {
          @Override
          public void run() {
            AnnotatedRunnable drainer = mockExecutor.removeHead();

            drainer.run();
          }
        },
        "drainer"
      );
      // once the queue is empty, we know the drainer has taken the task out and is blocked on the
View Full Code Here

  private LoopThread createDrainerThread(ThreadHelper threadHelper) {
    return threadHelper.repeatInThread(
      new Runnable() {
        @Override
        public void run() {
          AnnotatedRunnable drainer = mockExecutor.removeHead();

          if (drainer != null) {
            drainer.run();
          } else {
            try {
              Thread.sleep(10);
            } catch (InterruptedException e) {
              throw new RuntimeException(e);
View Full Code Here

  private Thread createDrainerThread() {
    return TestUtils.runInThread(
      new Runnable() {
        @Override
        public void run() {
          AnnotatedRunnable drainer = mockExecutor.removeHead();

          drainer.run();
        }
      },
      "original"
    );
  }
View Full Code Here

    // submit three tasks
    executorFront2.execute(slowTask);
    executorFront2.execute(countTask);
    executorFront2.execute(slowTask);
    Assert.assertEquals(mockExecutor.getNumPendingTasks(), 2);
    AnnotatedRunnable drainer2 = mockExecutor.getRunnableList().get(1);

    mockExecutor.removeHead().run();

    // Drainer1 expires after the 1st task completes,
    // and is rescheduled to the end of the pending list.
    Assert.assertEquals(mockExecutor.getNumPendingTasks(), 2);

    // Drainer2 should be on the head of the pending list   
    Assert.assertSame(drainer2, mockExecutor.getRunnableList().get(0));

    mockExecutor.removeHead().run();

    // Drainer2 expires after the 2nd and 3rd task complete.    
    AnnotatedRunnable drainer1 = mockExecutor.getRunnableList().get(0);

    // Drainer1 should be on the head of the pending list
    Assert.assertNotSame(drainer1, drainer2);

    // should have 2 slow tasks and 1 count tasks
View Full Code Here

      Thread t = TestUtils.runInThread(
        new Runnable() {
          @Override
          public void run() {
            AnnotatedRunnable drainer = mockExecutor.removeHead();

            drainer.run();
          }
        },
        "drainer"
      );
      // once the queue is empty, we know the drainer has taken the task out and is blocked on the
View Full Code Here

  private LoopThread createDrainerThread(ThreadHelper threadHelper) {
    return threadHelper.repeatInThread(
      new Runnable() {
        @Override
        public void run() {
          AnnotatedRunnable drainer = mockExecutor.removeHead();

          if (drainer != null) {
            drainer.run();
          } else {
            try {
              Thread.sleep(10);
            } catch (InterruptedException e) {
              throw new RuntimeException(e);
View Full Code Here

  private Thread createDrainerThread() {
    return TestUtils.runInThread(
      new Runnable() {
        @Override
        public void run() {
          AnnotatedRunnable drainer = mockExecutor.removeHead();

          drainer.run();
        }
      },
      "original"
    );
  }
View Full Code Here

TOP

Related Classes of com.facebook.testing.AnnotatedRunnable

Copyright © 2018 www.massapicom. 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.