From 908883db12e70b77bf9c93d516fcfdb63826377e Mon Sep 17 00:00:00 2001 From: sameira Date: Wed, 9 Dec 2015 16:20:30 +0530 Subject: [PATCH] Adding test cases for Cassandra Templates and CQL Queries --- .../repository/CQLQueriesIntegrationTest.java | 4 +- .../CassandraTemplateIntegrationTest.java | 37 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java index 1835df31f9..fd60b9a7f9 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CQLQueriesIntegrationTest.java @@ -57,7 +57,7 @@ public class CQLQueriesIntegrationTest { Session session = cluster.connect(); session.execute(KEYSPACE_CREATION_QUERY); session.execute(KEYSPACE_ACTIVATE_QUERY); - Thread.sleep(1000); + Thread.sleep(2000); LOGGER.info("KeySpace created and activated."); } @@ -96,7 +96,7 @@ public class CQLQueriesIntegrationTest { bookList.add("Head First Java"); bookList.add("OReilly Media"); bookList.add(ImmutableSet.of("Software")); - bookList.add(bookList); + bookListOfList.add(bookList); cassandraTemplate.ingest(insertPreparedCql, bookListOfList); Select select = QueryBuilder.select().from("book").limit(10); Book retrievedBook = cassandraTemplate.selectOne(select, Book.class); diff --git a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java index 69b965f8c5..fae24e8f21 100644 --- a/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/baeldung/spring/data/cassandra/repository/CassandraTemplateIntegrationTest.java @@ -1,14 +1,11 @@ package org.baeldung.spring.data.cassandra.repository; -import static junit.framework.TestCase.assertNull; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; - +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.querybuilder.QueryBuilder; +import com.datastax.driver.core.querybuilder.Select; +import com.datastax.driver.core.utils.UUIDs; +import com.google.common.collect.ImmutableSet; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -16,11 +13,7 @@ import org.apache.thrift.transport.TTransportException; import org.baeldung.spring.data.cassandra.config.CassandraConfig; import org.baeldung.spring.data.cassandra.model.Book; import org.cassandraunit.utils.EmbeddedCassandraServerHelper; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.*; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cassandra.core.cql.CqlIdentifier; @@ -29,12 +22,14 @@ import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.querybuilder.QueryBuilder; -import com.datastax.driver.core.querybuilder.Select; -import com.datastax.driver.core.utils.UUIDs; -import com.google.common.collect.ImmutableSet; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; + +import static junit.framework.TestCase.assertNull; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = CassandraConfig.class) @@ -62,7 +57,7 @@ public class CassandraTemplateIntegrationTest { Session session = cluster.connect(); session.execute(KEYSPACE_CREATION_QUERY); session.execute(KEYSPACE_ACTIVATE_QUERY); - Thread.sleep(5000); + Thread.sleep(2000); LOGGER.info("KeySpace created and activated."); }