Skip to content

Commit 143ae5f

Browse files
Bouncheckavelanarius
authored andcommitted
Add StatementPagesTest
Adds a simple test that checks if empty pages are correctly skipped through and all rows are being returned. Covers #254.
1 parent 7caca1e commit 143ae5f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.datastax.driver.core;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.testng.annotations.Test;
6+
7+
public class StatementPagesTest extends CCMTestsSupport {
8+
@Override
9+
public void onTestContextInitialized() {
10+
execute(
11+
"CREATE KEYSPACE IF NOT EXISTS ks WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}");
12+
execute("CREATE TABLE IF NOT EXISTS ks.t (pk int, ck int, v int, PRIMARY KEY(pk, ck))");
13+
14+
for (int i = 0; i < 50; i++) {
15+
// System.out.println("Insert " + i);
16+
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 15);
17+
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 32);
18+
}
19+
20+
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 8, 8, 14);
21+
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 11, 11, 14);
22+
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 14, 14, 14);
23+
}
24+
25+
@Test(groups = "short")
26+
public void should_not_get_stuck_on_empty_pages() {
27+
SimpleStatement st = new SimpleStatement("SELECT * FROM ks.t WHERE v = 14 ALLOW FILTERING");
28+
st.setFetchSize(1);
29+
ResultSet rs = session().execute(st);
30+
assertThat(rs.all().size()).isEqualTo(3);
31+
}
32+
}

0 commit comments

Comments
 (0)