1   /*
2    * $Id: VMFunctionalTestCase.java 10789 2008-02-12 20:04:43Z dfeist $
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.transport.vm;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  public class VMFunctionalTestCase extends FunctionalTestCase
18  {
19  
20      public static final long WAIT = 3000L;
21  
22      protected String getConfigResources()
23      {
24          return "vm/vm-functional-test.xml";
25      }
26  
27      public void testSingleMessage() throws Exception
28      {
29          MuleClient client = new MuleClient();
30          client.dispatch("vm://in", "Marco", null);
31          MuleMessage response = client.request("vm://out", WAIT);
32          assertNotNull("Response is null", response);
33          assertEquals("Polo", response.getPayload());
34      }
35  
36      public void testRequest() throws Exception
37      {
38          MuleClient client = new MuleClient();
39          client.dispatch("vm://in", "Marco", null);
40          MuleMessage response = client.request("vm://out", WAIT);
41          assertNotNull("Response is null", response);
42          assertEquals("Polo", response.getPayload());
43      }
44  
45      public void testMultipleMessages() throws Exception
46      {
47          MuleClient client = new MuleClient();
48          client.dispatch("vm://in", "Marco", null);
49          client.dispatch("vm://in", "Marco", null);
50          client.dispatch("vm://in", "Marco", null);
51          MuleMessage response;
52          for (int i = 0; i < 3; ++i)
53          {
54              response = client.request("vm://out", WAIT);
55              assertNotNull("Response is null", response);
56              assertEquals("Polo", response.getPayload());
57          }
58      }
59  }