@Test
public void testDoAuthentication() {

	
	/**
	 * 测试异常输入情况。
	 */
	Assert.assertFalse(handler.authenticate(null));
	Credential credential = Mockito.mock(Credential.class);
	Assert.assertFalse(handler.authenticate(credential));
	
	/**
	 * 测试解密失败抛出异常的情况。
	 */
	EncryCredential encryCredential = new EncryCredential("sssddaf");
	EncryCredentialManager encryCredentialManager = Mockito.mock(EncryCredentialManager.class);
	this.handler.setEncryCredentialManager(encryCredentialManager);
	Mockito.when(encryCredentialManager.decrypt(encryCredential)).thenThrow(InvalidEncryCredentialException.INSTANCE);
	Assert.assertFalse(handler.authenticate(encryCredential));
	
	/**
	 * 测试解密返回null的情况。
	 */
	Mockito.reset(encryCredentialManager);
	Mockito.when(encryCredentialManager.decrypt(encryCredential)).thenReturn(null);
	Assert.assertFalse(handler.authenticate(encryCredential));
	
	/**
	 * 测试解密成功，但是凭据不合法的情况。
	 */
	Mockito.reset(encryCredentialManager);
	EncryCredentialInfo encryCredentialInfo = new EncryCredentialInfo();
	Mockito.when(encryCredentialManager.decrypt(encryCredential)).thenReturn(encryCredentialInfo);
	Assert.assertFalse(handler.authenticate(encryCredential));
	
	
	/**
	 * 测试解密成功，但是凭据合法的情况。
	 */
	Mockito.reset(encryCredentialManager);
	encryCredentialInfo = new EncryCredentialInfo();
	Mockito.when(encryCredentialManager.decrypt(encryCredential)).thenReturn(encryCredentialInfo);
	Mockito.when(encryCredentialManager.checkEncryCredentialInfo(encryCredentialInfo)).thenReturn(true);
	Assert.assertTrue(handler.authenticate(encryCredential));
}