1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.richclient.command;
17
18 import javax.swing.JButton;
19
20 import junit.framework.TestCase;
21
22
23
24
25
26
27 public class ActionCommandTests extends TestCase {
28
29 public void testOnButtonAttached() {
30 final boolean[] executed = { false };
31
32 ActionCommand command = new ActionCommand() {
33 protected void doExecuteCommand() {
34 executed[0] = true;
35 }
36 };
37 command.setActionCommand("theActionCommand");
38
39 JButton button = new JButton("test");
40
41 command.onButtonAttached(button);
42
43 assertEquals("theActionCommand", button.getActionCommand());
44
45 button.doClick();
46 assertTrue(executed[0]);
47 }
48
49 public void testOnButtonAttachedWithDisplayDialog() {
50 ActionCommand command = new ActionCommand() {
51 protected void doExecuteCommand() {
52
53 }
54 };
55 command.setDisplaysInputDialog(true);
56
57 JButton button = new JButton();
58 button.setText(null);
59
60 command.onButtonAttached(button);
61
62 assertEquals(null, button.getText());
63 }
64
65 }