1
2
3
4
5
6
7 package org.mule.test.integration.construct;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.api.client.LocalMuleClient;
11 import org.mule.tck.junit4.FunctionalTestCase;
12 import org.mule.transport.http.HttpConnector;
13 import org.mule.transport.http.HttpConstants;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.junit.Test;
19
20 import static org.junit.Assert.assertEquals;
21
22 public class SimpleServiceTestCase extends FunctionalTestCase
23 {
24
25 private LocalMuleClient muleClient;
26
27 public SimpleServiceTestCase()
28 {
29 setDisposeContextPerClass(true);
30 }
31
32 @Override
33 protected void doSetUp() throws Exception
34 {
35 super.doSetUp();
36 muleClient = muleContext.getClient();
37 }
38
39 @Override
40 protected String getConfigResources()
41 {
42 return "org/mule/test/integration/construct/simple-service-config.xml";
43 }
44
45 @Test
46 public void testJaxRsService() throws Exception
47 {
48 final Map<String, Object> props = new HashMap<String, Object>();
49 props.put(HttpConnector.HTTP_METHOD_PROPERTY, HttpConstants.METHOD_POST);
50 props.put(HttpConstants.HEADER_CONTENT_TYPE, "application/xml");
51 final MuleMessage result = muleClient.send("http://localhost:6099/rest/weather-report",
52 "<fake_report/>", props);
53 assertEquals((Integer) 201, result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
54 }
55 }
56
57