View Javadoc

1   /*
2    * $Id: ExceptionListenerTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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;
12  
13  import org.mule.api.endpoint.OutboundEndpoint;
14  import org.mule.exception.AbstractExceptionListener;
15  import org.mule.exception.DefaultServiceExceptionStrategy;
16  import org.mule.tck.AbstractMuleTestCase;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  public class ExceptionListenerTestCase extends AbstractMuleTestCase
22  {
23      public void testAddGoodEndpoint() throws Exception
24      {
25          AbstractExceptionListener router = new DefaultServiceExceptionStrategy(muleContext);
26          OutboundEndpoint endpoint = getTestOutboundEndpoint("test");
27          router.addEndpoint(endpoint);
28          assertNotNull(router.getMessageProcessors());
29          assertTrue(router.getMessageProcessors().contains(endpoint));
30      }
31  
32      public void testSetGoodEndpoints() throws Exception
33      {
34          List<OutboundEndpoint> list = new ArrayList<OutboundEndpoint>();
35          list.add(getTestOutboundEndpoint("test"));
36          list.add(getTestOutboundEndpoint("test"));
37          
38          AbstractExceptionListener router = new DefaultServiceExceptionStrategy(muleContext);
39          assertNotNull(router.getMessageProcessors());
40          assertEquals(0, router.getMessageProcessors().size());
41          
42          router.addEndpoint(getTestOutboundEndpoint("test"));
43          assertEquals(1, router.getMessageProcessors().size());
44          
45          router.setMessageProcessors(list);
46          assertNotNull(router.getMessageProcessors());
47          assertEquals(2, router.getMessageProcessors().size());
48      }
49  }