public void testUniqueAttribute() throws Exception
{
if (userHandler_ instanceof UserDAOImpl)
{
UserDAOImpl ud = (UserDAOImpl)userHandler_;
User user = userHandler_.createUserInstance("toto");
user.setEmail("toto@gatein.org");
userHandler_.createUser(user, true);
user = userHandler_.createUserInstance("lolo");
user.setEmail("lolo@gatein.org");
userHandler_.createUser(user, true);
// Find by unique attribute
assertNull(ud.findUserByEmail("foobar"));
user = ud.findUserByEmail("toto@gatein.org");
assertNotNull(user);
assertEquals("toto", user.getUserName());
user = ud.findUserByEmail("lolo@gatein.org");
assertNotNull(user);
assertEquals("lolo", user.getUserName());
ud.removeUser("toto", false);
ud.removeUser("lolo", false);
}
}