@SuppressWarnings("unchecked")
@Test(expected=InternalServerErrorException.class)
public void testPasswordDatabaseException() throws Exception {

    AdminUserResource resource = new AdminUserResource();
    // Inject OSGi services into the resource
    UserManagementServiceProvider useradmin = new UserManagementServiceProvider();
    resource.useradmin = useradmin;
    UkelonnServiceProvider ukelonn = new UkelonnServiceProvider();
    resource.ukelonn = ukelonn;
    MockLogService logservice = new MockLogService();
    resource.logservice = logservice;
    ukelonn.setLogservice(logservice);
    useradmin.setLogservice(logservice);
    // Create a mock database that throws exceptions and inject it
    DataSource datasource = mock(DataSource.class);
    Connection connection = mock(Connection.class);
    when(datasource.getConnection()).thenReturn(connection);
    PreparedStatement statement = mock(PreparedStatement.class);
    when(connection.prepareStatement(anyString())).thenReturn(statement);
    when(statement.executeUpdate()).thenThrow(SQLException.class);
    useradmin.setDataSource(datasource);
    // Create a user object with a valid username
    User user = new User(0, "validusername", null, null, null);
    // Create a passwords object containing the user and with
    // valid and identical passwords
    UserAndPasswords passwords = new UserAndPasswords(user, "zecret", "zecret", false);
    // Changing the password should fail
    resource.password(passwords);
    fail("Should never get here");
}