@Test
public void writeToShouldUseRequestFormParamsWithGivenCharset() throws IOException {

    Iterator<EncodedPair> pairs = asList(
            Pairs.toPair("p1", "v%201", Values.UTF8, true),
            Pairs.toPair("p2", "v£ 1", Values.UTF8, false)
    ).iterator();
    Request mockRequest = mockRequest();
    when(mockRequest.getEncodedParamsIterator(ParamType.FORM)).thenReturn(pairs);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    toTest.writeTo(mockRequest, out);
    assertEquals("p1=v%201&p2=v%C2%A3%201", out.toString("utf-8"));
}