1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.servlet;
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 public RESTTestCase()
21 {
22 super();
23
24
25
26 setFailOnTimeout(false);
27 }
28
29 protected String getConfigResources()
30 {
31 return "rest-functional-test.xml";
32 }
33
34 public void testRest1ParamPost() throws Exception
35 {
36 MuleClient client = new MuleClient(muleContext);
37 MuleMessage reply = client.send("vm://in1", new DefaultMuleMessage("IBM", muleContext));
38
39 assertNotNull(reply);
40 assertNotNull(reply.getPayloadAsString());
41 assertTrue(reply.getPayloadAsString().indexOf("Symbol>IBM<") > -1);
42 }
43
44 public void testRest2ParamsPost() throws Exception
45 {
46 MuleClient client = new MuleClient(muleContext);
47 MuleMessage reply = client.send("vm://in2", new DefaultMuleMessage(new Object[]{"MTL","MTL"}, muleContext));
48
49 assertNotNull(reply.getPayloadAsString());
50 assertTrue(reply.getPayloadAsString().indexOf(">1</double>") > -1);
51 }
52
53 public void testRest1ParamGet() throws Exception
54 {
55 MuleClient client = new MuleClient(muleContext);
56 MuleMessage reply = client.send("vm://in3", new DefaultMuleMessage(new Object[]{"IBM"}, muleContext));
57
58 assertNotNull(reply);
59 String replyStr = reply.getPayloadAsString();
60 assertNotNull(replyStr);
61 assertTrue("'Symbol>IBM<' not found in reply: " + replyStr, replyStr.indexOf("Symbol>IBM<") > -1);
62 }
63
64 public void testRest2ParamsGet() throws Exception
65 {
66 MuleClient client = new MuleClient(muleContext);
67 MuleMessage reply = client.send("vm://in4", new DefaultMuleMessage(new Object[]{"MTL","MTL"}, muleContext));
68
69 String replyStr = reply.getPayloadAsString();
70 assertNotNull(replyStr);
71 assertTrue("'>1</double>' not found in reply: " + replyStr, replyStr.indexOf(">1</double>") > -1);
72 }
73
74 }
75
76