use of org.eclipse.scout.rt.shared.http.IHttpTransportManager in project scout.rt by eclipse.
the class HttpServiceTunnelTest method testTunnel.
@Test
public void testTunnel() throws IOException {
when(mockUrl.getValue()).thenReturn("http://localhost");
final MockLowLevelHttpResponse expectedResponse = new MockLowLevelHttpResponse().setContent(getInputStream(new ServiceTunnelResponse("testData", new Object[] {})));
HttpServiceTunnel tunnel = new HttpServiceTunnel() {
@Override
protected IHttpTransportManager getHttpTransportManager() {
return new IHttpTransportManager() {
private MockHttpTransport m_transport = new MockHttpTransport.Builder().setLowLevelHttpResponse(expectedResponse).build();
@Override
public HttpTransport getHttpTransport() {
return m_transport;
}
@Override
public HttpRequestFactory getHttpRequestFactory() {
return m_transport.createRequestFactory();
}
@Override
public void interceptNewHttpTransport(IHttpTransportBuilder builder) {
// nop
}
};
}
};
tunnel.setContentHandler(getTestContentHandler());
ServiceTunnelRequest request = new ServiceTunnelRequest("IPingService", "ping", null, null);
ServiceTunnelResponse response = tunnel.tunnel(request);
assertNotNull(response);
}
Aggregations