1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.ejb;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.endpoint.EndpointBuilder;
15 import org.mule.api.endpoint.OutboundEndpoint;
16 import org.mule.api.transport.DispatchException;
17 import org.mule.endpoint.EndpointURIEndpointBuilder;
18 import org.mule.module.client.MuleClient;
19 import org.mule.transport.AbstractFunctionalTestCase;
20 import org.mule.transport.rmi.RmiConnector;
21
22 import java.util.Properties;
23
24
25
26
27 public class EjbFunctionalTestCase extends AbstractFunctionalTestCase
28 {
29 public EjbFunctionalTestCase()
30 {
31 super("ejb", "ejb-functional-test.xml");
32 }
33
34 public void testCase() throws Exception
35 {
36 MuleClient client = new MuleClient(muleContext);
37 MuleMessage result = client.send("vm://in", "1234567890", null);
38 assertNotNull(result);
39 assertEquals("0987654321", result.getPayloadAsString());
40 }
41
42 @Override
43 public void testBadMethodType() throws Exception
44 {
45
46
47 EndpointBuilder builder = new EndpointURIEndpointBuilder("ejb://localhost/TestService?method=reverseString",
48 muleContext);
49 Properties props = new Properties();
50 props.put(RmiConnector.PROPERTY_SERVICE_METHOD_PARAM_TYPES, StringBuffer.class.getName());
51 builder.setProperties(props);
52
53 OutboundEndpoint ep = muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint(
54 builder);
55 try
56 {
57 ep.process(getTestEvent("hello", ep));
58 }
59 catch (Exception e)
60 {
61 assertTrue(e instanceof DispatchException);
62 assertTrue(e.getCause() instanceof NoSuchMethodException);
63 }
64 }
65
66 @Override
67 public void testCorrectMethodType() throws Exception
68 {
69
70
71 EndpointBuilder builder = new EndpointURIEndpointBuilder("ejb://localhost/TestService?method=reverseString",
72 muleContext);
73 Properties props = new Properties();
74 props.put(RmiConnector.PROPERTY_SERVICE_METHOD_PARAM_TYPES, String.class.getName());
75 builder.setProperties(props);
76
77 OutboundEndpoint ep = muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint(
78 builder);
79
80 try
81 {
82 ep.process(getTestEvent("hello", ep));
83 }
84 catch (Exception e)
85 {
86 assertTrue(e instanceof DispatchException);
87 assertTrue(e.getCause() instanceof NoSuchMethodException);
88 }
89 }
90
91 }