View Javadoc

1   /*
2    * $Id: HttpPollingFunctionalTestCase.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.MuleEventContext;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.DynamicPortTestCase;
17  import org.mule.tck.functional.EventCallback;
18  import org.mule.tck.functional.FunctionalTestComponent;
19  
20  public class HttpPollingFunctionalTestCase extends DynamicPortTestCase
21  {
22  
23      public void testPollingHttpConnector() throws Exception
24      {
25          FunctionalTestComponent ftc = getFunctionalTestComponent("polled");
26          assertNotNull(ftc);
27          ftc.setEventCallback(new EventCallback(){
28              public void eventReceived(MuleEventContext context, Object component) throws Exception
29              {
30                  assertEquals("The Accept header should be set on the incoming message", "application/xml", context.getMessage().<String>getInboundProperty("Accept"));
31              }
32          });
33          MuleClient client = new MuleClient(muleContext);
34          MuleMessage result = client.request("vm://toclient", RECEIVE_TIMEOUT);
35          assertNotNull(result.getPayload());
36          assertEquals("foo", result.getPayloadAsString());
37      }
38      
39      protected String getConfigResources()
40      {
41          return "mule-http-polling-config.xml";
42      }
43  
44      @Override
45      protected int getNumPortsToFind()
46      {
47          return 1;
48      }
49  
50  }