1
2
3
4
5
6
7 package org.mule.transport.http.functional;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.api.expression.RequiredValueException;
11 import org.mule.api.transport.DispatchException;
12 import org.mule.module.client.MuleClient;
13 import org.mule.tck.junit4.FunctionalTestCase;
14 import org.mule.tck.junit4.rule.DynamicPort;
15
16 import java.util.HashMap;
17 import java.util.Map;
18
19 import org.junit.Rule;
20 import org.junit.Test;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertTrue;
24 import static org.junit.Assert.fail;
25
26 public class HttpFunctionalWithQueryTestCase extends FunctionalTestCase
27 {
28
29 @Rule
30 public DynamicPort dynamicPort = new DynamicPort("port1");
31
32 @Override
33 protected String getConfigResources()
34 {
35 return "http-functional-test-with-query.xml";
36 }
37
38 @Test
39 public void testSend() throws Exception
40 {
41 MuleClient client = new MuleClient(muleContext);
42 MuleMessage result = client.send("clientEndpoint1", null, null);
43 assertEquals("boobar", result.getPayloadAsString());
44 }
45
46 @Test
47 public void testSendWithParams() throws Exception
48 {
49 MuleClient client = new MuleClient(muleContext);
50 Map<String, Object> props = new HashMap<String, Object>();
51 props.put("foo", "noo");
52 props.put("far", "nar");
53 MuleMessage result = client.send("clientEndpoint2", null, props);
54 assertEquals("noonar", result.getPayloadAsString());
55 }
56
57 @Test
58 public void testSendWithBadParams() throws Exception
59 {
60 MuleClient client = new MuleClient(muleContext);
61 Map<String, Object> props = new HashMap<String, Object>();
62 props.put("hoo", "noo");
63 props.put("har", "nar");
64
65 try
66 {
67 client.send("clientEndpoint2", null, props);
68 fail("Required values missing");
69 }
70 catch (DispatchException e)
71 {
72
73 assertTrue(e.getCause() instanceof RequiredValueException);
74 }
75 }
76 }