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.integration.components;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertEquals;
16  import static org.junit.Assert.assertNotNull;
17  import static org.junit.Assert.assertNull;
18  
19  /**
20   * This test re-written to use entry point resolvers.  As a consequence, some tests, which verified
21   * implementation details rather than functionality, were dropped.
22   */
23  public class NoArgsCallComponentTestCase extends FunctionalTestCase
24  {
25  
26      public static final String INPUT_DC_QUEUE_NAME = "vm://in";
27      public static final String OUTPUT_DC_QUEUE_NAME = "vm://out";
28      public static final String INPUT_DI_QUEUE_NAME = "vm://invokeWithInjected";
29      public static final String OUTPUT_DI_QUEUE_NAME = "vm://outWithInjected";
30  
31      public static final String DEFAULT_INPUT_MESSAGE = "test";
32      public static final String DEFUALT_OUTPUT_MESSAGE = "Just an apple.";
33  
34      public static final int TIMEOUT = 5000;
35  
36      @Override
37      protected String getConfigResources()
38      {
39          return "org/mule/test/integration/components/no-args-call-component-functional-test.xml";
40      }
41  
42      @Test
43      public void testDelegateClass() throws Exception
44      {
45          MuleClient client = new MuleClient(muleContext);
46          client.dispatch(INPUT_DC_QUEUE_NAME, "test", null);
47          MuleMessage message = client.request(OUTPUT_DC_QUEUE_NAME, TIMEOUT);
48          assertNotNull(message);
49          assertEquals(message.getPayload(), DEFUALT_OUTPUT_MESSAGE);
50          client.dispose();
51      }
52  
53      @Test
54      public void testWithInjectedDelegate() throws Exception
55      {
56          MuleClient client = new MuleClient(muleContext);
57          client.dispatch(INPUT_DI_QUEUE_NAME, DEFAULT_INPUT_MESSAGE, null);
58          MuleMessage reply = client.request(OUTPUT_DI_QUEUE_NAME, TIMEOUT);
59          assertNotNull(reply);
60          assertNull(reply.getExceptionPayload());
61          // same as original input
62          assertEquals(DEFAULT_INPUT_MESSAGE, reply.getPayload());
63      }
64  
65  }