KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > zeus > util > ArgumentsTest


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  */

19 package org.enhydra.zeus.util;
20
21 import junit.framework.Test;
22 import junit.framework.TestCase;
23 import junit.framework.TestSuite;
24
25 /**
26  * <p>
27  * This is a test case for the <code>{@link ArgumentsTest}</code> class.
28  * </p>
29  *
30  * @author Brooke Hedrick
31  * @author Brett McLaughlin
32  */

33 public class ArgumentsTest extends TestCase {
34         
35     /**
36      * <p>
37      * This constructs a new <code>ArgumentsTest</code>.
38      * </p>
39      *
40      * @param name the name of the test case.
41      */

42     public ArgumentsTest(String JavaDoc name) {
43         super(name);
44     }
45
46     /**
47      * <p>
48      * This method maeks it easier to call these
49      * tests dynamically.
50      * </p>
51      *
52      * @return <code>TestSuite</code> - corresponds to this
53      * <code>TestCase</code>.
54      */

55     public static Test suite(){
56         return new TestSuite(ArgumentsTest.class);
57     }
58
59     /**
60      * <p>
61      * This tests the default constructor for the
62      * <code>{@link Arguments}</code> class.
63      * </p>
64      */

65     public void testNoParameterConstructor() {
66         Arguments arguments = new Arguments();
67         assertTrue(arguments != null);
68     }
69
70     /**
71      * <p>
72      * This tests the constructor
73      * <code>{@link Arguments(String[] args)}</code>.
74      * </p>
75      */

76     public void testStringArrayConstructor() {
77         String JavaDoc[] args =
78             new String JavaDoc[] {"-file=/usr/src/dtd/song.dtd","-quiet=true"};
79             
80         Arguments arguments = new Arguments(args);
81         
82         String JavaDoc expected = "/usr/src/dtd/song.dtd";
83         assertEquals(arguments.getValue("file"), expected);
84
85         expected = "true";
86         assertEquals(arguments.getValue("quiet"), expected);
87     }
88
89     /**
90      * <p>
91      * This tests the <code>{@link Arguments#setValue}</code> method.
92      * </p>
93      */

94     public void testSetValue() {
95         Arguments arguments = new Arguments();
96         
97         String JavaDoc expected = "value1";
98         arguments.setValue("argument1", expected);
99         assertEquals(arguments.getValue("argument1"), expected);
100         
101         expected = "value2";
102         arguments.setValue("argument2", expected);
103         assertEquals(arguments.getValue("argument2"), expected);
104     }
105     
106     /**
107      * <p>
108      * This tests the <code>{@link Arguments#getValue}</code> method.
109      * </p>
110      */

111     public void testGetValue() {
112         Arguments arguments = new Arguments();
113         
114         String JavaDoc expected = "testValue";
115         arguments.setValue("testArgument", expected);
116         assertEquals(arguments.getValue("testArgument"), expected);
117     }
118
119     /**
120      * <p>
121      * This tests the <code>{@link Arguments#hasValue}</code> method.
122      * </p>
123      */

124     public void testHasValue() {
125         Arguments arguments = new Arguments();
126         
127         arguments.setValue("testArgument", "testValue");
128     
129         assertTrue(arguments.hasValue("testArgument"));
130         assertTrue(!arguments.hasValue("missingArgument"));
131     }
132
133     /**
134      * <p>
135      * This tests the <code>{@link Arguments#setValues}</code> method.
136      * </p>
137      */

138     public void testSetValues() {
139         String JavaDoc[] args =
140             new String JavaDoc[] {"-file=/usr/src/dtd/song.dtd","-quiet=true"};
141             
142         Arguments arguments = new Arguments();
143         arguments.setValues(args);
144         
145         String JavaDoc expected = "/usr/src/dtd/song.dtd";
146         assertEquals(arguments.getValue("file"), expected);
147
148         expected = "true";
149         assertEquals(arguments.getValue("quiet"), expected);
150     }
151 }
152
153
Popular Tags