1   /*
2    * $Id: AbstractStreamingDownloadMule1389TestCase.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.providers.tcp.issues;
12  
13  import org.mule.extras.client.MuleClient;
14  import org.mule.tck.FunctionalTestCase;
15  import org.mule.umo.UMOMessage;
16  import org.mule.providers.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          UMOMessage 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  }