1   /*
2    * $Id: PersistentVMQueueTestCase.java 7976 2007-08-21 14:26:13Z 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.vm;
12  
13  import org.mule.extras.client.MuleClient;
14  import org.mule.tck.FunctionalTestCase;
15  import org.mule.umo.UMOMessage;
16  
17  /**
18   *
19   */
20  
21  public class PersistentVMQueueTestCase extends FunctionalTestCase
22  {
23      private static final int RECEIVE_TIMEOUT = 5000;
24  
25      protected String getConfigResources()
26      {
27          return "persistent-vmqueue-test.xml";
28      }
29  
30      public void testAsynchronousDispatching() throws Exception
31      {
32          String input = "Test message";
33          String[] output = {"Test", "message"};
34          MuleClient client = new MuleClient();
35          client.dispatch("vm://receiver", input, null);
36          UMOMessage result = client.receive("vm://out", RECEIVE_TIMEOUT);
37          assertNotNull(result);
38          assertNotNull(result.getPayload());
39          assertNull(result.getExceptionPayload());
40          String[] payload = (String[]) result.getPayload();
41          assertEquals(output.length, payload.length);
42          for (int i = 0; i < output.length; i++)
43          {
44              assertEquals(output[i], payload[i]);
45          }
46      }
47  
48  }