View Javadoc

1   /*
2    * $Id: EndpointTransformerMule2131TestCase.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.issues;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.tck.functional.StringAppendTestTransformer;
18  
19  public class EndpointTransformerMule2131TestCase extends FunctionalTestCase
20  {
21  
22      public static final String MESSAGE = "a message";
23  
24      public EndpointTransformerMule2131TestCase()
25      {
26          setDisposeManagerPerSuite(true);
27      }
28  
29      protected String getConfigResources()
30      {
31          return "issues/endpoint-transformer-mule-2131-test.xml";
32      }
33  
34      protected MuleClient send() throws MuleException
35      {
36          MuleClient client = new MuleClient(muleContext);
37          client.dispatch("in", MESSAGE, null);
38          return client;
39      }
40  
41      public void testDirect() throws Exception
42      {
43          String response = request(send(), "direct");
44          assertEquals(MESSAGE, response);
45      }
46  
47      /* TODO This behaviour changed with BL-137, is this acceptable?
48      public void testGlobalNameGlobalTransformer() throws Exception
49      {
50          String response = request(send(), "global-name-global-transformer");
51          // Transformer is applied twice because it is on global endpoint and is
52          // therfore
53          // used for both the inbound and outbound endpoints because both use the
54          // global endpoint name and thus use the global endpoint as a template
55          assertEquals(MESSAGE + StringAppendTestTransformer.DEFAULT_TEXT
56                       + StringAppendTestTransformer.DEFAULT_TEXT, response);
57      }
58      */
59  
60      public void testGlobalNameLocalTransformer() throws Exception
61      {
62          doTestTransformed("global-name-local-transformer");
63      }
64  
65      public void testNoNameLocalTransformer() throws Exception
66      {
67          doTestTransformed("vm://no-name-local-transformer");
68      }
69  
70      public void testLocalNameLocalTransformer() throws Exception
71      {
72          doTestTransformed("vm://local-name-local-transformer");
73      }
74  
75      protected void doTestTransformed(String endpoint) throws Exception
76      {
77          String response = request(send(), endpoint);
78          assertEquals(MESSAGE + StringAppendTestTransformer.DEFAULT_TEXT, response);
79      }
80  
81      protected String request(MuleClient client, String endpoint) throws Exception
82      {
83          MuleMessage message = client.request(endpoint, RECEIVE_TIMEOUT);
84          assertNotNull(message);
85          assertNotNull(message.getPayloadAsString());
86          return message.getPayloadAsString();
87      }
88  
89  }