1   /*
2    * $Id: ExplicitMethodEntryPointResolverTestCase.java 10489 2008-01-23 17:53:38Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.mule.model;
11  
12  import org.mule.api.model.InvocationResult;
13  import org.mule.model.resolvers.ExplicitMethodEntryPointResolver;
14  import org.mule.tck.AbstractMuleTestCase;
15  
16  public class ExplicitMethodEntryPointResolverTestCase extends AbstractMuleTestCase
17  {
18      public void testMethodSetPass() throws Exception
19      {
20          ExplicitMethodEntryPointResolver resolver = new ExplicitMethodEntryPointResolver();
21          resolver.addMethod("someBusinessMethod");
22          InvocationResult result = resolver.invoke(new MultiplePayloadsTestObject(), getTestEventContext("blah"));
23          assertEquals(result.getState(), InvocationResult.STATE_INVOKED_SUCESSFUL);
24      }
25  
26      public void testMethodSetMatchFirst() throws Exception
27      {
28          ExplicitMethodEntryPointResolver resolver = new ExplicitMethodEntryPointResolver();
29          resolver.addMethod("someBusinessMethod");
30          resolver.addMethod("someSetter");
31          InvocationResult result = resolver.invoke(new MultiplePayloadsTestObject(), getTestEventContext("blah"));
32          assertEquals(result.getState(), InvocationResult.STATE_INVOKED_SUCESSFUL);
33      }
34  
35      public void testMethodNotFound() throws Exception
36      {
37          ExplicitMethodEntryPointResolver resolver = new ExplicitMethodEntryPointResolver();
38          resolver.addMethod("noMethod");
39          resolver.addMethod("noMethod2");
40          InvocationResult result = resolver.invoke(new MultiplePayloadsTestObject(), getTestEventContext("blah"));
41          assertEquals(result.getState(), InvocationResult.STATE_INVOKED_FAILED);
42      }
43  
44      public void testNoMethodSet() throws Exception
45      {
46          ExplicitMethodEntryPointResolver resolver = new ExplicitMethodEntryPointResolver();
47          try
48          {
49              resolver.invoke(new MultiplePayloadsTestObject(), getTestEventContext("blah"));
50              fail("method property is not set, this should cause an error");
51          }
52          catch (IllegalStateException e)
53          {
54              //Expected
55          }
56      }
57  }