01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse;
04:
05: import junit.framework.*;
06:
07: public class ArgumentsTest extends TestCase {
08: private Arguments args;
09:
10: public void testSimpleCommandline() throws Exception {
11: args = makeArgs(new String[0]);
12: assertNotNull(args);
13: assertEquals(80, args.getPort());
14: assertEquals(".", args.getRootPath());
15: }
16:
17: private Arguments makeArgs(String[] argArray) {
18: return args = FitNesse.parseCommandLine(argArray);
19: }
20:
21: public void testArgumentsDefaults() throws Exception {
22: makeArgs(new String[] {});
23: assertEquals(80, args.getPort());
24: assertEquals(".", args.getRootPath());
25: assertEquals("FitNesseRoot", args.getRootDirectory());
26: assertEquals(null, args.getLogDirectory());
27: assertEquals(false, args.isOmittingUpdates());
28: assertEquals(14, args.getDaysTillVersionsExpire());
29: assertEquals(null, args.getUserpass());
30: }
31:
32: public void testArgumentsAlternates() throws Exception {
33: String argString = "-p 123 -d MyWd -r MyRoot -l LogDir -e 321 -o -a userpass.txt";
34: makeArgs(argString.split(" "));
35: assertEquals(123, args.getPort());
36: assertEquals("MyWd", args.getRootPath());
37: assertEquals("MyRoot", args.getRootDirectory());
38: assertEquals("LogDir", args.getLogDirectory());
39: assertEquals(true, args.isOmittingUpdates());
40: assertEquals(321, args.getDaysTillVersionsExpire());
41: assertEquals("userpass.txt", args.getUserpass());
42: }
43:
44: public void testAllArguments() throws Exception {
45: args = makeArgs(new String[] { "-p", "81", "-d", "directory",
46: "-r", "root", "-l", "myLogDirectory", "-o", "-e", "22" });
47: assertNotNull(args);
48: assertEquals(81, args.getPort());
49: assertEquals("directory", args.getRootPath());
50: assertEquals("root", args.getRootDirectory());
51: assertEquals("myLogDirectory", args.getLogDirectory());
52: assertTrue(args.isOmittingUpdates());
53: assertEquals(22, args.getDaysTillVersionsExpire());
54: }
55:
56: public void testNotOmitUpdates() throws Exception {
57: args = makeArgs(new String[] { "-p", "81", "-d", "directory",
58: "-r", "root", "-l", "myLogDirectory" });
59: assertNotNull(args);
60: assertEquals(81, args.getPort());
61: assertEquals("directory", args.getRootPath());
62: assertEquals("root", args.getRootDirectory());
63: assertEquals("myLogDirectory", args.getLogDirectory());
64: assertTrue(!args.isOmittingUpdates());
65:
66: }
67:
68: public void testBadArgument() throws Exception {
69: args = makeArgs(new String[] { "-x" });
70: assertNull(args);
71: }
72: }
|