View Javadoc

1   /*
2    * $Id: PropertyScribblingMule893TestCase.java 22431 2011-07-18 07:40:35Z 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.issues;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.config.MuleProperties;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.junit4.FunctionalTestCase;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.junit.Test;
22  
23  import static org.junit.Assert.assertEquals;
24  import static org.junit.Assert.assertNotNull;
25  
26  public class PropertyScribblingMule893TestCase extends FunctionalTestCase
27  {
28  
29      @Override
30      protected String getConfigResources()
31      {
32          return "issues/property-scribbling-mule-893-test.xml";
33      }
34  
35      @Test
36      public void testSingleMessage() throws Exception
37      {
38          MuleClient client = new MuleClient(muleContext);
39          Map<String, Object> properties = new HashMap<String, Object>();
40          properties.put(MuleProperties.MULE_REPLY_TO_PROPERTY, "receive");
41          
42          client.dispatch("dispatch", "Message", properties);
43          MuleMessage response = client.request("receive", 3000L);
44          assertNotNull("Response is null", response);
45          assertEquals("Message Received", response.getPayload());
46      }
47  
48      @Test
49      public void testManyMessages() throws Exception
50      {
51          for (int i = 0; i < 1000; i++)
52          {
53              testSingleMessage();
54          }
55      }
56  
57  }