@Test
public void testGetUser()
throws Exception
{
LdapManager ldapManager = this.lookup(LdapManager.class);
LdapServer ldapServer = this.getLdapServer("default");
LdapUser brianf = ldapManager.getUser("brianf");
Assert.assertNotNull(brianf);
Assert.assertEquals("brianf", brianf.getUsername());
Assert.assertEquals(brianf.getUsername() + "123", brianf.getPassword());
Assert.assertEquals("Brian Fox", brianf.getRealName());
Assert.assertEquals(2, brianf.getMembership().size());
ldapServer.stop();
try {
ldapManager.getUser("brianf");
Assert.fail("Expected NoSuchLdapUserException");
}
catch (NoSuchLdapUserException e) {
// expected
}
ldapServer.start();
try {
ldapManager.getUser("brianf");
Assert.fail("Expected NoSuchLdapUserException");
}
catch (NoSuchLdapUserException e) {
// expected
}
// wait 3 more sec, then we should be good
Thread.sleep(7 * 1000);
Assert.assertNotNull(ldapManager.getUser("brianf"));
}