Skip to content

Instantly share code, notes, and snippets.

@redsquirrel
Created October 20, 2008 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redsquirrel/18195 to your computer and use it in GitHub Desktop.
Save redsquirrel/18195 to your computer and use it in GitHub Desktop.
import org.junit.Test;
import static org.junit.Assert.*;
public class WatcherTest {
@Test
public void testJavaVersion() {
assertEquals("1.5.0_16", System.getProperty("java.version"));
}
@Test
public void testStartTask() throws InterruptedException {
Worker task = new Worker();
assertEquals(0, task.getIdleMillis());
Thread.sleep(1000);
assertEquals(0, task.getIdleMillis());
//start worker
Thread thread = new Thread(task);
thread.start();
Thread.sleep(1000);
assertTrue(task.getIdleMillis() > 0);
assertTrue(task.getIdleMillis() < 100);
System.out.println(task.getIdleMillis());
thread.join();
assertTrue(task.getIdleMillis() != 0);
// if worker status is negative, then kill and restart new
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment