Search in sources :

Example 1 with FakeHttpHandler

use of com.predic8.membrane.core.transport.http.FakeHttpHandler in project service-proxy by membrane.

the class WSDLInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    exc = new Exchange(new FakeHttpHandler(3011));
    exc.setRequest(MessageUtil.getGetRequest("/axis2/services/BLZService?wsdl"));
    InputStream resourceAsStream = this.getClass().getResourceAsStream("/blz-service.wsdl");
    Response okResponse = Response.ok().contentType("text/xml; charset=utf-8").body(resourceAsStream, true).build();
    exc.setResponse(okResponse);
    exc.setOriginalHostHeader("thomas-bayer.com:80");
    interceptor = new WSDLInterceptor();
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Response(com.predic8.membrane.core.http.Response) InputStream(java.io.InputStream) FakeHttpHandler(com.predic8.membrane.core.transport.http.FakeHttpHandler) Before(org.junit.Before)

Example 2 with FakeHttpHandler

use of com.predic8.membrane.core.transport.http.FakeHttpHandler in project service-proxy by membrane.

the class ReverseProxyingInterceptorTest method createExchange.

/**
 * Creates a fake exchange which simulates a received redirect by the server.
 */
private Exchange createExchange(String requestHostHeader, String requestDestinationHeader, int port, String requestURI, String redirectionURI) {
    Exchange exc = new Exchange(new FakeHttpHandler(port));
    Request req = new Request();
    req.setUri(requestURI);
    Header header = new Header();
    if (requestHostHeader != null)
        header.setHost(requestHostHeader);
    if (requestDestinationHeader != null)
        header.add(Header.DESTINATION, requestDestinationHeader);
    req.setHeader(header);
    exc.setRequest(req);
    if (redirectionURI != null) {
        Response res = Response.redirect(redirectionURI, false).build();
        exc.setResponse(res);
        exc.getDestinations().add(requestURI);
    }
    return exc;
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Response(com.predic8.membrane.core.http.Response) Header(com.predic8.membrane.core.http.Header) FakeHttpHandler(com.predic8.membrane.core.transport.http.FakeHttpHandler) Request(com.predic8.membrane.core.http.Request)

Example 3 with FakeHttpHandler

use of com.predic8.membrane.core.transport.http.FakeHttpHandler in project service-proxy by membrane.

the class WADLInterceptorTest method getExchange.

private Exchange getExchange() throws IOException {
    Exchange exc = new Exchange(new FakeHttpHandler(3011));
    exc.setRequest(MessageUtil.getGetRequest("/search?wadl"));
    InputStream resourceAsStream = this.getClass().getResourceAsStream("/wadls/search.wadl");
    Response okResponse = Response.ok().contentType("text/xml; charset=utf-8").body(resourceAsStream, true).build();
    exc.setResponse(okResponse);
    exc.setOriginalHostHeader("thomas-bayer.com:80");
    return exc;
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Response(com.predic8.membrane.core.http.Response) InputStream(java.io.InputStream) FakeHttpHandler(com.predic8.membrane.core.transport.http.FakeHttpHandler)

Aggregations

Exchange (com.predic8.membrane.core.exchange.Exchange)3 Response (com.predic8.membrane.core.http.Response)3 FakeHttpHandler (com.predic8.membrane.core.transport.http.FakeHttpHandler)3 InputStream (java.io.InputStream)2 Header (com.predic8.membrane.core.http.Header)1 Request (com.predic8.membrane.core.http.Request)1 Before (org.junit.Before)1