1
2
3
4
5
6
7
8
9
10
11 package org.mule.mule;
12
13 import org.mule.config.MuleConfiguration;
14 import org.mule.impl.MuleDescriptor;
15 import org.mule.tck.AbstractMuleTestCase;
16 import org.mule.tck.testmodels.fruit.Orange;
17 import org.mule.tck.testmodels.mule.TestExceptionStrategy;
18 import org.mule.umo.UMODescriptor;
19 import org.mule.umo.endpoint.UMOEndpoint;
20
21
22
23
24
25 public class MuleDescriptorTestCase extends AbstractMuleTestCase
26 {
27 public void testDescriptorDefaults() throws Exception
28 {
29 MuleDescriptor descriptor = new MuleDescriptor();
30 descriptor.initialise();
31 MuleConfiguration config = new MuleConfiguration();
32
33 assertNotNull(descriptor.getInterceptors());
34 assertEquals(0, descriptor.getInterceptors().size());
35
36 assertEquals(config.getQueueProfile().getMaxOutstandingMessages(), descriptor.getQueueProfile()
37 .getMaxOutstandingMessages());
38 assertEquals(config.getPoolingProfile().getMaxIdle(), descriptor.getPoolingProfile().getMaxIdle());
39 assertEquals(config.getPoolingProfile().getMaxWait(), descriptor.getPoolingProfile().getMaxWait());
40 assertEquals(config.getPoolingProfile().getMaxActive(), descriptor.getPoolingProfile().getMaxActive());
41 assertEquals("1.0", descriptor.getVersion());
42
43
44 assertNull(descriptor.getImplementation());
45 assertNull(descriptor.getInboundEndpoint());
46 assertNull(descriptor.getInboundTransformer());
47 assertNull(descriptor.getName());
48 assertNull(descriptor.getOutboundEndpoint());
49 assertNull(descriptor.getOutboundTransformer());
50 assertEquals(0, descriptor.getProperties().size());
51 }
52
53 public void testDescriptorNullValidation() throws Exception
54 {
55 UMODescriptor descriptor = new MuleDescriptor();
56
57 try
58 {
59 descriptor.setExceptionListener(null);
60 fail("setting exeption strategy to null should fail");
61 }
62 catch (RuntimeException e)
63 {
64
65 }
66
67 try
68 {
69 descriptor.setName(null);
70 fail("setting name to null should fail");
71 }
72 catch (RuntimeException e)
73 {
74
75 }
76
77 try
78 {
79 descriptor.setImplementation(null);
80 fail("setting implementation to null should fail");
81 }
82 catch (RuntimeException e)
83 {
84
85 }
86
87 }
88
89 public void testImplementationValidation() throws Exception
90 {
91 UMODescriptor descriptor = new MuleDescriptor();
92
93 try
94 {
95 descriptor.setImplementation(null);
96 fail("setting implementation to null should fail");
97 }
98 catch (RuntimeException e)
99 {
100
101 }
102
103 }
104
105 public void testEndpointValidation() throws Exception
106 {
107 UMODescriptor descriptor = getTestDescriptor("Terry", Orange.class.getName());
108 TestExceptionStrategy es = new TestExceptionStrategy();
109 descriptor.setExceptionListener(es);
110 assertNotNull(descriptor.getOutboundEndpoint());
111 assertNotNull(descriptor.getOutboundEndpoint().getConnector().getExceptionListener());
112
113
114 UMOEndpoint endpoint = getTestEndpoint("test2", UMOEndpoint.ENDPOINT_TYPE_RECEIVER);
115 descriptor.setInboundEndpoint(endpoint);
116
117 assertNotNull(descriptor.getInboundEndpoint().getConnector().getExceptionListener());
118
119
120
121 }
122 }