diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/template/CassandraOperationsTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/template/CassandraOperationsTest.java index 1b3fa1c71..f4a363d88 100644 --- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/template/CassandraOperationsTest.java +++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/template/CassandraOperationsTest.java @@ -39,6 +39,7 @@ import org.springframework.cassandra.core.PreparedStatementBinder; import org.springframework.cassandra.core.ResultSetExtractor; import org.springframework.cassandra.core.ResultSetFutureExtractor; import org.springframework.cassandra.core.RingMember; +import org.springframework.cassandra.core.RowCallbackHandler; import org.springframework.cassandra.core.RowIterator; import org.springframework.cassandra.core.SessionCallback; import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; @@ -375,6 +376,73 @@ public class CassandraOperationsTest extends AbstractEmbeddedCassandraIntegratio } + @Test + public void queryTestCqlStringRowCallbackHandler() { + + final String isbn = "999999999"; + + final Book b1 = getBook(isbn); + + cassandraTemplate.query("select * from book where isbn='" + isbn + "'", new RowCallbackHandler() { + + @Override + public void processRow(Row row) throws DriverException { + + assertNotNull(row); + + Book b = new Book(); + b.setIsbn(row.getString("isbn")); + b.setTitle(row.getString("title")); + b.setAuthor(row.getString("author")); + b.setPages(row.getInt("pages")); + + assertBook(b1, b); + + } + }); + + } + + @Test + public void processTestResultSetRowCallbackHandler() { + + final String isbn = "999999999"; + + final Book b1 = getBook(isbn); + + ResultSet rs = cassandraTemplate.queryAsynchronously("select * from book where isbn='" + isbn + "'", + new ResultSetFutureExtractor() { + + @Override + public ResultSet extractData(ResultSetFuture rs) throws DriverException, DataAccessException { + + ResultSet frs = rs.getUninterruptibly(); + return frs; + } + }); + + assertNotNull(rs); + + cassandraTemplate.process(rs, new RowCallbackHandler() { + + @Override + public void processRow(Row row) throws DriverException { + + assertNotNull(row); + + Book b = new Book(); + b.setIsbn(row.getString("isbn")); + b.setTitle(row.getString("title")); + b.setAuthor(row.getString("author")); + b.setPages(row.getInt("pages")); + + assertBook(b1, b); + + } + }); + + } + /** * Assert that a Book matches the arguments expected *