1
2
3
4
5
6
7
8
9
10
11 package org.mule.mule.model;
12
13 import org.mule.api.model.InvocationResult;
14 import org.mule.model.resolvers.AbstractArgumentEntryPointResolver;
15 import org.mule.model.resolvers.NoArgumentsEntryPointResolver;
16 import org.mule.tck.AbstractMuleTestCase;
17 import org.mule.tck.testmodels.fruit.Apple;
18 import org.mule.tck.testmodels.fruit.InvalidSatsuma;
19 import org.mule.transport.NullPayload;
20
21 public class NoArgsEntryPointResolverTestCase extends AbstractMuleTestCase
22 {
23 public void testExplicitMethodMatch() throws Exception
24 {
25 AbstractArgumentEntryPointResolver resolver = new NoArgumentsEntryPointResolver();
26 resolver.addMethod("bite");
27 InvocationResult result = resolver.invoke(new InvalidSatsuma(), getTestEventContext("blah"));
28 assertEquals(result.getState(), InvocationResult.STATE_INVOKED_SUCESSFUL);
29 }
30
31 public void testExplicitMethodMatch2() throws Exception
32 {
33 AbstractArgumentEntryPointResolver resolver = new NoArgumentsEntryPointResolver();
34 resolver.addMethod("wash");
35 InvocationResult result = resolver.invoke(new Apple(), getTestEventContext("blah"));
36 assertEquals(result.getState(), InvocationResult.STATE_INVOKED_SUCESSFUL);
37 }
38
39 public void testDynamicMethodMatchFail() throws Exception
40 {
41 AbstractArgumentEntryPointResolver resolver = new NoArgumentsEntryPointResolver();
42 InvocationResult result = resolver.invoke(new Apple(), getTestEventContext("blah"));
43 assertEquals("Apple service has a number of matching method, so should have failed",
44 result.getState(), InvocationResult.STATE_INVOKED_FAILED);
45 }
46
47 public void testDynamicMethodMatchPass() throws Exception
48 {
49 AbstractArgumentEntryPointResolver resolver = new NoArgumentsEntryPointResolver();
50 InvocationResult result = resolver.invoke(new InvalidSatsuma(), getTestEventContext("blah"));
51 assertEquals(result.getState(), InvocationResult.STATE_INVOKED_SUCESSFUL);
52 }
53
54 public void testDynamicMethodMatchFailOnWildcardMatch() throws Exception
55 {
56 AbstractArgumentEntryPointResolver resolver = new NoArgumentsEntryPointResolver();
57 assertTrue(resolver.removeIgnoredMethod("is*"));
58 InvocationResult result = resolver.invoke(new InvalidSatsuma(), getTestEventContext("blah"));
59 assertEquals("Satsuma service has a number of matching method, so should have failed",
60 result.getState(), InvocationResult.STATE_INVOKED_FAILED);
61 }
62
63
64 public void testExplicitMethodMatchAndNullPayload() throws Exception
65 {
66 AbstractArgumentEntryPointResolver resolver = new NoArgumentsEntryPointResolver();
67 resolver.addMethod("wash");
68 InvocationResult result = resolver.invoke(new Apple(), getTestEventContext(NullPayload.getInstance()));
69 assertEquals(result.getState(), InvocationResult.STATE_INVOKED_SUCESSFUL);
70 }
71 }