1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.http.construct;
12
13 import org.mule.MessageExchangePattern;
14 import org.mule.api.MuleEvent;
15 import org.mule.api.MuleException;
16 import org.mule.api.endpoint.OutboundEndpoint;
17 import org.mule.api.lifecycle.InitialisationException;
18 import org.mule.api.transport.Connector;
19 import org.mule.construct.AbstractFlowConstruct;
20 import org.mule.construct.AbstractFlowConstuctTestCase;
21 import org.mule.tck.MuleTestUtils;
22
23 import java.util.Collections;
24
25 import static org.junit.Assert.assertEquals;
26
27 public class NoCacheHttpProxyTestCase extends AbstractFlowConstuctTestCase
28 {
29 protected Connector testConnector;
30 private HttpProxy httpProxy;
31
32 @SuppressWarnings("unchecked")
33 @Override
34 protected void doSetUp() throws Exception
35 {
36 super.doSetUp();
37
38 final OutboundEndpoint testOutboundEndpoint = MuleTestUtils.getTestOutboundEndpoint(
39 MessageExchangePattern.REQUEST_RESPONSE, muleContext);
40 testConnector = testOutboundEndpoint.getConnector();
41 muleContext.getRegistry().registerConnector(testConnector);
42 testConnector.start();
43
44 httpProxy = new HttpProxy("no-cache-http-proxy", muleContext, directInboundMessageSource,
45 testOutboundEndpoint, Collections.EMPTY_LIST, Collections.EMPTY_LIST, null);
46 }
47
48 @Override
49 protected AbstractFlowConstruct getFlowConstruct() throws Exception
50 {
51 return httpProxy;
52 }
53
54 private void startHttpProxy() throws InitialisationException, MuleException
55 {
56 httpProxy.initialise();
57 httpProxy.start();
58 }
59
60 public void testProcess() throws Exception
61 {
62 startHttpProxy();
63
64 final MuleEvent response = directInboundMessageSource.process(MuleTestUtils.getTestEvent(
65 "hello", muleContext));
66
67 assertEquals("hello", response.getMessageAsString());
68 }
69 }