1
2
3
4
5
6
7
8
9
10 package org.mule.module.ibeans.annotations.invoke;
11
12 import org.mule.tck.AbstractMuleTestCase;
13
14 import org.ibeans.annotation.IntegrationBean;
15 import org.ibeans.api.CallException;
16
17 public class InvokeAnnotationTestCase extends AbstractMuleTestCase
18 {
19 public InvokeAnnotationTestCase()
20 {
21 setStartContext(true);
22 }
23
24 @SuppressWarnings("unused")
25 @IntegrationBean
26 private InvokeTestIBean test;
27
28 @Override
29 protected void doSetUp() throws Exception
30 {
31 muleContext.getRegistry().registerObject("testCase", this);
32 }
33
34 public void testIBeanInvoke() throws Exception {
35 assertNotNull(test);
36 String result = test.greet("Ross");
37 assertEquals("Hello Ross", result);
38 }
39
40 public void testIBeanInvokeBadObject() throws Exception {
41 try
42 {
43 test.greetFail1("Ross");
44 fail("dummy2 not a valid object");
45 }
46 catch (CallException e)
47 {
48 assertTrue(e.getCause() instanceof IllegalArgumentException);
49
50 }
51 }
52
53 public void testIBeanInvokeBadMethod() throws Exception {
54 try
55 {
56 test.greetFail2("Ross");
57 fail("sayHellox not a valid method");
58 }
59 catch (CallException e)
60 {
61 assertTrue(e.getCause() instanceof NoSuchMethodException);
62
63 }
64 }
65
66 public void testIBeanInvokeWrongArguments() throws Exception {
67 try
68 {
69 test.greetFail3("Ross", "UK");
70 fail("Wrong number of arguments");
71 }
72 catch (CallException e)
73 {
74 assertTrue(e.getCause() instanceof NoSuchMethodException);
75
76 }
77 }
78 }