private HttpExchange prepareExchange(String pUri) throws URISyntaxException {
return prepareExchange(pUri,"Origin",null);
}
private HttpExchange prepareExchange(String pUri,String ... pHeaders) throws URISyntaxException {
HttpExchange exchange = EasyMock.createMock(HttpExchange.class);
URI uri = new URI(pUri);
expect(exchange.getRequestURI()).andReturn(uri);
expect(exchange.getRemoteAddress()).andReturn(new InetSocketAddress(8080));
Headers headers = new Headers();
expect(exchange.getRequestHeaders()).andReturn(headers).anyTimes();
for (int i = 0; i < pHeaders.length; i += 2) {
headers.set(pHeaders[i], pHeaders[i + 1]);
}
return exchange;
}