KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > action > TestActionMessage


1 /*
2  * $Id: TestActionMessage.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 2002-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.struts.action;
20
21 import junit.framework.Test;
22 import junit.framework.TestCase;
23 import junit.framework.TestSuite;
24
25 /**
26  * Unit tests for the <code>org.apache.struts.action.ActionMessage</code> class.
27  *
28  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
29  */

30 public class TestActionMessage extends TestCase {
31     
32     protected ActionMessage amWithNoValue = null;
33     
34     protected ActionMessage amWithOneValue = null;
35     
36     /**
37      * Defines the testcase name for JUnit.
38      *
39      * @param theName the testcase's name.
40      */

41     public TestActionMessage(String JavaDoc theName) {
42         super(theName);
43     }
44
45     /**
46      * Start the tests.
47      *
48      * @param theArgs the arguments. Not used
49      */

50     public static void main(String JavaDoc[] theArgs) {
51         junit.awtui.TestRunner.main(
52             new String JavaDoc[] { TestActionMessage.class.getName()});
53     }
54
55     /**
56      * @return a test suite (<code>TestSuite</code>) that includes all methods
57      * starting with "test"
58      */

59     public static Test suite() {
60         // All methods starting with "test" will be executed in the test suite.
61
return new TestSuite(TestActionMessage.class);
62     }
63
64     public void setUp() {
65         amWithNoValue = new ActionMessage("amWithNoValue");
66         amWithOneValue =
67             new ActionMessage("amWithOneValue", new String JavaDoc("stringValue"));
68     }
69
70     public void tearDown() {
71         amWithNoValue = null;
72     }
73     
74     public void testActionMessageWithNoValue() {
75         assertTrue(amWithNoValue.getValues() == null);
76         assertTrue(amWithNoValue.getKey() == "amWithNoValue");
77     }
78
79     public void testActionMessageWithAStringValue() {
80         Object JavaDoc[] values = amWithOneValue.getValues();
81         assertTrue(values != null);
82         assertTrue(values[0].equals("stringValue"));
83         assertTrue(amWithOneValue.getKey() == "amWithOneValue");
84     }
85 }
86
Popular Tags