// Set timeout to ensure there is no infinite looping (#12882)
  @Test(timeout = 1000)
  public void removeAllItems_manyItems_commit_shouldSucceed() throws SQLException {
    final int itemNumber = (SQLContainer.CACHE_RATIO + 1) * SQLContainer.DEFAULT_PAGE_LENGTH + 1;

    container.removeAllItems();

    assertEquals(container.size(), 0);
    for (int i = 0; i < itemNumber; ++i) {
      container.addItem();
    }
    container.commit();
    assertEquals(container.size(), itemNumber);
    assertTrue(container.removeAllItems());
    container.commit();
    assertEquals(container.size(), 0);
  }
  @Test
  public void commit_tableLastItemUpdated_shouldUpdateRowInDB() throws SQLException {
    Object last = container.lastItemId();
    container.getContainerProperty(last, NAME).setValue("Donald");
    container.commit();

    assertEquals("Donald", container.getContainerProperty(container.lastItemId(), NAME).getValue());
  }
  @Test
  public void commit_tableRemovedItem_shouldBeRemovedFromDB() throws SQLException {
    Object last = container.lastItemId();
    container.removeItem(last);
    container.commit();

    Assert.assertFalse(last.equals(container.lastItemId()));
  }
  @Test(expected = SQLException.class)
  public void itemWithNonExistingVersionColumnCannotBeRemoved() throws SQLException {
    query.setVersionColumn("version");

    container.removeItem(container.lastItemId());

    container.commit();
  }
  @Test
  public void newItemIsAdded() throws SQLException {
    Object id = container.addItem();
    getItem(id).getItemProperty(NAME).setValue("foo");

    container.commit();

    Item item = getItem(container.lastItemId());
    assertThat(item.getItemProperty(NAME).getValue().toString(), is("foo"));
  }
  @Test
  public void commit_removeModifiedItem_shouldSucceed() throws SQLException {
    int size = container.size();
    Object key = container.firstItemId();
    Item row = container.getItem(key);
    row.getItemProperty(NAME).setValue("Pekka");

    assertTrue(container.removeItem(key));
    container.commit();
    assertEquals(size - 1, container.size());
  }
  @Test
  public void commit_tableAddedItem_shouldBeWrittenToDB() throws SQLException {
    Object id = container.addItem();
    container.getContainerProperty(id, NAME).setValue("New Name");

    assertTrue(id instanceof TemporaryRowId);
    Assert.assertSame(id, container.lastItemId());
    container.commit();
    Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
    assertEquals(
        "New Name", container.getContainerProperty(container.lastItemId(), NAME).getValue());
  }
  @Test
  public void commit_tableTwoAddedItems_shouldBeWrittenToDB() throws SQLException {
    Object id = container.addItem();
    Object id2 = container.addItem();
    container.getContainerProperty(id, NAME).setValue("Herbert");
    container.getContainerProperty(id2, NAME).setValue("Larry");
    assertTrue(id2 instanceof TemporaryRowId);
    Assert.assertSame(id2, container.lastItemId());
    container.commit();
    Object nextToLast = container.getIdByIndex(container.size() - 2);

    Assert.assertFalse(nextToLast instanceof TemporaryRowId);
    assertEquals("Herbert", container.getContainerProperty(nextToLast, NAME).getValue());
    Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
    assertEquals("Larry", container.getContainerProperty(container.lastItemId(), NAME).getValue());
  }