1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.soap.xfire;
12
13 import org.mule.MuleManager;
14 import org.mule.config.MuleProperties;
15 import org.mule.extras.client.MuleClient;
16 import org.mule.impl.internal.notifications.MessageNotification;
17 import org.mule.impl.internal.notifications.MessageNotificationListener;
18 import org.mule.tck.FunctionalTestCase;
19 import org.mule.umo.UMOMessage;
20 import org.mule.umo.manager.UMOServerNotification;
21
22 import java.util.HashMap;
23
24 public class XFireCustomHttpHeaderTestCase extends FunctionalTestCase implements MessageNotificationListener
25 {
26 protected static final String endpointAddress = "http://localhost:63181/services/TestComponent?method=onReceive";
27
28 private UMOMessage notificationMsg = null;
29
30
31 protected void doPostFunctionalSetUp() throws Exception
32 {
33 super.doPostFunctionalSetUp();
34 MuleManager.getInstance().registerListener(this);
35 }
36
37
38 protected void doFunctionalTearDown() throws Exception
39 {
40 MuleManager.getInstance().unregisterListener(this);
41 super.doFunctionalTearDown();
42 }
43
44 public void testXfire() throws Exception
45 {
46 Object payload = new Object[]{"Test String"};
47 String myProperty = "myProperty";
48
49 HashMap props = new HashMap();
50 props.put(MuleProperties.MULE_USER_PROPERTY, "alan");
51 props.put(MuleProperties.MULE_METHOD_PROPERTY, "sayHello");
52 props.put(myProperty, myProperty);
53
54 MuleClient client = new MuleClient();
55 UMOMessage reply = client.send("xfire:" + endpointAddress, payload, props);
56
57 assertNotNull(reply);
58 assertNotNull(reply.getPayload());
59 assertEquals("Test String Received", reply.getPayloadAsString());
60
61
62 Thread.sleep(3000);
63
64
65 assertNotNull(notificationMsg);
66
67
68 assertEquals("alan", notificationMsg.getProperty(MuleProperties.MULE_USER_PROPERTY));
69
70
71 assertNull(notificationMsg.getProperty(MuleProperties.MULE_IGNORE_METHOD_PROPERTY));
72
73
74 assertEquals(myProperty, notificationMsg.getProperty(myProperty));
75 }
76
77 public void onNotification(UMOServerNotification notification)
78 {
79 if (notification instanceof MessageNotification)
80 {
81 String uri = ((MessageNotification)notification).getEndpoint().getEndpointURI().toString();
82 if (endpointAddress.equals(uri))
83 {
84 notificationMsg = (UMOMessage)notification.getSource();
85 }
86 }
87 }
88
89 protected String getConfigResources()
90 {
91 return "xfire-headers-conf.xml";
92 }
93
94 }