KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > error > test > BasicErrorTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.error.test;
8
9
10 import java.util.Locale JavaDoc;
11
12 import junit.framework.TestCase;
13
14 import com.inversoft.error.BasicError;
15
16
17 /**
18  * <p>
19  * Tests the BasicError class
20  * </p>
21  *
22  * @author Brian Pontarelli
23  * @since 2.0
24  * @version 2.0
25  */

26 public class BasicErrorTest extends TestCase {
27
28     /**
29      * Constructs a new <code>BasicErrorTest</code>
30      *
31      * @param name The name of the test case currently being run
32      */

33     public BasicErrorTest(String JavaDoc name) {
34         super(name);
35     }
36
37
38     /**
39      * Test everything.
40      */

41     public void testAll() {
42         Object JavaDoc[] params = {"foo", "bar"};
43         BasicError be = new BasicError("The message param1 is {0} and param2 is {1}", params);
44         assertEquals("The message should be formatted",
45             "The message param1 is foo and param2 is bar", be.getMessage());
46
47         be = new BasicError();
48         assertNull(be.getMessage());
49         assertNull(be.getLocale());
50         assertNull(be.toString());
51
52         be.setMessage("message");
53         assertEquals("message", be.getMessage());
54         assertEquals("message", be.toString());
55
56         be = new BasicError("message", new Locale JavaDoc("fr"));
57         assertEquals("message", be.getMessage());
58         assertEquals("fr", be.getLocale().getLanguage());
59
60         be = new BasicError("The message param1 is {0} and param2 is {1}", params,
61             new Locale JavaDoc("fr"));
62         assertEquals("The message should be formatted",
63             "The message param1 is foo and param2 is bar", be.getMessage());
64         assertEquals("fr", be.getLocale().getLanguage());
65     }
66 }
Popular Tags