1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.richclient.command.config;
17
18 import javax.swing.JButton;
19
20 import junit.framework.TestCase;
21
22 import org.springframework.richclient.image.EmptyIcon;
23
24
25
26
27
28
29
30 public abstract class CommandButtonConfigurerTestCase extends TestCase {
31
32 private CommandButtonConfigurer configurer;
33
34 private CommandFaceDescriptor descriptor;
35
36 public final void testConfigureWithNullDescriptor() {
37 try {
38 configurer.configure(new JButton(), null, null);
39 fail("Should throw IllegalArgumentException");
40 }
41 catch (IllegalArgumentException e) {
42 pass();
43 }
44 }
45
46 public final void testConfigureWithNullButton() {
47 try {
48 configurer.configure(null, null, descriptor);
49 fail("Should throw IllegalArgumentException");
50 }
51 catch (IllegalArgumentException e) {
52 pass();
53 }
54 }
55
56 private static void pass() {
57
58 }
59
60 protected final void setUp() throws Exception {
61 configurer = createConfigurer();
62 assertNotNull("Configurer cannot be null", configurer);
63
64 descriptor = new CommandFaceDescriptor();
65 CommandButtonIconInfo iconInfo = new CommandButtonIconInfo(EmptyIcon.SMALL);
66 CommandButtonLabelInfo labelInfo = CommandButtonLabelInfo.valueOf("test");
67 descriptor.setIconInfo(iconInfo);
68 descriptor.setLabelInfo(labelInfo);
69 descriptor.setCaption("Tool tip");
70 }
71
72 protected final CommandFaceDescriptor getCommandFaceDescriptor() {
73 return descriptor;
74 }
75
76 protected abstract CommandButtonConfigurer createConfigurer();
77 }