Search in sources :

Example 1 with IHttpTransportManager

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);
}
Also used : MockLowLevelHttpResponse(com.google.api.client.testing.http.MockLowLevelHttpResponse) MockHttpTransport(com.google.api.client.testing.http.MockHttpTransport) IHttpTransportManager(org.eclipse.scout.rt.shared.http.IHttpTransportManager) ServiceTunnelRequest(org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelRequest) ServiceTunnelResponse(org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelResponse) IHttpTransportBuilder(org.eclipse.scout.rt.shared.http.IHttpTransportBuilder) Test(org.junit.Test)

Aggregations

MockHttpTransport (com.google.api.client.testing.http.MockHttpTransport)1 MockLowLevelHttpResponse (com.google.api.client.testing.http.MockLowLevelHttpResponse)1 IHttpTransportBuilder (org.eclipse.scout.rt.shared.http.IHttpTransportBuilder)1 IHttpTransportManager (org.eclipse.scout.rt.shared.http.IHttpTransportManager)1 ServiceTunnelRequest (org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelRequest)1 ServiceTunnelResponse (org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelResponse)1 Test (org.junit.Test)1