1
2
3
4
5
6
7 package org.mule.test.integration.routing;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.api.context.notification.ServerNotification;
11 import org.mule.module.client.MuleClient;
12 import org.mule.tck.functional.FunctionalTestNotificationListener;
13 import org.mule.tck.junit4.FunctionalTestCase;
14 import org.mule.tck.junit4.rule.DynamicPort;
15 import org.mule.util.concurrent.Latch;
16
17 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
18 import org.junit.Rule;
19 import org.junit.Test;
20
21 import static org.junit.Assert.assertFalse;
22 import static org.junit.Assert.assertNotNull;
23 import static org.junit.Assert.assertTrue;
24
25 public class WireTapCxfTestCase extends FunctionalTestCase
26 {
27
28 private static final Latch tapLatch = new Latch();
29
30 @Rule
31 public DynamicPort dynamicPort = new DynamicPort("port1");
32
33 @Override
34 protected void doSetUp() throws Exception
35 {
36 super.doSetUp();
37
38 muleContext.registerListener(new FunctionalTestNotificationListener()
39 {
40 public void onNotification(ServerNotification notification)
41 {
42 tapLatch.release();
43 }
44 });
45 }
46
47 @Override
48 protected String getConfigResources()
49 {
50 return "org/mule/test/integration/routing/wire-tap-cxf.xml";
51 }
52
53 @Test
54 public void testWireTap() throws Exception
55 {
56 String url = "http://localhost:" + dynamicPort.getNumber() +"/services/EchoUMO";
57 String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
58 + "<soap:Body><echo><text>foo</text></echo></soap:Body></soap:Envelope>";
59
60 MuleClient client = new MuleClient(muleContext);
61 MuleMessage response = client.send(url, msg, null);
62 assertNotNull(response);
63
64 String responseString = response.getPayloadAsString();
65 assertTrue(responseString.contains("echoResponse"));
66 assertFalse(responseString.contains("soap:Fault"));
67
68 assertTrue(tapLatch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
69 }
70 }