1
2
3
4
5
6
7
8
9
10
11 package org.mule;
12
13 import org.mule.api.endpoint.InvalidEndpointTypeException;
14 import org.mule.api.endpoint.OutboundEndpoint;
15 import org.mule.service.DefaultServiceExceptionStrategy;
16 import org.mule.tck.AbstractMuleTestCase;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 public class AbstractExceptionListenerTestCase extends AbstractMuleTestCase
22 {
23
24 public void testAddGoodEndpoint() throws Exception
25 {
26 AbstractExceptionListener router = new DefaultServiceExceptionStrategy();
27 OutboundEndpoint endpoint = getTestOutboundEndpoint("test");
28 router.addEndpoint(endpoint);
29 assertNotNull(router.getEndpoints());
30 assertTrue(router.getEndpoints().contains(endpoint));
31 }
32
33 public void testSetGoodEndpoints() throws Exception
34 {
35 List list = new ArrayList();
36 list.add(getTestOutboundEndpoint("test"));
37 list.add(getTestOutboundEndpoint("test"));
38 AbstractExceptionListener router = new DefaultServiceExceptionStrategy();
39 assertNotNull(router.getEndpoints());
40 assertEquals(0, router.getEndpoints().size());
41 router.addEndpoint(getTestOutboundEndpoint("test"));
42 assertEquals(1, router.getEndpoints().size());
43 router.setEndpoints(list);
44 assertNotNull(router.getEndpoints());
45 assertEquals(2, router.getEndpoints().size());
46 }
47
48 public void testSetBadEndpoints() throws Exception
49 {
50 List list = new ArrayList();
51 list.add(getTestInboundEndpoint("test"));
52 list.add(getTestOutboundEndpoint("test"));
53 AbstractExceptionListener router = new DefaultServiceExceptionStrategy();
54 try
55 {
56 router.setEndpoints(list);
57 fail("Invalid endpoint: Exception exceptions");
58 }
59 catch (Exception e)
60 {
61 assertEquals(InvalidEndpointTypeException.class, e.getClass());
62 }
63 }
64
65 }