@Test
 public void testSetAction() {
   Action localAction = EasyMock.createMock(Action.class);
   EasyMock.replay(localAction);
   injecter.setAction(localAction);
   EasyMock.verify(localAction);
 }
 @Test
 public void testSetClassResource() {
   ClassResource cr = EasyMock.createMock(ClassResource.class);
   EasyMock.replay(cr);
   injecter.setClassResource(cr);
   EasyMock.verify(cr);
 }
  @Test
  public void testInject_mnemonic() {
    initializeInjecter();
    injecter.inject();

    Object mnemonicValue = action.getValue(Action.MNEMONIC_KEY);
    assertEquals(new Integer(KeyEvent.VK_A), mnemonicValue);
  }
  @Test
  public void testInject_accelerator() {
    initializeInjecter();
    injecter.inject();

    Object keystrokeValue = action.getValue(Action.ACCELERATOR_KEY);
    assertEquals(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK), keystrokeValue);
  }
  @Test
  public void testInject_longDescription() {
    initializeInjecter();
    injecter.inject();

    Object longDescValue = action.getValue(Action.LONG_DESCRIPTION);
    assertEquals("A very long description of action1", longDescValue);
  }
  @Test
  public void testInject_shortDescription() {
    initializeInjecter();
    injecter.inject();

    Object shortDescValue = action.getValue(Action.SHORT_DESCRIPTION);
    assertEquals("Short description of action1", shortDescValue);
  }
  @Test
  public void testInject_Name() {
    initializeInjecter();
    injecter.inject();

    Object nameValue = action.getValue(Action.NAME);
    assertEquals("Name1", nameValue);
  }
  @Test
  public void testInject_largeIcon() {
    initializeInjecter();
    injecter.inject();

    Object largeIconValue = action.getValue(Action.LARGE_ICON_KEY);
    assertNotNull(largeIconValue);
    assertTrue(Icon.class.isAssignableFrom(largeIconValue.getClass()));
  }
  @Test
  public void testInject_smallIcon() {
    initializeInjecter();
    injecter.inject();

    Object smallIconValue = action.getValue(Action.SMALL_ICON);
    assertNotNull(smallIconValue);
    assertTrue(Icon.class.isAssignableFrom(smallIconValue.getClass()));
  }
Example #10
0
 @Test
 public void testSetActionKey() {
   injecter.setActionKey("action.key");
 }
Example #11
0
 @Test(expected = NullPointerException.class)
 public void testSetAction_nullArg() {
   injecter.setAction(null);
 }
Example #12
0
 @Test(expected = NullPointerException.class)
 public void testSetClassResource_nullArg() {
   injecter.setClassResource(null);
 }
Example #13
0
 private void initializeInjecter() {
   injecter.setClassResource(sampleRes);
   injecter.setAction(action);
   injecter.setActionKey("doAction1");
 }
Example #14
0
 @Test(expected = IllegalArgumentException.class)
 public void testSetActionKey_emptyArg() {
   injecter.setActionKey("");
 }