Source:
public void testGetUserPropertyValues_Caching() throws UserStoreException, NamingException, IOException, MalformedObjectNameException, InstanceNotFoundException { ReadOnlyLDAPUserStoreManager readOnlyLDAPUserStoreManager1 = getReadOnlyLDAPUserStoreManager(); ReadWriteLDAPUserStoreManager readWriteLDAPUserStoreManager1 = getReadWriteDAPUserStoreManager(); Map<String, String> claims = new HashMap<String, String>(); claims.put(SNAME_CLAIM, USER_UPDATED_LAST_NAME); claims.put(U_NAME_CLAIM, USER_NAME_1); if (!readWriteLDAPUserStoreManager1.isExistingUser(USER_NAME_1)) { readWriteLDAPUserStoreManager1.doAddUser(USER_NAME_1, "test1", new String[0], claims, "defult"); } boolean isAuthenticated = false; try { rename(USER_NAME_1, USER_NAME_2); } catch (Exception e) { e.printStackTrace(); } isAuthenticated = readOnlyLDAPUserStoreManager1.doAuthenticate(USER_UPDATED_LAST_NAME, "test1"); Assert.assertTrue(isAuthenticated); Map<String, String> userProps = readOnlyLDAPUserStoreManager1 .getUserPropertyValues(USER_NAME_1, new String[] { CN_ATTR }, "default"); Assert.assertNotNull(userProps); rename(USER_NAME_2, USER_NAME_1); try { readOnlyLDAPUserStoreManager1.getUserClaimValue(USER_UPDATED_LAST_NAME, SNAME_CLAIM, "default"); Assert.fail("The user search should fail, due to cache holding previous DN for the user"); } catch (UserStoreException expectedException) { } clearCache(readOnlyLDAPUserStoreManager1); String lastName = readOnlyLDAPUserStoreManager1.getUserClaimValue(USER_UPDATED_LAST_NAME, SNAME_CLAIM, "default"); Assert.assertNotNull(lastName); }

Target:
public void testGetUserPropertyValues_Caching() throws UserStoreException, NamingException, IOException, MalformedObjectNameException, InstanceNotFoundException { ReadOnlyLDAPUserStoreManager readOnlyLDAPUserStoreManager1 = getReadOnlyLDAPUserStoreManager(); ReadWriteLDAPUserStoreManager readWriteLDAPUserStoreManager1 = getReadWriteDAPUserStoreManager(); Map<String, String> claims = new HashMap<String, String>(); claims.put(SNAME_CLAIM, USER_UPDATED_LAST_NAME); claims.put(U_NAME_CLAIM, USER_NAME_1); startTenantFlow(TEST_TENANT_1, TEST_TENANT_DOMAIN_1); if (!readWriteLDAPUserStoreManager1.isExistingUser(USER_NAME_1)) { readWriteLDAPUserStoreManager1.doAddUser(USER_NAME_1, "test1", new String[0], claims, "defult"); } boolean isAuthenticated = false; try { rename(USER_NAME_1, USER_NAME_2); } catch (Exception e) { log.error("Error in renaming LDAP user " + USER_NAME_1, e); } isAuthenticated = readOnlyLDAPUserStoreManager1.doAuthenticate(USER_UPDATED_LAST_NAME, "test1"); Assert.assertTrue(isAuthenticated); Map<String, String> userProps = readOnlyLDAPUserStoreManager1 .getUserPropertyValues(USER_NAME_1, new String[] { CN_ATTR }, "default"); Assert.assertNotNull(userProps); rename(USER_NAME_2, USER_NAME_1); try { readOnlyLDAPUserStoreManager1.getUserClaimValue(USER_UPDATED_LAST_NAME, SNAME_CLAIM, "default"); Assert.fail("The user search should fail, due to cache holding previous DN for the user, " + "and a UserStoreException should have been thrown."); } catch (UserStoreException expectedException) { } clearCache(readOnlyLDAPUserStoreManager1); String lastName = readOnlyLDAPUserStoreManager1 .getUserClaimValue(USER_UPDATED_LAST_NAME, SNAME_CLAIM, "default"); Assert.assertNotNull(lastName); PrivilegedCarbonContext.endTenantFlow(); }