Created
October 20, 2008 22:20
-
-
Save redsquirrel/18196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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