View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.soap.axis;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.api.MuleEvent;
11  import org.mule.exception.DefaultServiceExceptionStrategy;
12  
13  import java.util.ArrayList;
14  import java.util.List;
15  
16  public class UnitTestExceptionStrategy extends DefaultServiceExceptionStrategy
17  {
18      /**
19       * Record all exceptions that this ExceptionStrategy handles so Unit Test
20       * can query them and make their assertions.
21       */
22      private List<Throwable> messagingExceptions = null;
23      
24      public UnitTestExceptionStrategy(MuleContext context)
25      {
26          super(context);
27          messagingExceptions = new ArrayList<Throwable>();
28      }
29      
30      @Override
31      protected void logFatal(MuleEvent event, Throwable t)
32      {
33          logger.debug("logFatal", t);
34      }
35  
36      @Override
37      protected void logException(Throwable t)
38      {
39          logger.debug("logException", t);
40      }
41  
42      @Override
43      protected void doHandleException(Exception e, MuleEvent event)
44      {
45          messagingExceptions.add(e);
46          super.doHandleException(e, event);
47      }
48      
49      public List<Throwable> getMessagingExceptions()
50      {
51          return messagingExceptions;
52      }
53  }
54  
55