View Javadoc

1   /*
2    * $Id: PersistentUnaddressedVmQueueTestCase.java 22505 2011-07-21 15:34:24Z 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.functional;
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  public class PersistentUnaddressedVmQueueTestCase extends AbstractServiceAndFlowTestCase
26  {
27  
28      private static final int RECEIVE_TIMEOUT = 5000;
29  
30      public PersistentUnaddressedVmQueueTestCase(ConfigVariant variant, String configResources)
31      {
32          super(variant, configResources);
33      }
34  
35      @Parameters
36      public static Collection<Object[]> parameters()
37      {
38          return Arrays.asList(new Object[][]{
39              {ConfigVariant.SERVICE, "vm/persistent-unaddressed-vm-queue-test-service.xml"},
40              {ConfigVariant.FLOW, "vm/persistent-unaddressed-vm-queue-test-flow.xml"}});
41      }
42  
43      @Test
44      public void testAsynchronousDispatching() throws Exception
45      {
46          MuleClient client = new MuleClient(muleContext);
47          client.dispatch("vm://receiver1?connector=Connector1", "Test", null);
48          MuleMessage result = client.request("vm://out?connector=Connector2", RECEIVE_TIMEOUT);
49          assertNotNull(result);
50          assertEquals(result.getPayloadAsString(), "Test");
51      }
52  }