1
2
3
4
5
6
7 package org.mule.transport.http.functional;
8
9 import org.mule.api.MuleEventContext;
10 import org.mule.api.MuleMessage;
11 import org.mule.module.client.MuleClient;
12 import org.mule.tck.functional.EventCallback;
13 import org.mule.tck.functional.FunctionalTestComponent;
14 import org.mule.tck.junit4.FunctionalTestCase;
15 import org.mule.tck.junit4.rule.DynamicPort;
16
17 import org.junit.Rule;
18 import org.junit.Test;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertNotNull;
22
23 public class HttpPollingFunctionalTestCase extends FunctionalTestCase
24 {
25
26 @Rule
27 public DynamicPort dynamicPort = new DynamicPort("port1");
28
29 @Override
30 protected String getConfigResources()
31 {
32 return "mule-http-polling-config.xml";
33 }
34
35 @Test
36 public void testPollingHttpConnector() throws Exception
37 {
38 FunctionalTestComponent ftc = getFunctionalTestComponent("polled");
39 assertNotNull(ftc);
40 ftc.setEventCallback(new EventCallback(){
41 public void eventReceived(MuleEventContext context, Object component) throws Exception
42 {
43 assertEquals("The Accept header should be set on the incoming message", "application/xml", context.getMessage().<String>getInboundProperty("Accept"));
44 }
45 });
46 MuleClient client = new MuleClient(muleContext);
47 MuleMessage result = client.request("vm://toclient", RECEIVE_TIMEOUT);
48 assertNotNull(result.getPayload());
49 assertEquals("foo", result.getPayloadAsString());
50 }
51
52 }