Package com.facebook.testing

Examples of com.facebook.testing.LoopThread


    executorServiceFront.execute(task1);
    executorServiceFront.execute(task2);

    ThreadHelper threadHelper = new ThreadHelper();
    // ie, we'll want two physical threads
    LoopThread drainerThread1 = createDrainerThread(threadHelper);
    LoopThread drainerThread2 = createDrainerThread(threadHelper);
    // this waits for both tasks to get into a Drainer. Two tasks that pause immediately and
    // two drainers => we get 1 task per drainer
    while (!workQueue.isEmpty()) {
      Thread.sleep(50);
    }

    // check that the names change according to our ESF
    Assert.assertEquals(drainerThread1.getName(), "custom-name-000");
    task1.proceed();
    task1.await();
    Assert.assertEquals(drainerThread2.getName(), "custom-name-001");
    task2.proceed();
    task2.await();
    drainerThread1.join();
    drainerThread2.join();
    // and that the 'base name' of the borrowed  threads is restored
    Assert.assertEquals(drainerThread1.getName(), "drainer");
    Assert.assertEquals(drainerThread2.getName(), "drainer");
  }
View Full Code Here


    executorServiceFront.execute(task1);
    executorServiceFront.execute(task2);

    ThreadHelper threadHelper = new ThreadHelper();
    // ie, we'll want two physical threads
    LoopThread drainerThread1 = createDrainerThread(threadHelper);
    LoopThread drainerThread2 = createDrainerThread(threadHelper);
    // this waits for both tasks to get into a Drainer. Two tasks that pause immediately and
    // two drainers => we get 1 task per drainer
    while (!workQueue.isEmpty()) {
      Thread.sleep(50);
    }

    // check that the names change according to our ESF
    Assert.assertEquals(drainerThread1.getName(), "custom-name-000");
    task1.proceed();
    task1.await();
    Assert.assertEquals(drainerThread2.getName(), "custom-name-001");
    task2.proceed();
    task2.await();
    drainerThread1.join();
    drainerThread2.join();
    // and that the 'base name' of the borrowed  threads is restored
    Assert.assertEquals(drainerThread1.getName(), "drainer");
    Assert.assertEquals(drainerThread2.getName(), "drainer");
  }
View Full Code Here

TOP

Related Classes of com.facebook.testing.LoopThread

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.