View Javadoc

1   /*
2    * $Id: SimpleServiceTestCase.java 19268 2010-09-01 07:01:05Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.test.integration.construct;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.client.LocalMuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.transport.http.HttpConnector;
17  import org.mule.transport.http.HttpConstants;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  public class SimpleServiceTestCase extends FunctionalTestCase
23  {
24      private LocalMuleClient muleClient;
25  
26      @Override
27      protected void doSetUp() throws Exception
28      {
29          super.setDisposeManagerPerSuite(true);
30          super.doSetUp();
31          muleClient = muleContext.getClient();
32      }
33  
34      @Override
35      protected String getConfigResources()
36      {
37          return "org/mule/test/integration/construct/simple-service-config.xml";
38      }
39  
40      public void testJaxRsService() throws Exception
41      {
42          final Map<String, Object> props = new HashMap<String, Object>();
43          props.put(HttpConnector.HTTP_METHOD_PROPERTY, HttpConstants.METHOD_POST);
44          props.put(HttpConstants.HEADER_CONTENT_TYPE, "application/xml");
45          final MuleMessage result = muleClient.send("http://localhost:6099/rest/weather-report",
46              "<fake_report/>", props);
47          assertEquals((Integer) 201, result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
48      }
49  }
50  
51