KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > validator > ErrorMessagesTest


1 /*
2  * ErrorMessagesTest.java
3  * JUnit based test
4  *
5  * Created on June 9, 2005, 10:53 AM
6  */

7
8 package org.sapia.validator;
9
10 import junit.framework.*;
11 import java.util.Locale JavaDoc;
12
13 /**
14  *
15  * @author yduchesne
16  */

17 public class ErrorMessagesTest extends TestCase {
18   
19   
20   public ErrorMessagesTest(String JavaDoc testName) {
21     super(testName);
22   }
23
24   protected void setUp() throws Exception JavaDoc {
25   }
26
27   protected void tearDown() throws Exception JavaDoc {
28   }
29
30   public void testGetErrorMessageFor() {
31     ErrorMessages msgs = new ErrorMessages();
32     ErrorMessage m;
33
34     m = new ErrorMessage();
35     m.setLocale("fr");
36     m.setValue("french");
37     msgs.addErrorMessage(m);
38
39     m = new ErrorMessage();
40     m.setLocale("en");
41     m.setValue("english");
42     msgs.addErrorMessage(m);
43
44     m = new ErrorMessage();
45     m.setValue("default");
46     msgs.addErrorMessage(m);
47
48     super.assertEquals("english", msgs.getErrorMessageFor(Locale.US).getValue());
49     super.assertEquals("english", msgs.getErrorMessageFor("en/US/alabama").getValue());
50     super.assertEquals("english", msgs.getErrorMessageFor("en/US").getValue());
51     super.assertEquals("english", msgs.getErrorMessageFor("en").getValue());
52     super.assertEquals("french", msgs.getErrorMessageFor("fr").getValue());
53     super.assertEquals("default", msgs.getErrorMessageFor("es").getValue());
54   }
55   
56 }
57
Popular Tags