1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.resolvers;
12
13 import java.util.Arrays;
14 import java.util.Collection;
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.junit.Test;
19 import org.junit.runners.Parameterized.Parameters;
20
21 public class EntryPointResolverTestCase extends AbstractEntryPointResolverTestCase
22 {
23 public EntryPointResolverTestCase(ConfigVariant variant, String configResources)
24 {
25 super(variant, configResources);
26 }
27
28 @Parameters
29 public static Collection<Object[]> parameters()
30 {
31 return Arrays.asList(new Object[][]{
32 {ConfigVariant.SERVICE,
33 "org/mule/test/integration/resolvers/entry-point-resolver-test-service.xml"},
34 {ConfigVariant.FLOW, "org/mule/test/integration/resolvers/entry-point-resolver-test-flow.xml"}});
35 }
36
37 @Test
38 public void testArrayEntryPointResolverOnModel() throws Exception
39 {
40 if (variant.equals(ConfigVariant.SERVICE))
41 {
42 doTest("array", new String[]{"hello", "world"}, "array");
43 }
44 }
45
46 @Test
47 public void testArrayEntryPointResolverOnComponent() throws Exception
48 {
49 doTest("array2", new String[]{"hello", "world"}, "array");
50 }
51
52 @Test
53 public void testCallableEntryPointResolverOnModel() throws Exception
54 {
55 if (variant.equals(ConfigVariant.SERVICE))
56 {
57 doTest("callable", new Object(), "callable");
58 }
59 }
60
61 @Test
62 public void testCallableEntryPointResolverOnComponent() throws Exception
63 {
64 doTest("callable2", new Object(), "callable");
65 }
66
67 @Test
68 public void testCustomEntryPointResolverOnModel() throws Exception
69 {
70 if (variant.equals(ConfigVariant.SERVICE))
71 {
72 doTest("custom", new Object(), "custom");
73 }
74 }
75
76 @Test
77 public void testCustomEntryPointResolverOnComponent() throws Exception
78 {
79 doTest("custom2", new Object(), "custom");
80 }
81
82 @Test
83 public void testMethodEntryPointResolverOnModel() throws Exception
84 {
85 if (variant.equals(ConfigVariant.SERVICE))
86 {
87 doTest("method", new String(), "methodString");
88 doTest("method", new Integer(0), "methodInteger");
89 }
90 }
91
92 @Test
93 public void testMethodEntryPointResolverOnComponent() throws Exception
94 {
95 doTest("method2", new String(), "methodString");
96 doTest("method2", new Integer(0), "methodInteger");
97 }
98
99 @Test
100 public void testNoArgumentsEntryPointResolverOnModel() throws Exception
101 {
102 if (variant.equals(ConfigVariant.SERVICE))
103 {
104 doTest("no-arguments", new String(), "noArguments");
105 }
106 }
107
108 @Test
109 public void testNoArgumentsEntryPointResolverOnComponent() throws Exception
110 {
111 doTest("no-arguments2", new String(), "noArguments");
112 }
113
114 @Test
115 public void testPropertyEntryPointResolverOnModel() throws Exception
116 {
117 if (variant.equals(ConfigVariant.SERVICE))
118 {
119 Map<String, Object> properties = new HashMap<String, Object>();
120 properties.put("propertyName", "property");
121 doTest("property", new Object(), "property", properties);
122 }
123 }
124
125 @Test
126 public void testPropertyEntryPointResolverOnComponent() throws Exception
127 {
128 Map<String, Object> properties = new HashMap<String, Object>();
129 properties.put("propertyName", "property");
130 doTest("property2", new Object(), "property", properties);
131 }
132
133 @Test
134 public void testReflectionEntryPointResolverOnModel() throws Exception
135 {
136 if (variant.equals(ConfigVariant.SERVICE))
137 {
138 doTest("reflection", new Object[]{new Integer(0), new String("String")}, "reflection");
139 }
140 }
141
142 @Test
143 public void testReflectionEntryPointResolverOnComponent() throws Exception
144 {
145 doTest("reflection2", new Object[]{new Integer(0), new String("String")}, "reflection");
146 }
147
148 @Test
149 public void testLegacyEntryPointResolversOnModel() throws Exception
150 {
151 if (variant.equals(ConfigVariant.SERVICE))
152 {
153 doTest("legacy", "hello world", "callable");
154 }
155 }
156
157 @Test
158 public void testLegacyEntryPointResolversOnComponent() throws Exception
159 {
160 doTest("legacy2", "hello world", "callable");
161 }
162
163 @Test
164 public void testReflectionEntryPointResolverWithNullElementInArray() throws Exception
165 {
166
167
168 try
169 {
170 doTest("reflection2", new Object[]{new Integer(42), null}, "{NullPayload}");
171 }
172 catch (Exception e)
173 {
174
175
176
177
178 }
179
180 doTest("array2", new String[]{"hello", null, "world"}, "array");
181 }
182 }