39
39
import java .util .Arrays ;
40
40
import java .util .Iterator ;
41
41
42
+ import org .junit .After ;
42
43
import org .junit .Before ;
43
44
import org .junit .Test ;
44
45
import org .scijava .Context ;
45
46
import org .scijava .command .CommandInfoTest .CommandWithEnumParam .Choice ;
47
+ import org .scijava .log .LogService ;
46
48
import org .scijava .module .ModuleItem ;
47
49
import org .scijava .plugin .Parameter ;
48
50
53
55
*/
54
56
public class CommandInfoTest {
55
57
58
+ private Context ctx ;
56
59
private CommandService commandService ;
57
60
58
61
@ Before
59
62
public void setUp () {
60
- final Context ctx = new Context (CommandService .class );
63
+ ctx = new Context (CommandService .class );
61
64
commandService = ctx .getService (CommandService .class );
62
65
}
63
66
67
+ @ After
68
+ public void tearDown () {
69
+ ctx .dispose ();
70
+ }
71
+
64
72
@ Test
65
73
public void testEnumParam () {
66
74
final CommandInfo info = commandService .getCommand (
@@ -88,6 +96,12 @@ public void testEnumParam() {
88
96
choice .getChoices ());
89
97
}
90
98
99
+ @ Test
100
+ public void testDuplicateServiceParameters () {
101
+ CommandInfo commandInfo = new CommandInfo (ExtendedServiceCommand .class );
102
+ assertTrue (commandInfo .isValid ());
103
+ }
104
+
91
105
// -- Helper classes --
92
106
93
107
/** A command with an enum parameter. */
@@ -112,4 +126,26 @@ public void run() {
112
126
// NB: No implementation needed.
113
127
}
114
128
}
129
+
130
+ private static class ServiceCommand implements Command {
131
+
132
+ @ Parameter
133
+ private LogService logService ;
134
+
135
+ @ Override
136
+ public void run () {
137
+ // do nothing
138
+ }
139
+ }
140
+
141
+ private static class ExtendedServiceCommand extends ServiceCommand {
142
+
143
+ @ Parameter
144
+ private LogService logService ;
145
+
146
+ @ Override
147
+ public void run () {
148
+ // do nothing
149
+ }
150
+ }
115
151
}
0 commit comments