View Javadoc

1   /*
2    * $Id: ComponentBindingTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
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.routing.nested;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.transport.NullPayload;
17  
18  import java.util.Date;
19  
20  public class ComponentBindingTestCase extends FunctionalTestCase
21  {
22      private static final int number = 0xC0DE;
23  
24      @Override
25      protected String getConfigResources()
26      {
27          return "org/mule/test/integration/routing/nested/interface-binding-test.xml";
28      }
29  
30      private void internalTest(String prefix) throws Exception
31      {
32          MuleClient client = new MuleClient(muleContext);
33          String message = "Mule";
34          client.dispatch(prefix + "invoker.in", message, null);
35          MuleMessage reply = client.request(prefix + "invoker.out", RECEIVE_TIMEOUT);
36          assertNotNull(reply);
37          assertNull(reply.getExceptionPayload());
38          assertEquals("Received: Hello " + message + " " + number, reply.getPayload());
39      }
40  
41      private void internalNullTest(String prefix) throws Exception
42      {
43          MuleClient client = new MuleClient(muleContext);
44          Date message = new Date();
45          client.dispatch(prefix + "invoker.in", message, null);
46          MuleMessage reply = client.request(prefix + "invoker.out", RECEIVE_TIMEOUT);
47          assertNotNull(reply);
48          assertNull(reply.getExceptionPayload());
49          assertEquals(NullPayload.getInstance(), reply.getPayload());
50      }
51  
52      public void testVmBinding() throws Exception
53      {
54          internalTest("vm://");
55      }
56  
57      public void testJmsQueueBinding() throws Exception
58      {
59          internalTest("jms://");
60      }
61  
62      public void testJmsTopicBinding() throws Exception
63      {
64          internalTest("jms://topic:t");
65      }
66  
67      public void testVmBindingReturnNull() throws Exception
68      {
69          internalNullTest("vm://");
70      }
71  
72      public void testJmsQueueBindingReturnNull() throws Exception
73      {
74          internalNullTest("jms://");
75      }
76  
77      public void testJmsTopicBindingReturnNull() throws Exception
78      {
79          internalNullTest("jms://topic:t");
80      }
81  }