View Javadoc

1   /*
2    * $Id: MultipleResourcesTestCase.java 19270 2010-09-01 10:37:41Z 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.module.jersey;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
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  /**
23   * Tests that the jersey:resources component can handle multiple components
24   * correctly.
25   */
26  public class MultipleResourcesTestCase extends FunctionalTestCase
27  {
28  
29      public void testParams() throws Exception
30      {
31          MuleClient client = new MuleClient(muleContext);
32  
33          Map<String, String> props = new HashMap<String, String>();
34          props.put(HttpConnector.HTTP_METHOD_PROPERTY, HttpConstants.METHOD_GET);
35          MuleMessage result = client.send("http://localhost:63081/helloworld/sayHelloWithUri/Dan", "", props);
36          assertEquals((Integer)200, result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
37          assertEquals("Hello Dan", result.getPayloadAsString());
38  
39          result = client.send("http://localhost:63081/anotherworld/sayHelloWithUri/Dan", "", props);
40          assertEquals((Integer)200, result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
41          assertEquals("Bonjour Dan", result.getPayloadAsString());
42      }
43  
44      @Override
45      protected String getConfigResources()
46      {
47          return "multiple-resources-conf.xml";
48      }
49  
50  }