View Javadoc

1   /*
2    * $Id: MessagePropertyScopesTestCase.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  import org.mule.transport.NullPayload;
17  
18  import java.util.Arrays;
19  import java.util.Collection;
20  
21  import org.junit.Ignore;
22  import org.junit.Test;
23  import org.junit.runners.Parameterized.Parameters;
24  
25  import static org.junit.Assert.assertEquals;
26  import static org.junit.Assert.assertNotNull;
27  import static org.junit.Assert.assertTrue;
28  
29  public class MessagePropertyScopesTestCase extends AbstractServiceAndFlowTestCase
30  {
31      @Parameters
32      public static Collection<Object[]> parameters()
33      {
34          return Arrays.asList(new Object[][]{
35              {ConfigVariant.SERVICE, "org/mule/test/integration/messaging/message-property-scopes-config-service.xml"},
36              {ConfigVariant.FLOW, "org/mule/test/integration/messaging/message-property-scopes-config-flow.xml"}
37          });
38      }
39  
40      public MessagePropertyScopesTestCase(ConfigVariant variant, String configResources)
41      {
42          super(variant, configResources);
43      }
44  
45      @Test
46      public void testSessionProperty() throws Exception {
47  
48          MuleClient client = new MuleClient(muleContext);
49          MuleMessage response = client.send("vm://in1", "Hello World", null);
50          assertNotNull(response);
51          String payload = response.getPayloadAsString();
52          assertNotNull(payload);
53          assertEquals("java.util.Date", payload);
54      }
55  
56      @Ignore
57      @Test
58      public void testInvocationProperty() throws Exception
59      {
60          MuleClient client = new MuleClient(muleContext);
61          MuleMessage response = client.send("vm://in2", "Hello World", null);
62          // scope = "invocation" should not propagate the property on to the next service
63          assertTrue(response.getPayload() instanceof NullPayload);
64      }
65  }