1   /*
2    * $Id: HttpTransformersMule1822TestCase.java 12017 2008-06-12 09:04:04Z rossmason $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.transport.http.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 HttpTransformersMule1822TestCase extends FunctionalTestCase
20  {
21  
22      public static final String OUTBOUND_MESSAGE = "Test message";
23  
24      protected String getConfigResources()
25      {
26          return "http-transformers-mule-1822-test.xml";
27      }
28  
29      private MuleMessage sendTo(String uri) throws MuleException
30      {
31          MuleClient client = new MuleClient();
32          MuleMessage message = client.send(uri, OUTBOUND_MESSAGE, null);
33          assertNotNull(message);
34          return message;
35      }
36  
37      /**
38       * With no transformer we expect just the modification from the FTC
39       *
40       * @throws Exception
41       */
42      public void testBase() throws Exception
43      {
44          assertEquals(OUTBOUND_MESSAGE  + " Received",
45                  sendTo("base").getPayloadAsString());
46      }
47  
48      /**
49       * But response transformers on the base model should be applied
50       *
51       * @throws Exception
52       */
53      public void testResponse() throws Exception
54      {
55          assertEquals(
56                  StringAppendTestTransformer.append(" response",
57                          StringAppendTestTransformer.append(" response 2",
58                                          OUTBOUND_MESSAGE + " Received")),
59                  sendTo("response").getPayloadAsString());
60      }
61  
62      /**
63       * Shouldalso work with inbound transformers
64       *
65       * @throws Exception
66       */
67      public void testBoth() throws Exception
68      {
69          assertEquals(
70                  StringAppendTestTransformer.append(" response",
71                          StringAppendTestTransformer.append(" response 2",
72                                          StringAppendTestTransformer.append(" transformed 2",
73                                                  StringAppendTestTransformer.appendDefault(
74                                          OUTBOUND_MESSAGE)) + " Received")),
75                  sendTo("both").getPayloadAsString());
76      }
77  
78  }