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