View Javadoc

1   /*
2    * $Id: UnitTestExceptionStrategy.java 22772 2011-08-27 15:20:15Z dfeist $
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.MuleEvent;
15  import org.mule.api.exception.RollbackSourceCallback;
16  import org.mule.exception.DefaultMessagingExceptionStrategy;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  public class UnitTestExceptionStrategy extends DefaultMessagingExceptionStrategy
22  {
23      /**
24       * Record all exceptions that this ExceptionStrategy handles so Unit Test
25       * can query them and make their assertions.
26       */
27      private List<Throwable> messagingExceptions = null;
28      
29      public UnitTestExceptionStrategy(MuleContext muleContext, boolean rollbackByDefault)
30      {
31          super(muleContext);
32          messagingExceptions = new ArrayList<Throwable>();
33      }
34      
35      @Override
36      protected void logFatal(MuleEvent event, Throwable t)
37      {
38          logger.debug("logFatal", t);
39      }
40  
41      @Override
42      protected void logException(Throwable t)
43      {
44          logger.debug("logException", t);
45      }
46  
47      @Override
48      protected void doHandleException(Exception e, MuleEvent event, RollbackSourceCallback rollbackMethod)
49      {
50          messagingExceptions.add(e);
51          super.doHandleException(e, event, rollbackMethod);
52      }
53      
54      public List<Throwable> getMessagingExceptions()
55      {
56          return messagingExceptions;
57      }
58  }
59  
60