use of com.predic8.wsdl.Port in project service-proxy by membrane.
the class ReverseProxyingInterceptorTest method getRewrittenDestination.
/**
* Lets the ReverseProxyingInterceptor handle a fake Exchange and returns the rewritten "Destination" header.
*/
private String getRewrittenDestination(String requestHostHeader, String requestDestinationHeader, int port, String requestURI, String targetScheme, int targetPort) throws Exception {
Exchange exc = createExchange(requestHostHeader, requestDestinationHeader, port, requestURI, null);
String url = new URL(targetScheme, "target", targetPort, exc.getRequest().getUri()).toString();
exc.getDestinations().add(url);
Assert.assertEquals(Outcome.CONTINUE, rp.handleRequest(exc));
return exc.getRequest().getHeader().getFirstValue(Header.DESTINATION);
}
use of com.predic8.wsdl.Port 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;
}
use of com.predic8.wsdl.Port in project service-proxy by membrane.
the class ReverseProxyingInterceptorTest method getRewrittenRedirectionLocation.
/**
* Lets the ReverseProxyingInterceptor handle a fake Exchange and returns the rewritten "Location" header.
*/
private String getRewrittenRedirectionLocation(String requestHostHeader, int port, String requestURI, String redirectionURI) throws Exception {
Exchange exc = createExchange(requestHostHeader, null, port, requestURI, redirectionURI);
Assert.assertEquals(Outcome.CONTINUE, rp.handleResponse(exc));
return exc.getResponse().getHeader().getFirstValue(Header.LOCATION);
}
use of com.predic8.wsdl.Port in project service-proxy by membrane.
the class WsaEndpointRewriterTest method testRewriteEndpointAddress.
@Test
public void testRewriteEndpointAddress() throws XMLStreamException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
WsaEndpointRewriter rewriter = new WsaEndpointRewriter(new DecoupledEndpointRegistry());
int port = 2000;
rewriter.rewriteEndpoint(input, output, port, new Exchange(null));
String rewrittenXml = output.toString();
System.out.println(rewrittenXml);
assertTrue(rewrittenXml.contains("<Address>http://localhost:" + port + "/decoupled_endpoint</Address>"));
}
use of com.predic8.wsdl.Port in project service-proxy by membrane.
the class MyApplication method main.
public static void main(String[] args) throws Exception {
System.out.println("Starting up");
// create a new service proxy that listens on port 8080 and has a target to localhost:2001
ServiceProxy sp = createServiceProxy();
// create an enclosing WebSocket interceptor to add our own Logging interceptor to it
WebSocketInterceptor ws = new WebSocketInterceptor();
ws.getInterceptors().add(new MyWebSocketLogInterceptor());
// attach the WebSocket interceptor to the service proxy
sp.getInterceptors().add(ws);
// add the service proxy to a new router instance and start it
HttpRouter router = new HttpRouter();
router.add(sp);
router.init();
System.out.println("Starting finished - Waiting for WebSocket communication");
}
Aggregations