View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.integration.message;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertEquals;
16  import static org.junit.Assert.assertNotNull;
17  import static org.junit.Assert.assertNull;
18  
19  /**
20   * Test case for EE-1820
21   */
22  public class MessageVersionCompatibilityTestCase extends FunctionalTestCase
23  {
24      private final int TIMEOUT = 5000;
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/test/integration/messaging/message-version-compatibility.xml";
30      }
31  
32      @Test
33      public void testOldToOld() throws Exception
34      {
35          MuleClient client = new MuleClient(muleContext);
36          client.dispatch("vm://in1", "test", null);
37  
38          MuleMessage reply = client.request("vm://out1", TIMEOUT);
39          assertNotNull(reply);
40          assertEquals("test", reply.getPayload());
41      }
42  
43      @Test
44      public void testOldToNew() throws Exception
45      {
46          MuleClient client = new MuleClient(muleContext);
47          client.dispatch("vm://in2", "test", null);
48  
49          MuleMessage reply = client.request("vm://out2", TIMEOUT);
50          assertNotNull(reply);
51          assertEquals("test", reply.getPayload());
52      }
53  
54      @Test
55      public void testNewToOld() throws Exception
56      {
57          MuleClient client = new MuleClient(muleContext);
58          client.dispatch("vm://in3", "test", null);
59  
60          MuleMessage reply = client.request("vm://out3", TIMEOUT);
61          // No output is received because the receiver throws an exception:
62          // "java.lang.IllegalArgumentException: Session variable ... is malfomed and cannot be read"
63          assertNull(reply);
64      }
65      
66      @Test
67      public void testNewToNew() throws Exception
68      {
69          MuleClient client = new MuleClient(muleContext);
70          client.dispatch("vm://in4", "test", null);
71  
72          MuleMessage reply = client.request("vm://out4", TIMEOUT);
73          assertNotNull(reply);
74          assertEquals("test", reply.getPayload());
75      }
76  }