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