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