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