View Javadoc

1   /*
2    * $Id: ExceptionStrategyMessagePropertiesTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.exceptions;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  public class ExceptionStrategyMessagePropertiesTestCase extends FunctionalTestCase
21  {
22      int numMessages = 100;
23      
24      @Override
25      protected String getConfigResources()
26      {
27          return "org/mule/test/integration/exceptions/exception-strategy-message-properties.xml";
28      }
29  
30      public void testException() throws Exception
31      {
32          Thread tester1 = new Tester();
33          Thread tester2 = new Tester();
34          tester1.start();
35          tester2.start();
36          
37          MuleClient client = new MuleClient(muleContext);
38          MuleMessage msg;
39          for (int i = 0; i < numMessages; ++i)
40          {
41              msg = client.request("vm://error", 5000);
42              assertNotNull(msg);
43              assertEquals("bar", msg.getInboundProperty("foo"));
44          }        
45      }
46      
47      class Tester extends Thread
48      {
49          @Override
50          public void run()
51          {
52              try
53              {
54                  MuleClient client = new MuleClient(muleContext);
55                  
56                  Map props = new HashMap();
57                  props.put("foo", "bar");
58                  for (int i = 0; i < numMessages; ++i)
59                  {
60                      client.dispatch("vm://in", "test", props);
61                  }    
62              }
63              catch (Exception e)
64              {
65                  fail(e.getMessage());
66              }
67          }        
68      };
69  }
70  
71