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.properties;
8   
9   import org.mule.DefaultMuleMessage;
10  import org.mule.api.MuleMessage;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertEquals;
17  
18  public class ChainingRouterSessionPropertiesTestCase extends FunctionalTestCase
19  {
20  
21      public static final String EXPECTED_MESSAGE = "First property value is sessionProp1Val other property value is sessionProp2Val.";
22  
23      @Override
24  	protected String getConfigResources()
25      {
26  		return "org/mule/test/properties/chaining-router-session-properties.xml";
27  	}
28  	
29  	@Test
30      public void testSettingPropertyAfterCallingEndpoints() throws Exception {
31  		MuleClient client = new MuleClient(muleContext);
32  		MuleMessage msg = new DefaultMuleMessage("test", muleContext);
33  		msg = client.send("vm://Service1Request", msg);
34  		assertEquals(EXPECTED_MESSAGE, msg.getPayload());
35  		
36  	}
37  	
38  	@Test
39      public void testSettingPropertyBeforeCallingEndpoints() throws Exception
40      {
41  		MuleClient client = new MuleClient(muleContext);
42  		MuleMessage msg = new DefaultMuleMessage("test", muleContext);
43  		msg = client.send("vm://Service2Request", msg);
44  		assertEquals(EXPECTED_MESSAGE, msg.getPayload());
45  	}
46  
47  }