Adding test cases for Cassandra Templates and CQL Queries

This commit is contained in:
sameira 2015-12-09 16:20:30 +05:30 committed by David Morley
parent b45706cc60
commit 908883db12
2 changed files with 18 additions and 23 deletions

View File

@ -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);

View File

@ -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.");
}