View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.jersey;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
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  /**
23   * Tests that the jersey:resources component can handle multiple components
24   * correctly.
25   */
26  public class MultipleResourcesTestCase extends FunctionalTestCase
27  {
28  
29      @Override
30      protected String getConfigResources()
31      {
32          return "multiple-resources-conf.xml";
33      }
34  
35      @Test
36      public void testParams() throws Exception
37      {
38          MuleClient client = new MuleClient(muleContext);
39  
40          Map<String, String> props = new HashMap<String, String>();
41          props.put(HttpConnector.HTTP_METHOD_PROPERTY, HttpConstants.METHOD_GET);
42          MuleMessage result = client.send("http://localhost:63081/helloworld/sayHelloWithUri/Dan", "", props);
43          assertEquals((Integer)200, result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
44          assertEquals("Hello Dan", result.getPayloadAsString());
45  
46          result = client.send("http://localhost:63081/anotherworld/sayHelloWithUri/Dan", "", props);
47          assertEquals((Integer)200, result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
48          assertEquals("Bonjour Dan", result.getPayloadAsString());
49      }
50  
51  }