1 7 package com.inversoft.error.test; 8 9 10 import java.util.Locale ; 11 12 import junit.framework.TestCase; 13 14 import com.inversoft.error.BasicError; 15 16 17 26 public class BasicErrorTest extends TestCase { 27 28 33 public BasicErrorTest(String name) { 34 super(name); 35 } 36 37 38 41 public void testAll() { 42 Object [] 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 ("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 ("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 |