1   /*
2    * $Id: ResponseRouterCollectionTestCase.java 11311 2008-03-10 20:15:57Z dfeist $
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.response;
12  
13  import org.mule.api.endpoint.InboundEndpoint;
14  import org.mule.api.endpoint.InvalidEndpointTypeException;
15  import org.mule.tck.AbstractMuleTestCase;
16  
17  import java.util.ArrayList;
18  import java.util.List;
19  
20  public class ResponseRouterCollectionTestCase extends AbstractMuleTestCase
21  {
22  
23      public void testAddGoodEndpoint() throws Exception
24      {
25          DefaultResponseRouterCollection router=new DefaultResponseRouterCollection();
26          InboundEndpoint endpoint=getTestInboundEndpoint("test");
27          router.addEndpoint(endpoint);
28          assertNotNull(router.getEndpoints());
29          assertTrue(router.getEndpoints().contains(endpoint));
30      }
31  
32      public void testSetGoodEndpoints() throws Exception
33      {
34          List list= new ArrayList();
35          list.add(getTestInboundEndpoint("test"));
36          list.add(getTestInboundEndpoint("test"));
37          DefaultResponseRouterCollection router=new DefaultResponseRouterCollection();
38          assertNotNull(router.getEndpoints());
39          assertEquals(0, router.getEndpoints().size());
40          router.addEndpoint(getTestInboundEndpoint("test"));
41          assertEquals(1, router.getEndpoints().size());
42          router.setEndpoints(list);
43          assertNotNull(router.getEndpoints());
44          assertEquals(2, router.getEndpoints().size());
45      }
46  
47      public void testSetBadEndpoints() throws Exception
48      {
49          List list= new ArrayList();
50          list.add(getTestInboundEndpoint("test"));
51          list.add(getTestOutboundEndpoint("test"));
52          DefaultResponseRouterCollection router=new DefaultResponseRouterCollection();
53          try{
54              router.setEndpoints(list);
55              fail("Invalid endpoint: Exception exceptions");
56          }
57          catch(Exception e){
58              assertEquals(InvalidEndpointTypeException.class, e.getClass());
59          }
60      }
61      
62      public void testSetBad2Endpoints() throws Exception
63      {
64          List list= new ArrayList();
65          list.add(getTestInboundEndpoint("test"));
66          list.add(getTestOutboundEndpoint("test"));
67          DefaultResponseRouterCollection router=new DefaultResponseRouterCollection();
68          try{
69              router.setEndpoints(list);
70              fail("Invalid endpoint: Exception exceptions");
71          }
72          catch(Exception e){
73              assertEquals(InvalidEndpointTypeException.class, e.getClass());
74          }
75      }
76  
77  }
78  
79