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