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

    AdminUserResource resource = new AdminUserResource();
    UkelonnServiceProvider ukelonn = new UkelonnServiceProvider();
    UserManagementServiceProvider useradmin = new UserManagementServiceProvider();
    // 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 logservice and inject it
    MockLogService logservice = new MockLogService();
    useradmin.setLogservice(logservice);
    // Inject OSGi services into the resource
    resource.ukelonn = ukelonn;
    resource.useradmin = useradmin;
    resource.logservice = logservice;
    // Create a user object
    String newUsername = "aragorn";
    String newEmailaddress = "strider@hotmail.com";
    String newFirstname = "Aragorn";
    String newLastname = "McArathorn";
    User user = new User(0, newUsername, newEmailaddress, newFirstname, newLastname);
    // Create a passwords object containing the user
    UserAndPasswords passwords = new UserAndPasswords(user, "zecret", "zecret", false);
    // Creating user should fail
    resource.create(passwords);
    fail("Should never get here");
}