@Test
public void testWaitIfPaused() throws InterruptedException, CruiseControlException {

    MockProject mockProject = new MockProject() {
        private static final long serialVersionUID = 4815988988116502160L;
        public void run() {
            loop();
        }
        void checkWait() throws InterruptedException {
            waitIfPaused();
        }
    };
    projectConfig.add(new MockSchedule());
    mockProject.setProjectConfig(projectConfig);
    mockProject.init();
    new Thread(mockProject).start();
    int firstLoopCount = mockProject.getLoopCount();
    Thread.sleep(100);
    int secondLoopCount = mockProject.getLoopCount();
    assertTrue("loop counts should have been different when not paused",
               firstLoopCount != secondLoopCount);
    mockProject.setPaused(true);
    Thread.sleep(100);
    firstLoopCount = mockProject.getLoopCount();
    Thread.sleep(100);
    secondLoopCount = mockProject.getLoopCount();
    assertEquals("loop counts should be same when paused", firstLoopCount, secondLoopCount);
    mockProject.setPaused(false);
    Thread.sleep(100);
    int lastLoopCount = mockProject.getLoopCount();
    assertTrue("loop count increased after pause ended", lastLoopCount > secondLoopCount);
    mockProject.stopLooping();
}