View Javadoc

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