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.module.client.MuleClient;
15 import org.mule.tck.FunctionalTestCase;
16 import org.mule.transport.tcp.integration.AbstractStreamingCapacityTestCase;
17
18 public abstract class AbstractStreamingDownloadMule1389TestCase extends FunctionalTestCase
19 {
20
21 protected String endpoint;
22
23 public AbstractStreamingDownloadMule1389TestCase(String endpoint)
24 {
25 this.endpoint = endpoint;
26 }
27
28 public void testDownloadSpeed() throws Exception
29 {
30 MuleClient client = new MuleClient();
31 long now = System.currentTimeMillis();
32 MuleMessage result = client.send(endpoint, "request", null);
33 assertNotNull(result);
34 assertNotNull(result.getPayload());
35 assertEquals(InputStreamSource.SIZE, result.getPayloadAsBytes().length);
36 long then = System.currentTimeMillis();
37 double speed = InputStreamSource.SIZE / (double) (then - now) * 1000 / AbstractStreamingCapacityTestCase.ONE_MB;
38 logger.info("Transfer speed " + speed + " MB/s (" + InputStreamSource.SIZE + " B in " + (then - now) + " ms)");
39 }
40
41 }