コード例 #1
0
  @Test
  public void testOffMode() throws InterruptedException {
    ThreadHistoryUtility.INSTANCE.deactivate();
    for (int i = 0; i < THREADCOUNT; i++) {
      new Thread(new TestThread()).start();
    }

    Thread.currentThread().sleep(1500);

    assertEquals(0, ThreadHistoryUtility.INSTANCE.getThreadHistoryEvents().size());
  }
コード例 #2
0
  @Test
  public void testOnMode() throws InterruptedException {
    ThreadHistoryUtility.INSTANCE.activate();
    for (int i = 0; i < THREADCOUNT; i++) {
      new Thread(new TestThread()).start();
    }

    Thread.currentThread().sleep(1500);
    assertTrue(ThreadHistoryUtility.INSTANCE.getThreadHistoryEvents().size() > 0);
    int oldsize = ThreadHistoryUtility.INSTANCE.getThreadHistoryEvents().size();

    for (int i = 0; i < THREADCOUNT + 1; i++) {
      new Thread(new TestThread()).start();
    }

    Thread.currentThread().sleep(1500);
    assertTrue(oldsize < ThreadHistoryUtility.INSTANCE.getThreadHistoryEvents().size());
  }
コード例 #3
0
 @BeforeClass
 public static void setUpdate() {
   ThreadHistoryUtility.INSTANCE.setUpdateInterval(1000L);
 }