summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorIlya Ermakov <ilya403403@gmail.com>2014-12-03 13:43:15 +0300
committerVaadin Code Review <review@vaadin.com>2014-12-12 06:31:02 +0000
commit3bc4ff53736ed2a0c3e9e362be3e7de481d1d00f (patch)
tree28eb03f89768f73dd5bfd625a2a7ea10a0cc5ea2 /server/tests
parentdd879668f5f74dfea8a804f3ff3c1e7c2f89a5a3 (diff)
downloadvaadin-framework-3bc4ff53736ed2a0c3e9e362be3e7de481d1d00f.tar.gz
vaadin-framework-3bc4ff53736ed2a0c3e9e362be3e7de481d1d00f.zip
Make SQLContainer.removeAllItems() work properly with paging (#12882)
With this patch removeAllItems() works properly when items need to be fetched from database. Change-Id: Ic008ae7c67610cbdde7d71fa071494508678ac8f
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
index 93a27352a5..fbae0ee159 100644
--- a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
+++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
@@ -1071,6 +1071,26 @@ public class SQLContainerTableQueryTest {
Assert.assertEquals(0, container.size());
}
+ // Set timeout to ensure there is no infinite looping (#12882)
+ @Test(timeout = 1000)
+ public void removeAllItems_manyItems_commit_shouldSucceed()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, SQLTestsConstants.sqlGen));
+ final int itemNumber = (SQLContainer.CACHE_RATIO + 1)
+ * SQLContainer.DEFAULT_PAGE_LENGTH + 1;
+ container.removeAllItems();
+ Assert.assertEquals(container.size(), 0);
+ for (int i = 0; i < itemNumber; ++i) {
+ container.addItem();
+ }
+ container.commit();
+ Assert.assertEquals(container.size(), itemNumber);
+ Assert.assertTrue(container.removeAllItems());
+ container.commit();
+ Assert.assertEquals(container.size(), 0);
+ }
+
@Test
public void commit_tableAddedItem_shouldBeWrittenToDB() throws SQLException {
TableQuery query = new TableQuery("people", connectionPool,