src/test/java/codeu/controller/RegisterServletTest.java
/**
   * Prints a test message whenever the username that is being entered into the registration
   * page contains invalid characters.
   */
Prints a test message whenever the username that is being entered into the registration
page contains invalid characters.
Prints a test message whenever the username that is being entered into the registration page contains invalid characters .
@Test
  public void testDoPost_BadUsername() throws IOException, ServletException {
    Mockito.when(mockRequest.getParameter("username")).thenReturn("bad !@#$% username");
    registerServlet.doPost(mockRequest, mockResponse);
    Mockito.verify(mockRequest)
        .setAttribute("error", "Please enter only letters, numbers, and spaces.");
    Mockito.verify(mockRequestDispatcher).forward(mockRequest, mockResponse);
  }
@ Test public void testDoPost_BadUsername ( ) throws IOException , ServletException { Mockito . when ( mockRequest . getParameter ( "username" ) ) . thenReturn ( "bad !@#$% username" ) ; registerServlet . doPost ( mockRequest , mockResponse ) ; Mockito . verify ( mockRequest ) . setAttribute ( "error" , "Please enter only letters, numbers, and spaces." ) ; Mockito . verify ( mockRequestDispatcher ) . forward ( mockRequest , mockResponse ) ; }
Prints a test message whenever the username that is being entered into the registration
 page contains invalid characters.
Prints a test message whenever the username that is being entered into the registration page contains invalid characters .