Skip to content

Commit a04fadf

Browse files
Bouncheckavelanarius
authored andcommitted
Add test method for empty pages
Adds a test method to SimpleStatementCcmIT that checks if SimpleStatement with page size 1 correctly fetches all rows. Covers issue #254.
1 parent b97a4de commit a04fadf

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/SimpleStatementCcmIT.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,31 @@ public void should_use_page_size() {
367367
// Should have only fetched 10 (page size) rows.
368368
assertThat(result.remaining()).isEqualTo(10);
369369
}
370+
371+
@Test
372+
public void should_not_fail_on_empty_pages() {
373+
SESSION_RULE
374+
.session()
375+
.execute(
376+
"CREATE KEYSPACE IF NOT EXISTS ks WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}");
377+
378+
SESSION_RULE
379+
.session()
380+
.execute("CREATE TABLE IF NOT EXISTS ks.t (pk int, ck int, v int, PRIMARY KEY(pk, ck))");
381+
382+
for (int i = 0; i < 50; i++) {
383+
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 15);
384+
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 32);
385+
}
386+
387+
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 8, 8, 14);
388+
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 11, 11, 14);
389+
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 14, 14, 14);
390+
391+
SimpleStatement st =
392+
SimpleStatement.newInstance("SELECT * FROM ks.t WHERE v = 14 ALLOW FILTERING");
393+
st = st.setPageSize(1);
394+
List<Row> allRows = SESSION_RULE.session().execute(st).all();
395+
assertThat(allRows.size()).isEqualTo(3);
396+
}
370397
}

0 commit comments

Comments
 (0)