View Javadoc

1   /*
2    * $Id: ExceptionListenerTestCase.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;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertNotNull;
15  import static org.junit.Assert.assertTrue;
16  
17  import org.mule.api.endpoint.OutboundEndpoint;
18  import org.mule.api.processor.MessageProcessor;
19  import org.mule.exception.AbstractExceptionStrategy;
20  import org.mule.exception.DefaultMessagingExceptionStrategy;
21  import org.mule.tck.junit4.AbstractMuleContextTestCase;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.junit.Test;
27  
28  public class ExceptionListenerTestCase extends AbstractMuleContextTestCase
29  {
30      @Test
31      public void testAddGoodEndpoint() throws Exception
32      {
33          AbstractExceptionStrategy router = new DefaultMessagingExceptionStrategy(muleContext);
34          OutboundEndpoint endpoint = getTestOutboundEndpoint("test");
35          router.addEndpoint(endpoint);
36          assertNotNull(router.getMessageProcessors());
37          assertTrue(router.getMessageProcessors().contains(endpoint));
38      }
39  
40      @Test
41      public void testSetGoodEndpoints() throws Exception
42      {
43          List<MessageProcessor> list = new ArrayList<MessageProcessor>();
44          list.add(getTestOutboundEndpoint("test"));
45          list.add(getTestOutboundEndpoint("test"));
46          
47          AbstractExceptionStrategy router = new DefaultMessagingExceptionStrategy(muleContext);
48          assertNotNull(router.getMessageProcessors());
49          assertEquals(0, router.getMessageProcessors().size());
50          
51          router.addEndpoint(getTestOutboundEndpoint("test"));
52          assertEquals(1, router.getMessageProcessors().size());
53          
54          router.setMessageProcessors(list);
55          assertNotNull(router.getMessageProcessors());
56          assertEquals(2, router.getMessageProcessors().size());
57      }
58  }