1 4 package org.oddjob.monitor.action; 5 6 import junit.framework.TestCase; 7 8 import org.apache.log4j.Logger; 9 import org.oddjob.Resetable; 10 import org.oddjob.monitor.model.ExplorerContext; 11 import org.oddjob.monitor.model.ExplorerModel; 12 import org.oddjob.monitor.model.JobAction; 13 import org.oddjob.util.ThreadManager; 14 15 public class HardResetActionTest extends TestCase { 16 private static final Logger logger = Logger.getLogger(HardResetActionTest.class); 17 18 22 public void testPerform() throws Exception { 23 class MyR implements Resetable { 24 boolean reset = false; 25 public void softReset() { 26 } 27 public void hardReset() { 28 reset = true; 29 } 30 } 31 MyR sample = new MyR(); 32 33 ExplorerModel em = new ExplorerModel(); 34 em.setRoot(sample); 35 ThreadManager tm = new ThreadManager(); 36 em.setThreadManager(tm); 37 ExplorerContext ec = new ExplorerContext(em); 38 39 JobAction test = new HardResetAction(); 40 test.optionSelect(sample, ec); 41 42 test.action(); 43 44 while (tm.activeDescriptions().length > 0) { 45 logger.debug("Waiting for ThreadManager."); 46 Thread.yield(); 47 } 48 assertTrue(sample.reset); 49 } 50 51 55 public void testWithObject() { 56 JobAction test = new HardResetAction(); 57 test.optionSelect(new Object (), null); 58 assertFalse(test.enabled()); 59 } 60 61 } 62 | Popular Tags |