1   /*
2    * $Id: EntryPointResolverMethodCacheTestCase.java 12242 2008-07-07 13:35:38Z dirk.olmes $
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  
11  package org.mule.model.resolvers;
12  
13  import org.mule.api.MuleEventContext;
14  import org.mule.api.model.InvocationResult;
15  import org.mule.tck.AbstractMuleTestCase;
16  
17  import java.lang.reflect.Method;
18  
19  import junit.framework.AssertionFailedError;
20  
21  public class EntryPointResolverMethodCacheTestCase extends AbstractMuleTestCase
22  {
23      
24      private static final String METHOD = "aMethod";
25      
26      public void testMethodCaching() throws Exception
27      {
28          Method method = this.getClass().getMethod(METHOD, new Class[] { String.class});
29          
30          MuleEventContext eventContext = getTestEventContext(null);
31          MockEntryPointResolver epResolver = new MockEntryPointResolver();
32          epResolver.addMethodByName(method, eventContext);
33          
34          assertEquals(method, epResolver.getMethodByName(METHOD, eventContext));   
35      }
36      
37      public void aMethod(String payload)
38      {
39          // this method exists only for being cached in the test
40      }
41      
42      private static class MockEntryPointResolver extends AbstractEntryPointResolver
43      {
44          public InvocationResult invoke(Object component, MuleEventContext context) throws Exception
45          {
46              throw new AssertionFailedError("do not invoke this method");
47          }
48      }
49      
50  }
51  
52