code:     public void setUp() throws Exception
      {
          super.setUp();
          _successfulResult = mock(AuthenticationResult.class);
          _errorResult = mock(AuthenticationResult.class);
          _authenticationProvider = mock(UsernamePasswordAuthenticationProvider.class);
          when(_authenticationProvider.authenticate(eq(VALID_USERNAME), eq(VALID_PASSWORD))).thenReturn(_successfulResult);
          when(_authenticationProvider.authenticate(eq(VALID_USERNAME), not(eq(VALID_PASSWORD)))).thenReturn(_errorResult);
          when(_authenticationProvider.authenticate(not(eq(VALID_USERNAME)), anyString())).thenReturn(_errorResult);
          _negotiator = new PlainNegotiator(_authenticationProvider);
      }
  
      @Override
  