1   /*
2    * $Id: ExceptionsTestCase.java 7976 2007-08-21 14:26:13Z 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;
12  
13  import org.mule.config.i18n.MessageFactory;
14  import org.mule.impl.ImmutableMuleEndpoint;
15  import org.mule.tck.AbstractMuleTestCase;
16  import org.mule.umo.UMOException;
17  import org.mule.umo.endpoint.UMOImmutableEndpoint;
18  import org.mule.umo.manager.ManagerException;
19  import org.mule.umo.routing.RoutingException;
20  
21  public class ExceptionsTestCase extends AbstractMuleTestCase
22  {
23  
24      public void testExceptionChaining()
25      {
26          String rootMsg = "Root Test Exception Message";
27          String msg = "Test Exception Message";
28  
29          Exception e = new ManagerException(MessageFactory.createStaticMessage(msg), new MuleException(
30              MessageFactory.createStaticMessage(rootMsg)));
31  
32          assertEquals(rootMsg, e.getCause().getMessage());
33          assertEquals(msg, e.getMessage());
34          assertEquals(e.getClass().getName() + ": " + msg, e.toString());
35      }
36  
37      public final void testRoutingExceptionNullUMOMessageNullUMOImmutableEndpoint() throws UMOException
38      {
39          RoutingException rex = new RoutingException(null, null);
40          assertNotNull(rex);
41      }
42  
43      public final void testRoutingExceptionNullUMOMessageValidUMOImmutableEndpoint() throws UMOException
44      {
45          UMOImmutableEndpoint endpoint = new ImmutableMuleEndpoint("test://outbound", false);
46          assertNotNull(endpoint);
47  
48          RoutingException rex = new RoutingException(null, endpoint);
49          assertNotNull(rex);
50          assertSame(endpoint, rex.getEndpoint());
51      }
52  
53  }