View Javadoc

1   /*
2    * $Id: MessageVersionCompatibilityTestCase.java 22421 2011-07-15 05:05:06Z 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.integration.message;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  
17  import java.util.Arrays;
18  import java.util.Collection;
19  
20  import org.junit.Test;
21  import org.junit.runners.Parameterized.Parameters;
22  
23  import static org.junit.Assert.assertEquals;
24  import static org.junit.Assert.assertNotNull;
25  import static org.junit.Assert.assertNull;
26  
27  /**
28   * Test case for EE-1820
29   */
30  public class MessageVersionCompatibilityTestCase extends AbstractServiceAndFlowTestCase
31  {
32      private final int TIMEOUT = 5000;
33  
34      @Parameters
35      public static Collection<Object[]> parameters()
36      {
37          return Arrays.asList(new Object[][]{
38              {ConfigVariant.SERVICE, "org/mule/test/integration/messaging/message-version-compatibility-service.xml"},
39              {ConfigVariant.FLOW, "org/mule/test/integration/messaging/message-version-compatibility-flow.xml"}
40          });
41      }
42  
43      public MessageVersionCompatibilityTestCase(ConfigVariant variant, String configResources)
44      {
45          super(variant, configResources);
46      }
47  
48      @Test
49      public void testOldToOld() throws Exception
50      {
51          MuleClient client = new MuleClient(muleContext);
52          client.dispatch("vm://in1", "test", null);
53  
54          MuleMessage reply = client.request("vm://out1", TIMEOUT);
55          assertNotNull(reply);
56          assertEquals("test", reply.getPayload());
57      }
58  
59      @Test
60      public void testOldToNew() throws Exception
61      {
62          MuleClient client = new MuleClient(muleContext);
63          client.dispatch("vm://in2", "test", null);
64  
65          MuleMessage reply = client.request("vm://out2", TIMEOUT);
66          assertNotNull(reply);
67          assertEquals("test", reply.getPayload());
68      }
69  
70      @Test
71      public void testNewToOld() throws Exception
72      {
73          MuleClient client = new MuleClient(muleContext);
74          client.dispatch("vm://in3", "test", null);
75  
76          MuleMessage reply = client.request("vm://out3", TIMEOUT);
77          // No output is received because the receiver throws an exception:
78          // "java.lang.IllegalArgumentException: Session variable ... is malfomed and cannot be read"
79          assertNull(reply);
80      }
81  
82      @Test
83      public void testNewToNew() throws Exception
84      {
85          MuleClient client = new MuleClient(muleContext);
86          client.dispatch("vm://in4", "test", null);
87  
88          MuleMessage reply = client.request("vm://out4", TIMEOUT);
89          assertNotNull(reply);
90          assertEquals("test", reply.getPayload());
91      }
92  }