moved all tests into *.test.unit.* packages; next is to pull out integration tests into *.test.integration.* packages
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package org.springframework.cassandra.cql;
|
||||
package org.springframework.cassandra.test.unit.core.cql;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springframework.cassandra.test.unit.core.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.keyspace.TableOperations.alterTable;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cassandra.core.cql.generator.AlterTableCqlGenerator;
|
||||
import org.springframework.cassandra.core.keyspace.AlterTableSpecification;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
public class AlterTableCqlGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void testAlterTableBuilder() throws Exception {
|
||||
String name = "mytable";
|
||||
DataType addedType = DataType.timeuuid();
|
||||
String addedName = "added_column";
|
||||
DataType alteredType = DataType.text();
|
||||
String alteredName = "altered_column";
|
||||
String droppedName = "dropped";
|
||||
|
||||
AlterTableSpecification alter = alterTable().name(name).add(addedName, addedType).alter(alteredName, alteredType)
|
||||
.drop(droppedName);
|
||||
AlterTableCqlGenerator generator = new AlterTableCqlGenerator(alter);
|
||||
System.out.println(generator.toCql());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.springframework.cassandra.test.unit.core.cql.generator;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.springframework.cassandra.core.keyspace.MapBuilder.map;
|
||||
import static org.springframework.cassandra.core.keyspace.TableOperations.createTable;
|
||||
import static org.springframework.cassandra.core.keyspace.TableOption.BLOOM_FILTER_FP_CHANCE;
|
||||
import static org.springframework.cassandra.core.keyspace.TableOption.CACHING;
|
||||
import static org.springframework.cassandra.core.keyspace.TableOption.COMMENT;
|
||||
import static org.springframework.cassandra.core.keyspace.TableOption.COMPACTION;
|
||||
import static org.springframework.cassandra.core.keyspace.TableOption.CompactionOption.TOMBSTONE_THRESHOLD;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cassandra.core.cql.generator.CreateTableCqlGenerator;
|
||||
import org.springframework.cassandra.core.keyspace.CreateTableSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.TableOption.CachingOption;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
public class CreateTableCqlGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void createTableTest() {
|
||||
String name = "my\"\"table";
|
||||
DataType type0 = DataType.text();
|
||||
String partKey0 = "partitionKey0";
|
||||
String partition1 = "partitionKey1";
|
||||
String primary0 = "primary0";
|
||||
DataType type1 = DataType.text();
|
||||
String column1 = "column1";
|
||||
DataType type2 = DataType.bigint();
|
||||
String column2 = "column2";
|
||||
Object comment = "this is a comment";
|
||||
Object bloom = "0.00075";
|
||||
Object caching = CachingOption.KEYS_ONLY;
|
||||
|
||||
CreateTableSpecification create = createTable().ifNotExists().name(name).partitionKeyColumn(partKey0, type0)
|
||||
.partitionKeyColumn(partition1, type0).primaryKeyColumn(primary0, type0).column(column1, type1)
|
||||
.column(column2, type2).with(COMMENT, comment).with(BLOOM_FILTER_FP_CHANCE, bloom)
|
||||
.with(COMPACTION, map().entry(TOMBSTONE_THRESHOLD, "0.15")).with(CACHING, caching);
|
||||
|
||||
CreateTableCqlGenerator generator = new CreateTableCqlGenerator(create);
|
||||
String cql = generator.toCql();
|
||||
assertEquals(
|
||||
"CREATE TABLE IF NOT EXISTS \"my\"\"table\" (partitionKey0 text, partitionKey1 text, primary0 text, column1 text, column2 bigint, PRIMARY KEY ((partitionKey0, partitionKey1), primary0) WITH CLUSTERING ORDER BY (primary0 ASC) AND comment = 'this is a comment' AND bloom_filter_fp_chance = 0.00075 AND compaction = { 'tombstone_threshold' : 0.15 } AND caching = keys_only;",
|
||||
cql);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.springframework.cassandra.test.unit.core.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.keyspace.TableOperations.dropTable;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cassandra.core.cql.generator.DropTableCqlGenerator;
|
||||
import org.springframework.cassandra.core.keyspace.DropTableSpecification;
|
||||
|
||||
public class DropTableCqlGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void testDropTableBuilder() throws Exception {
|
||||
DropTableSpecification drop = dropTable().ifExists().name("mytable");
|
||||
|
||||
DropTableCqlGenerator generator = new DropTableCqlGenerator(drop);
|
||||
System.out.println(generator.toCql());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.cassandra.cql.builder;
|
||||
package org.springframework.cassandra.test.unit.core.keyspace;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.cassandra.cql.builder;
|
||||
package org.springframework.cassandra.test.unit.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.keyspace.TableOperations.alterTable;
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.cassandra.core.keyspace.AlterTableSpecification;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
public class AlterTableBuilderTest {
|
||||
public class AlterTableCqlGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void testAlterTableBuilder() throws Exception {
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.cassandra.cql.builder;
|
||||
package org.springframework.cassandra.test.unit.cql.generator;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.springframework.cassandra.core.keyspace.MapBuilder.map;
|
||||
@@ -16,7 +16,7 @@ import org.springframework.cassandra.core.keyspace.TableOption.CachingOption;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
public class CreateTableBuilderTest {
|
||||
public class CreateTableCqlGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void createTableTest() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.cassandra.cql.builder;
|
||||
package org.springframework.cassandra.test.unit.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.keyspace.TableOperations.dropTable;
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.junit.Test;
|
||||
import org.springframework.cassandra.core.cql.generator.DropTableCqlGenerator;
|
||||
import org.springframework.cassandra.core.keyspace.DropTableSpecification;
|
||||
|
||||
public class DropTableBuilderTest {
|
||||
public class DropTableCqlGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void testDropTableBuilder() throws Exception {
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.data.cassandra.config;
|
||||
package org.springframework.data.cassandra.test.unit.config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.data.cassandra.config;
|
||||
package org.springframework.data.cassandra.test.unit.config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package org.springframework.data.cassandra.config;
|
||||
package org.springframework.data.cassandra.test.unit.config;
|
||||
|
||||
import org.springframework.cassandra.core.CassandraOperations;
|
||||
import org.springframework.cassandra.core.CassandraTemplate;
|
||||
import org.springframework.cassandra.core.SessionFactoryBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.cassandra.config.AbstractCassandraConfiguration;
|
||||
import org.springframework.data.cassandra.core.CassandraDataOperations;
|
||||
import org.springframework.data.cassandra.core.CassandraDataTemplate;
|
||||
import org.springframework.data.cassandra.core.CassandraKeyspaceFactoryBean;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.data.cassandra.core;
|
||||
package org.springframework.data.cassandra.test.unit.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.mapping;
|
||||
package org.springframework.data.cassandra.test.unit.mapping;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -32,6 +32,8 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntity;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.mapping;
|
||||
package org.springframework.data.cassandra.test.unit.mapping;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -31,6 +31,12 @@ import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntity;
|
||||
import org.springframework.data.cassandra.mapping.BasicCassandraPersistentProperty;
|
||||
import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
|
||||
import org.springframework.data.cassandra.mapping.CassandraPersistentProperty;
|
||||
import org.springframework.data.cassandra.mapping.Column;
|
||||
import org.springframework.data.cassandra.mapping.ColumnId;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.table;
|
||||
package org.springframework.data.cassandra.test.unit.table;
|
||||
|
||||
import org.springframework.data.cassandra.mapping.RowId;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.table;
|
||||
package org.springframework.data.cassandra.test.unit.table;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.table;
|
||||
package org.springframework.data.cassandra.test.unit.table;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.table;
|
||||
package org.springframework.data.cassandra.test.unit.table;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.table;
|
||||
package org.springframework.data.cassandra.test.unit.table;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.table;
|
||||
package org.springframework.data.cassandra.test.unit.table;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.table;
|
||||
package org.springframework.data.cassandra.test.unit.table;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.table;
|
||||
package org.springframework.data.cassandra.test.unit.table;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.template;
|
||||
package org.springframework.data.cassandra.test.unit.template;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cassandra.core.CassandraOperations;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.cassandra.config.TestConfig;
|
||||
import org.springframework.data.cassandra.test.unit.config.TestConfig;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.template;
|
||||
package org.springframework.data.cassandra.test.unit.template;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -40,12 +40,12 @@ import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.cassandra.config.TestConfig;
|
||||
import org.springframework.data.cassandra.core.CassandraDataOperations;
|
||||
import org.springframework.data.cassandra.core.ConsistencyLevel;
|
||||
import org.springframework.data.cassandra.core.QueryOptions;
|
||||
import org.springframework.data.cassandra.core.RetryPolicy;
|
||||
import org.springframework.data.cassandra.table.Book;
|
||||
import org.springframework.data.cassandra.test.unit.config.TestConfig;
|
||||
import org.springframework.data.cassandra.test.unit.table.Book;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.template;
|
||||
package org.springframework.data.cassandra.test.unit.template;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cassandra.core.CassandraOperations;
|
||||
import org.springframework.cassandra.core.HostMapper;
|
||||
import org.springframework.cassandra.core.RingMember;
|
||||
import org.springframework.data.cassandra.config.TestConfig;
|
||||
import org.springframework.data.cassandra.test.unit.config.TestConfig;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
@@ -37,12 +37,12 @@
|
||||
<cassandra:keyspace-attributes auto="update"
|
||||
replication-stategy="SimpleStrategy" replication-factor="1"
|
||||
durable-writes="true">
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.Comment" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.unit.table.Comment" />
|
||||
<cassandra:table
|
||||
entity="org.springframework.data.cassandra.table.Notification" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.Post" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.Timeline" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.User" />
|
||||
entity="org.springframework.data.cassandra.test.unit.table.Notification" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.unit.table.Post" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.unit.table.Timeline" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.unit.table.User" />
|
||||
</cassandra:keyspace-attributes>
|
||||
</cassandra:keyspace>
|
||||
|
||||
Reference in New Issue
Block a user