private void attemptLogin(String address, String password, boolean expectSuccess) throws IOException {
// The query string is escaped.
PercentEscaper escaper = new PercentEscaper(PercentEscaper.SAFECHARS_URLENCODER, true);
String data =
"address=" + escaper.escape(address) + "&" + "password=" + escaper.escape(password);
Reader reader = new StringReader(data);
when(req.getReader()).thenReturn(new BufferedReader(reader));
PrintWriter writer = mock(PrintWriter.class);
when(resp.getWriter()).thenReturn(writer);