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