KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > cli > BuildTest


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE file.
7  *
8  * $Id: BuildTest.java,v 1.1 2001/12/19 18:16:25 jstrachan Exp $
9  */

10
11 package org.apache.commons.cli;
12
13 import junit.framework.Test;
14 import junit.framework.TestCase;
15 import junit.framework.TestSuite;
16
17 public class BuildTest extends TestCase
18 {
19
20     public static Test suite() {
21         return new TestSuite(BuildTest.class);
22     }
23
24     public BuildTest(String JavaDoc name)
25     {
26         super(name);
27     }
28
29     public void setUp()
30     {
31
32     }
33
34     public void tearDown()
35     {
36
37     }
38
39     public void testSimple()
40     {
41         Options opts = new Options();
42         
43         opts.addOption("a",
44                        false,
45                        "toggle -a");
46
47         opts.addOption("b",
48                        true,
49                        "toggle -b");
50     }
51
52     public void testDuplicateSimple()
53     {
54         Options opts = new Options();
55         opts.addOption("a",
56                        false,
57                        "toggle -a");
58
59         opts.addOption("a",
60                        true,
61                        "toggle -a*");
62         
63         assertEquals( "last one in wins", "toggle -a*", opts.getOption("a").getDescription() );
64     }
65
66     public void testLong()
67     {
68         Options opts = new Options();
69         
70         opts.addOption("a",
71                        "--a",
72                        false,
73                        "toggle -a");
74
75         opts.addOption("b",
76                        "--b",
77                        true,
78                        "set -b");
79
80     }
81
82     public void testDuplicateLong()
83     {
84         Options opts = new Options();
85         opts.addOption("a",
86                        "--a",
87                        false,
88                        "toggle -a");
89
90         opts.addOption("a",
91                        "--a",
92                        false,
93                        "toggle -a*");
94         assertEquals( "last one in wins", "toggle -a*", opts.getOption("a").getDescription() );
95     }
96 }
97
Popular Tags