View Javadoc

1   /*
2    * $Id: TransformerChainMule2063TestCase.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.issues;
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 TransformerChainMule2063TestCase extends AbstractServiceAndFlowTestCase
26  {
27      public static final String IN = "in";
28      public static final String TEST1_OUT = IN + "123";
29      public static final String TEST2_OUT = IN + "123";
30      public static final String TEST3_OUT = IN + "123abc";
31      public static final long WAIT_MS = 3000L;
32  
33      public TransformerChainMule2063TestCase(ConfigVariant variant, String configResources)
34      {
35          super(variant, configResources);
36      }
37  
38      @Parameters
39      public static Collection<Object[]> parameters()
40      {
41          return Arrays.asList(new Object[][]{
42              {ConfigVariant.SERVICE, "issues/transformer-chain-mule-2063-test-service.xml"},
43              {ConfigVariant.FLOW, "issues/transformer-chain-mule-2063-test-flow.xml"}});
44      }
45  
46      protected void doTest(String name, String result) throws Exception
47      {
48          MuleClient client = new MuleClient(muleContext);
49          client.send("vm://" + name + "-in", IN, null);
50          MuleMessage message = client.request("vm://" + name + "-out", WAIT_MS);
51  
52          assertNotNull(message);
53          assertNotNull(message.getPayloadAsString());
54          assertEquals(result, message.getPayloadAsString());
55      }
56  
57      @Test
58      public void testInputTransformers() throws Exception
59      {
60          doTest("test1", TEST1_OUT);
61      }
62  
63      @Test
64      public void testGlobalTransformers() throws Exception
65      {
66          doTest("test2", TEST2_OUT);
67      }
68  
69      @Test
70      public void testOutputTransformers() throws Exception
71      {
72          doTest("test3", TEST3_OUT);
73      }
74  
75  }