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 static org.junit.Assert.assertEquals;
10  import static org.junit.Assert.assertNull;
11  import org.mule.api.MuleMessage;
12  import org.mule.api.client.MuleClient;
13  import org.mule.tck.junit4.FunctionalTestCase;
14  import org.mule.tck.junit4.rule.DynamicPort;
15  
16  import java.util.HashMap;
17  import java.util.Map;
18  
19  import org.junit.Rule;
20  import org.junit.Test;
21  
22  public class InterfaceBindingTestCase extends FunctionalTestCase
23  {
24  
25      @Rule
26      public DynamicPort port = new DynamicPort("port");
27  
28      @Override
29      protected String getConfigResources()
30      {
31          return "interface-binding-config.xml";
32      }
33  
34      @Test
35      public void bindsComponentInterface() throws Exception
36      {
37          MuleClient client = muleContext.getClient();
38          Map headers = new HashMap();
39          headers.put("http.method", "GET");
40          MuleMessage result = client.send("http://localhost:" + port.getNumber() + "/sayHello", "", headers);
41  
42          assertNull(result.getExceptionPayload());
43          assertEquals("Hello World", result.getPayloadAsString());
44      }
45  }