### Question:
ODLJndiLdapRealm extends DefaultLdapRealm { public static String getUsername(AuthenticationToken token) throws ClassCastException { if (null == token) { return null; } return (String) token.getPrincipal(); } ODLJndiLdapRealm(); static String getUsername(AuthenticationToken token); static AuthorizationInfo buildAuthorizationInfo(final Set<String> roleNames); @Override String getUserDnSuffix(); void setSearchBase(final String searchBase); void setLdapAttributeForComparison(final String ldapAttributeForComparison); void setGroupRolesMap(final Map<String, String> groupRolesMap);  }### Answer:
@Test public void testGetUsernameAuthenticationToken() { AuthenticationToken authenticationToken = null; assertNull(ODLJndiLdapRealm.getUsername(authenticationToken)); AuthenticationToken validAuthenticationToken = new UsernamePasswordToken("test", "testpassword"); assertEquals("test", ODLJndiLdapRealm.getUsername(validAuthenticationToken)); }
@Test public void testGetUsernamePrincipalCollection() { PrincipalCollection pc = null; assertNull(new ODLJndiLdapRealm().getUsername(pc)); TestPrincipalCollection tpc = new TestPrincipalCollection("testuser"); String username = new ODLJndiLdapRealm().getUsername(tpc); assertEquals("testuser", username); }