1 17 package org.alfresco.error; 18 19 import java.util.Locale ; 20 21 import junit.framework.TestCase; 22 23 import org.alfresco.i18n.I18NUtil; 24 25 30 public class AlfrescoRuntimeExceptionTest extends TestCase 31 { 32 private static final String BASE_RESOURCE_NAME = "org.alfresco.i18n.testMessages"; 33 private static final String PARAM_VALUE = "television"; 34 private static final String MSG_PARAMS = "msg_params"; 35 private static final String MSG_ERROR = "msg_error"; 36 private static final String VALUE_ERROR = "This is an error message. \n This is on a new line."; 37 private static final String VALUE_FR_ERROR = "C'est un message d'erreur. \n C'est sur une nouvelle ligne."; 38 private static final String VALUE_PARAMS = "What no " + PARAM_VALUE + "?"; 39 private static final String VALUE_FR_PARAMS = "Que non " + PARAM_VALUE + "?"; 40 private static final String NON_I18NED_MSG = "This is a non i18ned error message."; 41 42 @Override 43 protected void setUp() throws Exception 44 { 45 I18NUtil.setLocale(Locale.getDefault()); 47 } 48 49 public void testI18NBehaviour() 50 { 51 I18NUtil.registerResourceBundle(BASE_RESOURCE_NAME); 53 54 AlfrescoRuntimeException exception1 = new AlfrescoRuntimeException(MSG_PARAMS, new Object []{PARAM_VALUE}); 55 assertEquals(VALUE_PARAMS, exception1.getMessage()); 56 AlfrescoRuntimeException exception3 = new AlfrescoRuntimeException(MSG_ERROR); 57 assertEquals(VALUE_ERROR, exception3.getMessage()); 58 59 I18NUtil.setLocale(new Locale ("fr", "FR")); 61 62 AlfrescoRuntimeException exception2 = new AlfrescoRuntimeException(MSG_PARAMS, new Object []{PARAM_VALUE}); 63 assertEquals(VALUE_FR_PARAMS, exception2.getMessage()); 64 AlfrescoRuntimeException exception4 = new AlfrescoRuntimeException(MSG_ERROR); 65 assertEquals(VALUE_FR_ERROR, exception4.getMessage()); 66 67 AlfrescoRuntimeException exception5 = new AlfrescoRuntimeException(NON_I18NED_MSG); 68 assertEquals(NON_I18NED_MSG, exception5.getMessage()); 69 } 70 } 71 | Popular Tags |