1
2
3
4
5
6
7
8
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>IBM<' not found in reply: " + replyStr, replyStr.indexOf("Symbol>IBM<") > -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