* this pattern is used for HATEOAS or similar apis which return urls for
* further requests. If we don't replace here, the test cannot be bound to
* the same MWS instance as it was created with.
*/
private QueueDispatcher replaceURLWithLocalhostPort(final int port) {
return new QueueDispatcher() {
protected final BlockingQueue<MockResponse> responseQueue = new LinkedBlockingQueue<MockResponse>();
@Override
public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
MockResponse response = responseQueue.take();