3939import java .util .Arrays ;
4040import java .util .Iterator ;
4141
42+ import org .junit .After ;
4243import org .junit .Before ;
4344import org .junit .Test ;
4445import org .scijava .Context ;
4546import org .scijava .command .CommandInfoTest .CommandWithEnumParam .Choice ;
47+ import org .scijava .log .LogService ;
4648import org .scijava .module .ModuleItem ;
4749import org .scijava .plugin .Parameter ;
4850
5355 */
5456public class CommandInfoTest {
5557
58+ private Context ctx ;
5659 private CommandService commandService ;
5760
5861 @ Before
5962 public void setUp () {
60- final Context ctx = new Context (CommandService .class );
63+ ctx = new Context (CommandService .class );
6164 commandService = ctx .getService (CommandService .class );
6265 }
6366
67+ @ After
68+ public void tearDown () {
69+ ctx .dispose ();
70+ }
71+
6472 @ Test
6573 public void testEnumParam () {
6674 final CommandInfo info = commandService .getCommand (
@@ -88,6 +96,12 @@ public void testEnumParam() {
8896 choice .getChoices ());
8997 }
9098
99+ @ Test
100+ public void testDuplicateServiceParameters () {
101+ CommandInfo commandInfo = new CommandInfo (ExtendedServiceCommand .class );
102+ assertTrue (commandInfo .isValid ());
103+ }
104+
91105 // -- Helper classes --
92106
93107 /** A command with an enum parameter. */
@@ -112,4 +126,26 @@ public void run() {
112126 // NB: No implementation needed.
113127 }
114128 }
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+ }
115151}
0 commit comments