View Javadoc

1   /*
2    * $Id: VMSynchTestCase.java 22449 2011-07-19 07:40:43Z justin.calleja $
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.transport.vm;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertNotNull;
15  
16  import java.util.Arrays;
17  import java.util.Collection;
18  
19  import org.junit.Test;
20  import org.junit.runners.Parameterized.Parameters;
21  import org.mule.api.MuleMessage;
22  import org.mule.module.client.MuleClient;
23  import org.mule.tck.AbstractServiceAndFlowTestCase;
24  
25  /**
26   * Simple synch test used to study message flow.
27   */
28  public class VMSynchTestCase extends AbstractServiceAndFlowTestCase
29  {
30  
31      public VMSynchTestCase(ConfigVariant variant, String configResources)
32      {
33          super(variant, configResources);
34      }
35      
36      @Parameters
37      public static Collection<Object[]> parameters()
38      {
39          return Arrays.asList(new Object[][]{
40              {ConfigVariant.SERVICE, "vm/vm-synch-test-service.xml"},
41              {ConfigVariant.FLOW, "vm/vm-synch-test-flow.xml"}
42          });
43      }
44  
45      @Test
46      public void testSingleMessage() throws Exception
47      {
48          MuleClient client = new MuleClient(muleContext);
49          MuleMessage response =  client.send("vm://bridge", "Message", null);
50          assertNotNull("Response is null", response);
51          assertEquals("Message Received", response.getPayload());
52      }
53  
54      @Test
55      public void testManyMessage() throws Exception
56      {
57          for (int i = 0; i < 1000; i++)
58          {
59              testSingleMessage();
60          }
61      }
62  
63  }