/** Test action is disabled for an object. */ public void testWithObject() { OurExplorerContext ec = new OurExplorerContext(); ec.component = new Object(); JobAction test = new StopAction(); test.setSelectedContext(ec); test.prepare(); assertFalse(test.isEnabled()); }
/** Test that performing the action works. */ public void testPerform() throws Exception { class MyS implements Stoppable { boolean stopped = false; public void stop() { stopped = true; } } MyS sample = new MyS(); OurExplorerContext ec = new OurExplorerContext(); ec.component = sample; JobAction test = new StopAction(); test.setSelectedContext(ec); assertTrue(test.isEnabled()); test.action(); assertTrue(sample.stopped); }