DATACASS-33 - moved test support classes & improved CompoundPrimaryKeyIntegrationTests

This commit is contained in:
Matthew Adams
2014-02-07 10:48:51 -06:00
parent c91611ff31
commit 2502779445
8 changed files with 23 additions and 20 deletions

View File

@@ -4,7 +4,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.cassandra.test.integration.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.Assert;

View File

@@ -28,7 +28,7 @@ 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.cassandra.test.integration.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.util.ClassTypeInformation;
/**

View File

@@ -22,6 +22,7 @@ import java.util.Date;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntity;
import org.springframework.data.cassandra.mapping.BasicCassandraPersistentProperty;
import org.springframework.data.cassandra.mapping.CachingCassandraPersistentProperty;
@@ -32,6 +33,7 @@ import org.springframework.data.cassandra.mapping.Column;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.PrimaryKeyClass;
import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
import org.springframework.data.cassandra.mapping.Table;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.util.ReflectionUtils;
@@ -39,41 +41,44 @@ import org.springframework.util.ReflectionUtils;
* Integration test for {@link BasicCassandraPersistentProperty}.
*
* @author Alex Shvid
* @author Matthew T. Adams
*/
public class CompoundPrimaryKeyIntegrationTests {
@PrimaryKeyClass
static class TimelineKey {
@PrimaryKeyColumn(ordinal = 0)
String id;
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
String string;
@PrimaryKeyColumn(ordinal = 1)
Date dt;
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED)
Date datetime;
}
@Table
static class Timeline {
@PrimaryKey
TimelineKey id;
@Column("message")
String text;
}
CassandraPersistentEntity<TimelineKey> cpk;
CassandraPersistentEntity<Timeline> entity;
@Before
public void setup() {
cpk = new BasicCassandraPersistentEntity<TimelineKey>(ClassTypeInformation.from(TimelineKey.class));
entity = new BasicCassandraPersistentEntity<Timeline>(ClassTypeInformation.from(Timeline.class));
}
@Test
public void checksIdProperty() {
Field field = ReflectionUtils.findField(Timeline.class, "id");
CassandraPersistentProperty property = getPropertyFor(field);
public void checkIdProperty() {
Field id = ReflectionUtils.findField(Timeline.class, "id");
CassandraPersistentProperty property = getPropertyFor(id);
assertTrue(property.isIdProperty());
assertTrue(property.isCompositePrimaryKey());
}
private CassandraPersistentProperty getPropertyFor(Field field) {

View File

@@ -30,8 +30,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.config.SchemaAction;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import org.springframework.data.cassandra.test.integration.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.config.TestConfig;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.support.TestConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -21,7 +21,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.test.integration.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -1,4 +1,4 @@
package org.springframework.data.cassandra.test.integration;
package org.springframework.data.cassandra.test.integration.support;
import static org.springframework.cassandra.core.keyspace.DropTableSpecification.dropTable;
@@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.test.integration.support.SpringDataCassandraBuildProperties;
import org.springframework.data.cassandra.test.integration.template.CassandraDataOperationsTest.Config;
import org.springframework.util.Assert;

View File

@@ -1,9 +1,8 @@
package org.springframework.data.cassandra.test.integration.config;
package org.springframework.data.cassandra.test.integration.support;
import org.springframework.cassandra.test.unit.support.Utils;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.config.java.AbstractSpringDataCassandraConfiguration;
import org.springframework.data.cassandra.test.integration.support.SpringDataCassandraBuildProperties;
/**
* Setup any spring configuration for unit tests

View File

@@ -41,9 +41,9 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.data.cassandra.config.SchemaAction;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.test.integration.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.config.TestConfig;
import org.springframework.data.cassandra.test.integration.simpletons.Book;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.support.TestConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;