1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.tcp.issues;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.endpoint.InboundEndpoint;
15 import org.mule.module.client.MuleClient;
16 import org.mule.tck.DynamicPortTestCase;
17 import org.mule.tck.FunctionalTestCase;
18 import org.mule.transport.tcp.integration.AbstractStreamingCapacityTestCase;
19
20 public abstract class AbstractStreamingDownloadMule1389TestCase extends DynamicPortTestCase
21 {
22 public void testDownloadSpeed() throws Exception
23 {
24 MuleClient client = new MuleClient(muleContext);
25 long now = System.currentTimeMillis();
26 MuleMessage result = client.send(((InboundEndpoint) client.getMuleContext().getRegistry().lookupObject("inTestComponent")).getAddress(),
27 "request", null);
28 assertNotNull(result);
29 assertNotNull(result.getPayload());
30 assertEquals(InputStreamSource.SIZE, result.getPayloadAsBytes().length);
31 long then = System.currentTimeMillis();
32 double speed = InputStreamSource.SIZE / (double) (then - now) * 1000 / AbstractStreamingCapacityTestCase.ONE_MB;
33 logger.info("Transfer speed " + speed + " MB/s (" + InputStreamSource.SIZE + " B in " + (then - now) + " ms)");
34 }
35
36 }