View Javadoc

1   /*
2    * $Id: ManySendsMule1758TestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.issues;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  public class ManySendsMule1758TestCase extends FunctionalTestCase
18  {
19      private static int NUM_MESSAGES = 3000;
20  
21      protected String getConfigResources()
22      {
23          return "org/mule/issues/many-sends-mule-1758-test.xml";
24      }
25  
26      public void testSingleSend() throws Exception
27      {
28          MuleClient client = new MuleClient(muleContext);
29          MuleMessage response = client.send("vm://s-in", "Marco", null);
30          assertNotNull("Response is null", response);
31          assertEquals("Polo", response.getPayload());
32      }
33  
34      public void testManySends() throws Exception
35      {
36          long then = System.currentTimeMillis();
37          MuleClient client = new MuleClient(muleContext);
38          for (int i = 0; i < NUM_MESSAGES; ++i)
39          {
40              logger.debug("Message " + i);
41              MuleMessage response = client.send("vm://s-in", "Marco", null);
42              assertNotNull("Response is null", response);
43              assertEquals("Polo", response.getPayload());
44          }
45          long now = System.currentTimeMillis();
46          logger.info("Total time " + ((now - then) / 1000.0) + "s; per message " + ((now - then) / (1.0 * NUM_MESSAGES)) + "ms");
47      }
48  
49  }