View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.integration.resolvers;
8   
9   import java.util.HashMap;
10  import java.util.Map;
11  
12  import org.junit.Test;
13  
14  public class EntryPointResolverTestCase extends AbstractEntryPointResolverTestCase
15  {
16  
17      @Override
18      protected String getConfigResources()
19      {
20          return "org/mule/test/integration/resolvers/entry-point-resolver-test.xml";
21      }
22  
23      @Test
24      public void testArrayEntryPointResolverOnModel() throws Exception
25      {
26          doTest("array", new String[]{"hello", "world"}, "array");
27      }
28      
29      @Test
30      public void testArrayEntryPointResolverOnComponent() throws Exception
31      {
32          doTest("array2", new String[]{"hello", "world"}, "array");
33      }
34  
35      @Test
36      public void testCallableEntryPointResolverOnModel() throws Exception
37      {
38          doTest("callable", new Object(), "callable");
39      }
40  
41      @Test
42      public void testCallableEntryPointResolverOnComponent() throws Exception
43      {
44          doTest("callable2", new Object(), "callable");
45      }
46  
47      @Test
48      public void testCustomEntryPointResolverOnModel() throws Exception
49      {
50          doTest("custom", new Object(), "custom");
51      }
52  
53      @Test
54      public void testCustomEntryPointResolverOnComponent() throws Exception
55      {
56          doTest("custom2", new Object(), "custom");
57      }
58  
59      @Test
60      public void testMethodEntryPointResolverOnModel() throws Exception
61      {
62          doTest("method", new String(), "methodString");
63          doTest("method", new Integer(0), "methodInteger");
64      }
65  
66      @Test
67      public void testMethodEntryPointResolverOnComponent() throws Exception
68      {
69          doTest("method2", new String(), "methodString");
70          doTest("method2", new Integer(0), "methodInteger");
71      }
72  
73      @Test
74      public void testNoArgumentsEntryPointResolverOnModel() throws Exception
75      {
76          doTest("no-arguments", new String(), "noArguments");
77      }
78  
79      @Test
80      public void testNoArgumentsEntryPointResolverOnComponent() throws Exception
81      {
82          doTest("no-arguments2", new String(), "noArguments");
83      }
84  
85      @Test
86      public void testPropertyEntryPointResolverOnModel() throws Exception
87      {
88          Map properties = new HashMap();
89          properties.put("propertyName", "property");
90          doTest("property", new Object(), "property", properties);
91      }
92  
93      @Test
94      public void testPropertyEntryPointResolverOnComponent() throws Exception
95      {
96          Map properties = new HashMap();
97          properties.put("propertyName", "property");
98          doTest("property2", new Object(), "property", properties);
99      }
100 
101     @Test
102     public void testReflectionEntryPointResolverOnModel() throws Exception
103     {
104         doTest("reflection", new Object[]{new Integer(0), new String("String")}, "reflection");
105     }
106 
107     @Test
108     public void testReflectionEntryPointResolverOnComponent() throws Exception
109     {
110         doTest("reflection2", new Object[]{new Integer(0), new String("String")}, "reflection");
111     }
112 
113     @Test
114     public void testLegacyEntryPointResolversOnModel() throws Exception
115     {
116         doTest("legacy", "hello world", "callable");
117     }
118 
119     @Test
120     public void testLegacyEntryPointResolversOnComponent() throws Exception
121     {
122         doTest("legacy2", "hello world", "callable");
123     }
124 
125     @Test
126     public void testReflectionEntryPointResolverWithNullElementInArray() throws Exception
127     {
128         // see MULE-3565
129         
130         // This first case causes an exception in the flow because the ReflectionEntryPointResolver
131         // will take the argument types literally and it doesn't know how to handle the null as class
132         doTest("reflection", new Object[] { new Integer(42), null }, "{NullPayload}");
133         
134         doTest("array", new String[] { "hello", null, "world" }, "array");
135     }
136 }