View Javadoc

1   /*
2    * $Id: JettyHttpFunctionalWithQueryTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.servlet.jetty.functional;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.transport.DispatchException;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.FunctionalTestCase;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  public class JettyHttpFunctionalWithQueryTestCase extends FunctionalTestCase
22  {
23      @Override
24      protected String getConfigResources()
25      {
26          return "jetty-http-functional-test-with-query.xml";
27      }
28  
29      public void testSend() throws Exception
30      {
31          MuleClient client = new MuleClient(muleContext);
32          Map<String, Object> props = new HashMap<String, Object>();
33          MuleMessage result = client.send("clientEndpoint1", null, props);
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();
58          }
59          catch (DispatchException ex)
60          {
61              // this one was expected
62          }
63      }
64  }