1   /*
2    * $Id: RESTTestCase.java 12238 2008-07-06 22:13:50Z 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.components;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.FunctionalTestCase;
17  
18  public class RESTTestCase extends FunctionalTestCase
19  {
20      
21      protected String getConfigResources()
22      {
23          return "/rest-functional-test.xml";
24      }
25      
26      public void testRest1ParamPost() throws Exception
27      {
28          MuleClient client = new MuleClient();
29          MuleMessage reply  = client.send("vm://in1", new DefaultMuleMessage("IBM"));
30          
31          assertNotNull(reply);
32          assertNotNull(reply.getPayloadAsString());
33          assertTrue(reply.getPayloadAsString().indexOf("Symbol>IBM<") > -1);
34      }
35      
36      public void testRest2ParamsPost() throws Exception
37      {
38          MuleClient client = new MuleClient();
39          MuleMessage reply  = client.send("vm://in2", new DefaultMuleMessage(new Object[]{"MTL","MTL"}));
40          
41          assertNotNull(reply.getPayloadAsString());
42          assertTrue(reply.getPayloadAsString().indexOf(">1</double>") > -1);
43      }
44      
45      public void testRest1ParamGet() throws Exception
46      {
47          MuleClient client = new MuleClient();
48          MuleMessage reply  = client.send("vm://in3", new DefaultMuleMessage(new Object[]{"IBM"}));
49          
50          assertNotNull(reply);
51          String replyStr = reply.getPayloadAsString();
52          assertNotNull(replyStr);
53          assertTrue("'Symbol&gt;IBM&lt;' not found in reply: " + replyStr, replyStr.indexOf("Symbol&gt;IBM&lt;") > -1);
54      }
55      
56      public void testRest2ParamsGet() throws Exception
57      {
58          MuleClient client = new MuleClient();
59          MuleMessage reply  = client.send("vm://in4", new DefaultMuleMessage(new Object[]{"MTL","MTL"}));
60          
61          String replyStr = reply.getPayloadAsString();
62          assertNotNull(replyStr);
63          assertTrue("'>1</double>' not found in reply: " + replyStr, replyStr.indexOf(">1</double>") > -1);
64      }
65  
66  }
67  
68