View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.issues;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertEquals;
16  import static org.junit.Assert.assertNotNull;
17  
18  public class ManySendsMule1758TestCase extends FunctionalTestCase
19  {
20  
21      private static int NUM_MESSAGES = 3000;
22  
23      @Override
24      protected String getConfigResources()
25      {
26          return "org/mule/issues/many-sends-mule-1758-test.xml";
27      }
28  
29      @Test
30      public void testSingleSend() throws Exception
31      {
32          MuleClient client = new MuleClient(muleContext);
33          MuleMessage response = client.send("vm://s-in", "Marco", null);
34          assertNotNull("Response is null", response);
35          assertEquals("Polo", response.getPayload());
36      }
37  
38      @Test
39      public void testManySends() throws Exception
40      {
41          long then = System.currentTimeMillis();
42          MuleClient client = new MuleClient(muleContext);
43          for (int i = 0; i < NUM_MESSAGES; ++i)
44          {
45              logger.debug("Message " + i);
46              MuleMessage response = client.send("vm://s-in", "Marco", null);
47              assertNotNull("Response is null", response);
48              assertEquals("Polo", response.getPayload());
49          }
50          long now = System.currentTimeMillis();
51          logger.info("Total time " + ((now - then) / 1000.0) + "s; per message " + ((now - then) / (1.0 * NUM_MESSAGES)) + "ms");
52      }
53  
54  }