    public void testCreateAndUpdateUser()
            throws Exception
    {
        User user = new User();
        user.setUsername(USERNAME);
        user.setPassword(PASSWORD);
        final long countOld = usersDao.count();
        usersDao.createUser(user);
        final long countNew = usersDao.count();
        assertTrue("Failed to create user '" + USERNAME + "'!", countOld < countNew);
        final String changedPassword = EncryptionUtils.encryptWithMD5("newpassword");
        user.setPassword(changedPassword);
        usersDao.updateUser(user);
        User updatedUser = usersDao.findUser(USERNAME, changedPassword);
        assertEquals("Failed to update the user!", changedPassword, updatedUser.getPassword());
        user = updatedUser;
        String roleName = "ADMINISTRATOR";
        assertFalse("This user is already an administrator!", user.hasRole(roleName));
        usersDao.assignRole(user, roleName);
        updatedUser = usersDao.findUser(USERNAME);
        assertTrue("Failed to assign role 'ADMINISTRATOR' to user '" + USERNAME + "'",
                   updatedUser.hasRole(roleName));
        usersDao.removeUser(user.getUsername());
    }

    public void testCreateAndUpdateUser()
            throws Exception
    {
        User user = new User();
        user.setUsername(USERNAME);
        user.setPassword(PASSWORD);
        final long countOld = usersDao.count();
        usersDao.createUser(user);
        final long countNew = usersDao.count();
        assertTrue("Failed to create user '" + USERNAME + "'!", countOld < countNew);
        final String changedPassword = EncryptionUtils.encryptWithMD5("newpassword");
        user.setPassword(changedPassword);
        usersDao.updateUser(user);
        User updatedUser = usersDao.findUser(USERNAME, changedPassword);
        assertEquals("Failed to update the user!", changedPassword, updatedUser.getPassword());
        user = updatedUser;
        String roleName = "ADMINISTRATOR";
        assertFalse("This user is already an administrator!", user.hasRole(roleName));
        usersDao.assignRole(user, roleName);
        updatedUser = usersDao.findUser(USERNAME);
        assertTrue("Failed to assign role 'ADMINISTRATOR' to user '" + USERNAME + "'",
                   updatedUser.hasRole(roleName));
    }
