11package fi .helsinki .cs .tmc .cli .core ;
22
3+ import static org .junit .Assert .assertEquals ;
34import static org .junit .Assert .assertNotNull ;
5+ import static org .junit .Assert .assertNotSame ;
46import static org .junit .Assert .assertNull ;
57import static org .junit .Assert .assertTrue ;
68
79import fi .helsinki .cs .tmc .cli .Application ;
10+ import fi .helsinki .cs .tmc .cli .command .HelpCommand ;
811import fi .helsinki .cs .tmc .cli .io .TestIo ;
912
1013import org .apache .commons .cli .CommandLine ;
@@ -26,6 +29,7 @@ public class CommandFactoryTest {
2629 @ Before
2730 public void setUp () {
2831 ctx = new CliContext (new TestIo ());
32+ CommandFactory .reload ();
2933 }
3034
3135 @ Test
@@ -34,12 +38,12 @@ public void constructorAddsCommands() {
3438 }
3539
3640 @ Test
37- public void createCommandWorksWithRealCommand () {
41+ public void createHelpCommand () {
3842 assertNotNull (CommandFactory .createCommand ("help" ));
3943 }
4044
4145 @ Test
42- public void createCommandWorksWithBadCommand () {
46+ public void createNonexistingCommand () {
4347 assertNull (CommandFactory .createCommand ("foobar" ));
4448 }
4549
@@ -59,7 +63,7 @@ public void run(CliContext context, CommandLine args) {
5963
6064 @ Test
6165 public void addGoodCommand () {
62- CommandFactory .addCommand (GoodCommand .class );
66+ CommandFactory .addCommand ("category" , GoodCommand .class );
6367 //TODO check the all the stuff in the command
6468 assertNotNull (CommandFactory .createCommand ("good" ));
6569 }
@@ -82,7 +86,7 @@ public void addCommandWithoutProperAnnotation() {
8286 //WARNING The exception code leads to unpredicatble test results
8387 //exception.expect(RuntimeException.class);
8488 //exception.expectMessage(contains("annotation"));
85- CommandFactory .addCommand (BadCommand .class );
89+ CommandFactory .addCommand ("category" , BadCommand .class );
8690 }
8791
8892 private static class ReallyBadCommand {}
@@ -92,6 +96,6 @@ public void addCommandThatDoesntExtendInterface() {
9296 //WARNING The exception code leads to unpredicatble test results
9397 //exception.expect(RuntimeException.class);
9498 //exception.expectMessage(contains("Interface"));
95- CommandFactory .addCommand (ReallyBadCommand .class );
99+ CommandFactory .addCommand ("category" , ReallyBadCommand .class );
96100 }
97101}
0 commit comments