1
2
3
4
5
6
7 package org.mule.module.cxf.jaxws;
8
9 import org.mule.api.MuleEventContext;
10 import org.mule.api.MuleMessage;
11 import org.mule.module.client.MuleClient;
12 import org.mule.tck.functional.EventCallback;
13 import org.mule.tck.functional.FunctionalTestComponent;
14 import org.mule.tck.junit4.FunctionalTestCase;
15 import org.mule.tck.junit4.rule.DynamicPort;
16
17 import java.util.HashMap;
18 import java.util.Map;
19
20 import org.apache.hello_world_soap_http.GreeterImpl;
21 import org.junit.Rule;
22 import org.junit.Test;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26
27 public class HeaderPropertiesTestCase extends FunctionalTestCase
28 {
29
30 @Rule
31 public DynamicPort dynamicPort = new DynamicPort("port1");
32
33 @Override
34 protected String getConfigResources()
35 {
36 return "header-conf.xml";
37 }
38
39 private GreeterImpl getGreeter() throws Exception
40 {
41 Object instance = getComponent("greeterService");
42
43 return (GreeterImpl) instance;
44 }
45
46 @Test
47 public void testClientWithMuleClient() throws Exception
48 {
49 FunctionalTestComponent testComponent = getFunctionalTestComponent("testService");
50 assertNotNull(testComponent);
51
52 EventCallback callback = new EventCallback()
53 {
54 public void eventReceived(final MuleEventContext context, final Object component) throws Exception
55 {
56 MuleMessage msg = context.getMessage();
57 assertEquals("BAR", msg.getInboundProperty("FOO"));
58 }
59 };
60 testComponent.setEventCallback(callback);
61
62 MuleClient client = new MuleClient(muleContext);
63 Map<String, Object> props = new HashMap<String, Object>();
64 props.put("operation", "greetMe");
65 props.put("FOO", "BAR");
66 MuleMessage result = client.send("clientEndpoint", "Dan", props);
67 assertEquals("Hello Dan Received", result.getPayload());
68
69 GreeterImpl impl = getGreeter();
70 assertEquals(1, impl.getInvocationCount());
71 }
72 }