1   /*
2    * $Id: HttpResponseTestCase.java 10789 2008-02-12 20:04:43Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.transport.NullPayload;
18  import org.mule.transport.http.HttpConnector;
19  
20  public class HttpResponseTestCase extends FunctionalTestCase
21  {
22      protected String getConfigResources()
23      {
24          return "org/mule/test/usecases/http/http-response.xml";
25      }
26  
27      public void testNullPayloadUsingAsync() throws Exception
28      {
29          MuleClient client = new MuleClient();
30          MuleMessage reply = client.send("http://localhost:8990", new DefaultMuleMessage("test"));
31  
32          //TODO RM: What should really be returned when doing an async request?
33          assertNotNull(reply.getPayload());
34          assertEquals(reply.getIntProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0), 200);
35          assertEquals(0, reply.getPayloadAsString().length());
36      }
37  
38      public void testPayloadIsNotEmptyNoRemoteSynch() throws Exception
39      {
40          MuleClient client = new MuleClient();
41          MuleMessage reply = client.send("http://localhost:8999", new DefaultMuleMessage("test"));
42          assertNotNull(reply.getPayload());
43          assertFalse(reply.getPayload() instanceof NullPayload);
44          assertEquals("test", reply.getPayloadAsString());
45      }
46  
47      public void testPayloadIsNotEmptyWithRemoteSynch() throws Exception
48      {
49          MuleClient client = new MuleClient();
50          MuleMessage reply = client.send("http://localhost:8989", new DefaultMuleMessage("test"));
51          assertNotNull(reply.getPayload());
52          assertFalse(reply.getPayload() instanceof NullPayload);
53          assertEquals("test", reply.getPayloadAsString());
54      }
55  }