View Javadoc

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