### Question:
ArchivaServletAuthenticator implements ServletAuthenticator { @Override public boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result ) throws AuthenticationException, AccountLockedException, MustChangePasswordException { if ( result != null && !result.isAuthenticated() ) { throw new AuthenticationException( "User Credentials Invalid" ); } return true; }  @Override boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result ); @Override boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId,
                                 String permission ); @Override boolean isAuthorized( String principal, String repoId, String permission ); SecuritySystem getSecuritySystem(); void setSecuritySystem( SecuritySystem securitySystem );  }### Answer:
@Test public void testIsAuthenticatedUserExists() throws Exception { AuthenticationResult result = new AuthenticationResult( true, "user", null ); boolean isAuthenticated = servletAuth.isAuthenticated( request, result ); assertTrue( isAuthenticated ); }
@Test public void testIsAuthenticatedUserDoesNotExist() throws Exception { AuthenticationResult result = new AuthenticationResult( false, "non-existing-user", null ); try { servletAuth.isAuthenticated( request, result ); fail( "Authentication exception should have been thrown." ); } catch ( AuthenticationException e ) { assertEquals( "User Credentials Invalid", e.getMessage() ); } }