@Test
  public void defaults() throws Exception {
    MockHttpServletRequest request = formLogin().buildRequest(this.servletContext);
    CsrfToken token =
        (CsrfToken)
            request.getAttribute(CsrfRequestPostProcessor.TestCsrfTokenRepository.ATTR_NAME);

    assertThat(request.getParameter("username")).isEqualTo("user");
    assertThat(request.getParameter("password")).isEqualTo("password");
    assertThat(request.getMethod()).isEqualTo("POST");
    assertThat(request.getParameter(token.getParameterName())).isEqualTo(token.getToken());
    assertThat(request.getRequestURI()).isEqualTo("/login");
    assertThat(request.getParameter("_csrf")).isNotNull();
  }
 @Test
 public void setMultipleParameters() {
   request.setParameter("key1", "value1");
   request.setParameter("key2", "value2");
   Map<String, Object> params = new HashMap<String, Object>(2);
   params.put("key1", "newValue1");
   params.put("key3", new String[] {"value3A", "value3B"});
   request.setParameters(params);
   String[] values1 = request.getParameterValues("key1");
   assertEquals(1, values1.length);
   assertEquals("newValue1", request.getParameter("key1"));
   assertEquals("value2", request.getParameter("key2"));
   String[] values3 = request.getParameterValues("key3");
   assertEquals(2, values3.length);
   assertEquals("value3A", values3[0]);
   assertEquals("value3B", values3[1]);
 }
  @Test
  public void requestParameterFromQueryWithEncoding() throws Exception {
    this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/?foo={value}", "bar=baz");

    MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);

    assertEquals("foo=bar=baz", request.getQueryString());
    assertEquals("bar=baz", request.getParameter("foo"));
  }
  @Test
  public void requestParameterFromQueryList() throws Exception {
    this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/?foo[0]=bar&foo[1]=baz");

    MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);

    assertEquals("foo[0]=bar&foo[1]=baz", request.getQueryString());
    assertEquals("bar", request.getParameter("foo[0]"));
    assertEquals("baz", request.getParameter("foo[1]"));
  }
 @Test
 public void nullParameterName() {
   assertNull(request.getParameter(null));
   assertNull(request.getParameterValues(null));
 }