1   /*
2    * $Id: ExceptionTypeFilterTestCase.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.routing.filters;
12  
13  import org.mule.impl.MuleMessage;
14  import org.mule.impl.message.ExceptionPayload;
15  import org.mule.tck.AbstractMuleTestCase;
16  import org.mule.umo.UMOMessage;
17  
18  import java.io.IOException;
19  
20  public class ExceptionTypeFilterTestCase extends AbstractMuleTestCase
21  {
22  
23      public void testExceptionTypeFilter()
24      {
25          ExceptionTypeFilter filter = new ExceptionTypeFilter();
26          assertNull(filter.getExpectedType());
27          UMOMessage m = new MuleMessage("test");
28          assertTrue(!filter.accept(m));
29          m.setExceptionPayload(new ExceptionPayload(new IllegalArgumentException("test")));
30          assertTrue(filter.accept(m));
31  
32          filter = new ExceptionTypeFilter(IOException.class);
33          assertTrue(!filter.accept(m));
34          m.setExceptionPayload(new ExceptionPayload(new IOException("test")));
35          assertTrue(filter.accept(m));
36      }
37  
38  }