1   /*
2    * $Id: MessagesTestCase.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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.AbstractMuleTestCase;
16  
17  import java.util.MissingResourceException;
18  
19  public class MessagesTestCase extends AbstractMuleTestCase
20  {
21      public void testMessageLoading() throws Exception
22      {
23          Message message = CoreMessages.authFailedForUser("Fred");
24          assertEquals("Authentication failed for principal Fred", message.getMessage());
25          assertEquals(135, message.getCode());
26      }
27  
28      public void testBadBundle()
29      {
30          try
31          {
32              InvalidMessageFactory.getInvalidMessage();
33              fail("should throw resource bundle not found exception");
34          }
35          catch (MissingResourceException e)
36          {
37              assertTrue(e.getMessage().startsWith("Can't find bundle"));
38          }
39      }
40  
41      public void testGoodBundle()
42      {
43          Message message = TestMessages.testMessage("one", "two", "three");
44          assertEquals("Testing, Testing, one, two, three", message.getMessage());
45          assertEquals(1, message.getCode());
46      }
47  }