View Javadoc

1   /*
2    * $Id: DynamicEndpointRoutingTestCase.java 22431 2011-07-18 07:40:35Z dirk.olmes $
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.test.routing;
12  
13  import org.mule.api.FutureMessageResult;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.AbstractServiceAndFlowTestCase;
17  
18  import java.util.Arrays;
19  import java.util.Collection;
20  
21  import org.junit.Test;
22  import org.junit.runners.Parameterized.Parameters;
23  
24  import static org.junit.Assert.assertEquals;
25  import static org.junit.Assert.assertNotNull;
26  
27  public class DynamicEndpointRoutingTestCase extends AbstractServiceAndFlowTestCase
28  {
29      @Parameters
30      public static Collection<Object[]> parameters()
31      {
32          return Arrays.asList(new Object[][]{
33              {ConfigVariant.SERVICE, "dynamic-endpoint-routing-test-service.xml"},
34              {ConfigVariant.FLOW, "dynamic-endpoint-routing-test-flow.xml"}});
35      }
36  
37      public DynamicEndpointRoutingTestCase(ConfigVariant variant, String configResources)
38      {
39          super(variant, configResources);
40      }
41  
42      @Test
43      public void testDynamicEndpoint() throws Exception
44      {
45          MuleClient client = new MuleClient(muleContext);
46          FutureMessageResult result = client.sendAsync("vm://inBound", "Hello,world", null, 5000);
47          MuleMessage response = result.getMessage(5000);
48          assertNotNull(response);
49          assertNotNull(response.getPayload());
50          assertEquals("step2Service", response.getPayloadAsString());
51      }
52  }