View Javadoc

1   /*
2    * $Id: HttpFunctionalWithQueryTestCase.java 19840 2010-10-05 18:32:45Z dzapata $
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.transport.http.functional;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.expression.RequiredValueException;
15  import org.mule.api.transport.DispatchException;
16  import org.mule.module.client.MuleClient;
17  import org.mule.tck.DynamicPortTestCase;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  public class HttpFunctionalWithQueryTestCase extends DynamicPortTestCase
23  {
24      @Override
25      protected String getConfigResources()
26      {
27          return "http-functional-test-with-query.xml";
28      }
29  
30      public void testSend() throws Exception
31      {
32          MuleClient client = new MuleClient(muleContext);
33          MuleMessage result = client.send("clientEndpoint1", null, null);
34          assertEquals("boobar", result.getPayloadAsString());
35      }
36  
37      public void testSendWithParams() throws Exception
38      {
39          MuleClient client = new MuleClient(muleContext);
40          Map<String, Object> props = new HashMap<String, Object>();
41          props.put("foo", "noo");
42          props.put("far", "nar");
43          MuleMessage result = client.send("clientEndpoint2", null, props);
44          assertEquals("noonar", result.getPayloadAsString());
45      }
46  
47      public void testSendWithBadParams() throws Exception
48      {
49          MuleClient client = new MuleClient(muleContext);
50          Map<String, Object> props = new HashMap<String, Object>();
51          props.put("hoo", "noo");
52          props.put("har", "nar");
53  
54          try
55          {
56              client.send("clientEndpoint2", null, props);
57              fail("Required values missing");
58          }
59          catch (DispatchException e)
60          {
61              //expected
62              assertTrue(e.getCause() instanceof RequiredValueException);
63          }
64      }
65  
66      @Override
67      protected int getNumPortsToFind()
68      {
69          return 1;
70      }
71  }