View Javadoc

1   /*
2    * $Id: JettyHttpFunctionalWithQueryTestCase.java 22552 2011-07-25 07:18:19Z claude.mamo $
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 static org.junit.Assert.assertEquals;
14  
15  import org.mule.api.MuleMessage;
16  import org.mule.api.transport.DispatchException;
17  import org.mule.module.client.MuleClient;
18  import org.mule.tck.AbstractServiceAndFlowTestCase;
19  
20  import java.util.Arrays;
21  import java.util.Collection;
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  import org.junit.Test;
26  import org.junit.runners.Parameterized.Parameters;
27  
28  public class JettyHttpFunctionalWithQueryTestCase extends AbstractServiceAndFlowTestCase
29  {
30      public JettyHttpFunctionalWithQueryTestCase(ConfigVariant variant, String configResources)
31      {
32          super(variant, configResources);
33      }
34  
35      @Parameters
36      public static Collection<Object[]> parameters()
37      {
38          return Arrays.asList(new Object[][]{
39              {ConfigVariant.SERVICE, "jetty-http-functional-test-with-query-service.xml"},
40              {ConfigVariant.FLOW, "jetty-http-functional-test-with-query-flow.xml"}
41          });
42      }      
43      
44      @Test
45      public void testSend() throws Exception
46      {
47          MuleClient client = new MuleClient(muleContext);
48          Map<String, Object> props = new HashMap<String, Object>();
49          MuleMessage result = client.send("clientEndpoint1", null, props);
50          assertEquals("boobar", result.getPayloadAsString());
51      }
52  
53      @Test
54      public void testSendWithParams() throws Exception
55      {
56          MuleClient client = new MuleClient(muleContext);
57          Map<String, Object> props = new HashMap<String, Object>();
58          props.put("foo", "noo");
59          props.put("far", "nar");
60          MuleMessage result = client.send("clientEndpoint2", null, props);
61          assertEquals("noonar", result.getPayloadAsString());
62      }
63  
64      @Test(expected = DispatchException.class)
65      public void testSendWithBadParams() throws Exception
66      {
67          MuleClient client = new MuleClient(muleContext);
68          Map<String, Object> props = new HashMap<String, Object>();
69          props.put("hoo", "noo");
70          props.put("har", "nar");
71  
72          client.send("clientEndpoint2", null, props);
73      }
74  }