示例#1
0
  /** 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());
  }
示例#2
0
  /** 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);
  }