private void doTest(String fromRegexp, String toReplacement, String[] chunks, String expectedResult) {
        IBufferFactoryComponent bufferFactory = new ByteBufferFactoryComponent();
        URLRewritingStream stream = new URLRewritingStream(bufferFactory, (ApiResponse) null, fromRegexp, toReplacement);
        RecordingHandler handler = new RecordingHandler(bufferFactory.createBuffer());
        stream.bodyHandler(handler);
        stream.endHandler(new IAsyncHandler<Void>() {
            @Override
            public void handle(Void result) {
            }
        });

        for (String chunk : chunks) {
            stream.write(bufferFactory.createBuffer(chunk));
        }
        stream.end();

        String result = handler.getBuffer().toString();
        Assert.assertEquals(expectedResult, result);
    }
@param fromRegexp
@param toReplacement
@param chunks
@param expectedResult
gateway/engine/policies/src/test/java/io/apiman/gateway/engine/policies/URLRewritingStreamTest.java