1   /*
2    * $Id: MethodEntrypointsTestCase.java 10789 2008-02-12 20:04:43Z 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  
11  package org.mule.test.integration.resolvers;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.model.resolvers.EntryPointNotFoundException;
16  import org.mule.tck.FunctionalTestCase;
17  
18  public class MethodEntrypointsTestCase extends FunctionalTestCase
19  {
20  
21      protected String getConfigResources()
22      {
23          return "org/mule/test/integration/resolvers/method-entrypoints-config.xml";
24      }
25  
26      public void testTooManySatifiableMethods() throws Exception
27      {
28          MuleClient client = new MuleClient();
29          MuleMessage message = client.send("vm://service", "hello", null);
30          assertNotNull(message.getExceptionPayload());
31          assertTrue(message.getExceptionPayload().getException().getCause() instanceof EntryPointNotFoundException);
32          assertTrue(message.getExceptionPayload().getException().getCause().getMessage().indexOf("Found too many possible methods on object") > -1);
33      }
34  
35      public void testBadMethodName() throws Exception
36      {
37          MuleClient client = new MuleClient();
38          MuleMessage message = client.send("vm://service?method=foo", "hello", null);
39          assertNotNull(message.getExceptionPayload());
40          assertTrue(message.getExceptionPayload().getException().getCause() instanceof EntryPointNotFoundException);
41      }
42  
43      public void testValidCallToReverse() throws Exception
44      {
45          MuleClient client = new MuleClient();
46          MuleMessage message = client.send("vm://service?method=reverseString", "hello", null);
47          assertNotNull(message);
48          assertEquals(message.getPayloadAsString(), "olleh");
49      }
50  
51      public void testValidCallToUpperCase() throws Exception
52      {
53          MuleClient client = new MuleClient();
54          MuleMessage message = client.send("vm://service?method=upperCaseString", "hello", null);
55          assertNotNull(message);
56          assertEquals(message.getPayloadAsString(), "HELLO");
57      }
58  }