View Javadoc

1   /*
2    * $Id: TransformerAttributeTestCase.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.transport.vm;
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  import org.mule.tck.functional.StringAppendTestTransformer;
25  
26  public class TransformerAttributeTestCase extends AbstractServiceAndFlowTestCase
27  {
28      public static final String OUTBOUND_MESSAGE = "Test message";
29  
30      public TransformerAttributeTestCase(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/transformer-attribute-test-service.xml"},
40              {ConfigVariant.FLOW, "vm/transformer-attribute-test-flow.xml"}
41          });
42      }
43  
44      @Test
45      public void testSimple() throws Exception
46      {
47          MuleMessage message = new MuleClient(muleContext).send("vm://simple", OUTBOUND_MESSAGE, null);
48          assertNotNull(message);
49          assertEquals(StringAppendTestTransformer.appendDefault(OUTBOUND_MESSAGE)  + " Received",
50                  message.getPayloadAsString());
51      }
52  
53      @Test
54      public void testThrough() throws Exception
55      {
56          MuleMessage message = new MuleClient(muleContext).send("vm://chained", OUTBOUND_MESSAGE, null);
57          assertNotNull(message);
58          assertEquals(StringAppendTestTransformer.appendDefault(OUTBOUND_MESSAGE)  + " Received",
59                  message.getPayloadAsString());
60      }
61  
62  }