View Javadoc

1   /*
2    * $Id: HttpPostTestCase.java 22421 2011-07-15 05:05:06Z dirk.olmes $
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.test.usecases.http;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  
17  import java.util.Arrays;
18  import java.util.Collection;
19  
20  import org.junit.Test;
21  import org.junit.runners.Parameterized.Parameters;
22  
23  import static org.junit.Assert.assertEquals;
24  import static org.junit.Assert.assertNotNull;
25  
26  public class HttpPostTestCase extends AbstractServiceAndFlowTestCase
27  {
28      @Parameters
29      public static Collection<Object[]> parameters()
30      {
31          return Arrays.asList(new Object[][]{
32              {ConfigVariant.SERVICE, "org/mule/test/usecases/http/http-post-service.xml"},
33              {ConfigVariant.FLOW, "org/mule/test/usecases/http/http-post-flow.xml"}
34          });
35      }
36  
37      public HttpPostTestCase(ConfigVariant variant, String configResources)
38      {
39          super(variant, configResources);
40      }
41  
42      @Test
43      public void testPost() throws Exception
44      {
45          MuleClient client = new MuleClient(muleContext);
46          MuleMessage message = client.send("httpRequest", "payload", null);
47          assertNotNull(message);
48          assertNotNull(message.getPayloadAsString());
49          assertEquals("IncidentData=payload", message.getPayloadAsString());
50      }
51  }