1
2
3
4
5
6
7 package org.mule.test.config;
8
9 import org.mule.config.i18n.CoreMessages;
10 import org.mule.config.i18n.Message;
11 import org.mule.tck.junit4.AbstractMuleTestCase;
12
13 import java.util.MissingResourceException;
14
15 import org.junit.Test;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertTrue;
19 import static org.junit.Assert.fail;
20
21 public class MessagesTestCase extends AbstractMuleTestCase
22 {
23
24 @Test
25 public void testMessageLoading() throws Exception
26 {
27 Message message = CoreMessages.authFailedForUser("Fred");
28 assertEquals("Authentication failed for principal Fred", message.getMessage());
29 assertEquals(135, message.getCode());
30 }
31
32 @Test
33 public void testBadBundle()
34 {
35 try
36 {
37 InvalidMessageFactory.getInvalidMessage();
38 fail("should throw resource bundle not found exception");
39 }
40 catch (MissingResourceException e)
41 {
42
43
44 assertTrue(e.getMessage().matches(".*Can't find.*bundle.*"));
45 }
46 }
47
48 @Test
49 public void testGoodBundle()
50 {
51 Message message = TestMessages.testMessage("one", "two", "three");
52 assertEquals("Testing, Testing, one, two, three", message.getMessage());
53 assertEquals(1, message.getCode());
54 }
55 }