@Test
public void testSetCurrentUser() throws SQLException, AuthorizeException
{

    new NonStrictExpectations(authorizeService.getClass())
    {{
        // Allow Admin permissions - needed to create a new EPerson
            authorizeService.isAdmin((Context) any); result = true;
    }};
    
    EPerson oldUser = context.getCurrentUser();
    
    // Create a dummy EPerson to set as current user
    EPerson newUser = ePersonService.create(context);
    newUser.setFirstName(context, "Jane");
    newUser.setLastName(context, "Doe");
    newUser.setEmail("jane@email.com");
    newUser.setCanLogIn(true);
    newUser.setLanguage(context, I18nUtil.getDefaultLocale().getLanguage());
    
    context.setCurrentUser(newUser);
    
    assertThat("testSetCurrentUser 0", context.getCurrentUser(), notNullValue());
    assertThat("testSetCurrentUser 1", context.getCurrentUser(), equalTo(newUser));
    
    // Restore the previous current user
    context.setCurrentUser(oldUser);
}