1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.cxf.issues;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.client.MuleClient;
15 import org.mule.tck.DynamicPortTestCase;
16
17 import java.util.concurrent.CountDownLatch;
18 import java.util.concurrent.TimeUnit;
19
20
21
22
23
24
25 public class LargeProxyTestCase extends DynamicPortTestCase
26 {
27 @Override
28 protected String getConfigResources()
29 {
30 return "largeproxytest-config.xml";
31 }
32
33 public void testLargeMessageWithEchoProxy() throws Exception
34 {
35 int length = 5000;
36 final MuleClient client = new MuleClient(muleContext);
37
38 StringBuffer b = new StringBuffer();
39 int counter = 1;
40 while (b.length() < length)
41 {
42
43 b.append(counter).append(" ");
44 counter++;
45 }
46 final String largeString = b.toString().trim();
47
48 final String msg =
49 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
50 "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
51 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
52 "<soap:Body>" +
53 "<echo xmlns=\"http://simple.component.mule.org/\">" +
54 "<echo>" + largeString + "</echo>" +
55 "</echo>" +
56 "</soap:Body>" +
57 "</soap:Envelope>";
58
59 final CountDownLatch latch = new CountDownLatch(100);
60
61 Runnable runnable = new Runnable()
62 {
63
64 public void run()
65 {
66 for (int i = 0; i < 20; i++)
67 {
68 try
69 {
70 MuleMessage result = client.send("http://localhost:" + getPorts().get(0) + "/services/EchoProxy", msg, null);
71 String payloadAsStr = result.getPayloadAsString();
72 assertTrue("The payload length should never be 0", payloadAsStr.length() != 0);
73 assertTrue(payloadAsStr.indexOf(largeString) != -1);
74 latch.countDown();
75 }
76 catch (Exception e)
77 {
78 e.printStackTrace();
79 }
80 }
81 }
82
83 };
84
85 for (int j = 0; j < 5; j++)
86 {
87 new Thread(runnable).start();
88 }
89
90 latch.await(50000, TimeUnit.SECONDS);
91 }
92
93 @Override
94 protected int getNumPortsToFind()
95 {
96 return 2;
97 }
98 }