@Test
public void testResolvePrincipal() {

    //测试null情况。
    assertNull(this.resolver.resolvePrincipal(null));
    //测试不只是的用户凭据对象。
    Credential credential = Mockito.mock(Credential.class);
    assertNull(this.resolver.resolvePrincipal(credential));
    //测试正常情况。
    String userId = "test";
    EncryCredential encryCredential = new EncryCredential("ddd");
    Map<String, Object> param = new HashMap<String, Object>();
    encryCredential.setParameters(param);
    EncryCredentialInfo encryCredentialInfo = new EncryCredentialInfo();
    encryCredentialInfo.setUserId(userId);
    encryCredential.setEncryCredentialInfo(encryCredentialInfo);
    Principal principal = this.resolver.resolvePrincipal(encryCredential);
    assertNotNull(principal);
    assertEquals(userId, principal.getId());
    assertEquals(param, principal.getAttributes());
}