1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.jersey;
12
13 import static org.junit.Assert.assertEquals;
14
15 import java.util.Arrays;
16 import java.util.Collection;
17 import java.util.HashMap;
18 import java.util.Map;
19
20 import org.junit.Test;
21 import org.junit.runners.Parameterized.Parameters;
22 import org.mule.api.MuleMessage;
23 import org.mule.module.client.MuleClient;
24 import org.mule.tck.AbstractServiceAndFlowTestCase;
25 import org.mule.transport.http.HttpConnector;
26 import org.mule.transport.http.HttpConstants;
27
28
29
30
31
32 public class MultipleResourcesTestCase extends AbstractServiceAndFlowTestCase
33 {
34
35 public MultipleResourcesTestCase(ConfigVariant variant, String configResources)
36 {
37 super(variant, configResources);
38 }
39
40 @Parameters
41 public static Collection<Object[]> parameters()
42 {
43 return Arrays.asList(new Object[][]{
44 {ConfigVariant.SERVICE, "multiple-resources-conf-service.xml"},
45 {ConfigVariant.FLOW, "multiple-resources-conf-flow.xml"}
46 });
47 }
48
49 @Test
50 public void testParams() throws Exception
51 {
52 MuleClient client = new MuleClient(muleContext);
53
54 Map<String, String> props = new HashMap<String, String>();
55 props.put(HttpConnector.HTTP_METHOD_PROPERTY, HttpConstants.METHOD_GET);
56 MuleMessage result = client.send("http://localhost:63081/helloworld/sayHelloWithUri/Dan", "", props);
57 assertEquals((Integer)200, result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
58 assertEquals("Hello Dan", result.getPayloadAsString());
59
60 result = client.send("http://localhost:63081/anotherworld/sayHelloWithUri/Dan", "", props);
61 assertEquals((Integer)200, result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
62 assertEquals("Bonjour Dan", result.getPayloadAsString());
63 }
64
65 }