View Javadoc

1   /*
2    * $Id: UnitTestExceptionStrategy.java 19651 2010-09-14 15:22:50Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.transport.soap.axis;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.MuleMessage;
15  import org.mule.exception.DefaultServiceExceptionStrategy;
16  
17  import java.util.ArrayList;
18  import java.util.List;
19  
20  public class UnitTestExceptionStrategy extends DefaultServiceExceptionStrategy
21  {
22      /**
23       * Record all exceptions that this ExceptionStrategy handles so Unit Test
24       * can query them and make their assertions.
25       */
26      private List<Throwable> messagingExceptions = null;
27      
28      public UnitTestExceptionStrategy(MuleContext context)
29      {
30          super(context);
31          messagingExceptions = new ArrayList<Throwable>();
32      }
33      
34      @Override
35      protected void logFatal(MuleMessage message, Throwable t)
36      {
37          logger.debug("logFatal", t);
38      }
39  
40      @Override
41      protected void logException(Throwable t)
42      {
43          logger.debug("logException", t);
44      }
45  
46      @Override
47      public void handleMessagingException(MuleMessage message, Throwable t)
48      {
49          messagingExceptions.add(t);
50          super.handleMessagingException(message, t);
51      }
52      
53      public List<Throwable> getMessagingExceptions()
54      {
55          return messagingExceptions;
56      }
57  }
58  
59