diff --git a/pom.xml b/pom.xml
index 3125c1474..772d19143 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,9 +32,15 @@
2.1.9.21.02.16
- 0.3.12.1.112.1.7.1
+
+ embedded
+ localhost
+ 19042
+ 19160
+ 17000
+ 17001
@@ -99,12 +105,6 @@
-
- com.github.jbellis
- jamm
- ${jamm.version}
- test
-
@@ -144,27 +144,6 @@
test
-
- org.cassandraunit
- cassandra-unit-spring
- ${cassandra-unit.version}
-
-
- cassandra-all
- org.apache.cassandra
-
-
- com.datastax.cassandra
- cassandra-driver-core
-
-
- slf4j-log4j12
- org.slf4j
-
-
- test
-
-
javax.elel-api
@@ -192,14 +171,6 @@
3.1test
-
-
- org.hectorclient
- hector-core
- 1.1-4
- test
-
-
@@ -222,14 +193,6 @@
com.datastax.cassandracassandra-driver-dse
-
- com.github.jbellis
- jamm
-
-
- org.cassandraunit
- cassandra-unit-spring
-
@@ -247,28 +210,6 @@
-
- org.codehaus.mojo
- build-helper-maven-plugin
- 1.8
-
-
- reserve-network-port
-
- reserve-network-port
-
- process-resources
-
-
- build.cassandra.native_transport_port
- build.cassandra.rpc_port
- build.cassandra.storage_port
- build.cassandra.ssl_storage_port
-
-
-
-
- org.apache.maven.pluginsmaven-dependency-plugin
@@ -282,9 +223,11 @@
false**/test/unit/**/*.java
+ **/*UnitTests.java**/test/integration/**/*.java
+ **/**IntegrationTests.java**/test/performance/**/*.java
@@ -298,14 +241,16 @@
${failsafe.version}1
- -Xms1g -Xmx1g -Xss256k -javaagent:${com.github.jbellis:jamm:jar}
+ -Xms1g -Xmx1g -Xss256ktruefalse**/test/integration/**/*.java
+ **/*IntegrationTests.java**/test/unit/**/*.java
+ **/*UnitTests.java**/test/performance/**/*.java
@@ -356,6 +301,57 @@
+
+
+ embedded-cassandra
+
+ true
+
+
+
+ embedded
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.8
+
+
+ reserve-network-port
+
+ reserve-network-port
+
+ generate-test-resources
+
+
+ build.cassandra.native_transport_port
+ build.cassandra.rpc_port
+ build.cassandra.storage_port
+ build.cassandra.ssl_storage_port
+
+
+
+
+
+
+
+
+
+ external-cassandra
+
+
+ external
+ 9042
+ 9160
+ 7000
+ 7001
+
+
diff --git a/spring-cql/pom.xml b/spring-cql/pom.xml
index a50919052..d16ad210d 100644
--- a/spring-cql/pom.xml
+++ b/spring-cql/pom.xml
@@ -71,10 +71,6 @@
el-apitest
-
- org.cassandraunit
- cassandra-unit-spring
- org.apache.cassandracassandra-all
@@ -82,8 +78,8 @@
test
- slf4j-log4j12
- org.slf4j
+ ch.qos.logback
+ logback-coreguava
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/config/PoolingOptionsFactoryBeanTest.java b/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTest.java
similarity index 88%
rename from spring-cql/src/test/java/org/springframework/cassandra/test/unit/config/PoolingOptionsFactoryBeanTest.java
rename to spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTest.java
index 6216b0eea..57818a123 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/config/PoolingOptionsFactoryBeanTest.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTest.java
@@ -1,31 +1,30 @@
/*
- * Copyright 2013-2014 the original author or authors.
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.cassandra.test.unit.config;
+package org.springframework.cassandra.config;
import org.junit.Assert;
import org.junit.Test;
-import org.springframework.cassandra.config.PoolingOptionsFactoryBean;
/**
- * Pooling Options Factory Bean Test. https://jira.spring.io/browse/DATACASS-176
- *
+ * Unit tests for {@link PoolingOptionsFactoryBean}
+ *
* @author Sumit Kumar
* @author David Webb
*/
-public class PoolingOptionsFactoryBeanTest {
+public class PoolingOptionsFactoryBeanUnitTest {
private static final int REMOTE_MIN_SIMULTANEOUS_REQUESTS = 111;
private static final int REMOTE_MAX_SIMULTANEOUS_REQUESTS = 127;
@@ -39,8 +38,9 @@ public class PoolingOptionsFactoryBeanTest {
/**
* The max values should be set before setting core values. Otherwise the core values will be compared with the
* default max values which is 8. Same for other min-max properties pairs. This test checks the same.
- *
+ *
* @throws Exception Any unhandled scenarios will result in a test failure.
+ * @see DATACASS-176
*/
@Test
public void testAfterPropertiesSet() throws Exception {
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/CqlIdentifierTest.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/CqlIdentifierUnitTests.java
similarity index 85%
rename from spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/CqlIdentifierTest.java
rename to spring-cql/src/test/java/org/springframework/cassandra/core/cql/CqlIdentifierUnitTests.java
index c90d6d47e..0209e72ca 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/CqlIdentifierTest.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/CqlIdentifierUnitTests.java
@@ -1,29 +1,33 @@
/*
- * Copyright 2013-2014 the original author or authors.
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.cassandra.test.unit.core.cql;
+package org.springframework.cassandra.core.cql;
import static org.junit.Assert.*;
-import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
-import static org.springframework.cassandra.core.cql.CqlIdentifier.quotedCqlId;
+import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
import org.junit.Test;
import org.springframework.cassandra.core.ReservedKeyword;
-import org.springframework.cassandra.core.cql.CqlIdentifier;
-public class CqlIdentifierTest {
+/**
+ * Unit tests for {@link CqlIdentifier}.
+ *
+ * @author John McPeek
+ * @author Matthew T. Adams
+ */
+public class CqlIdentifierUnitTests {
@Test
public void testUnquotedIdentifiers() {
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/IndexOperationCqlGeneratorTest.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractIndexOperationCqlGeneratorTest.java
similarity index 79%
rename from spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/IndexOperationCqlGeneratorTest.java
rename to spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractIndexOperationCqlGeneratorTest.java
index 0eb3692c5..b31499892 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/IndexOperationCqlGeneratorTest.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractIndexOperationCqlGeneratorTest.java
@@ -1,35 +1,34 @@
/*
- * Copyright 2013-2014 the original author or authors.
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.cassandra.test.unit.core.cql.generator;
+package org.springframework.cassandra.core.cql.generator;
import org.junit.Test;
-import org.springframework.cassandra.core.cql.generator.IndexNameCqlGenerator;
import org.springframework.cassandra.core.keyspace.IndexNameSpecification;
/**
* Useful test class that specifies just about as much as you can for a CQL generation test. Intended to be extended by
* classes that contain methods annotated with {@link Test}. Everything is public because this is a test class with no
* need for encapsulation, and it makes for easier reuse in other tests like integration tests (hint hint).
- *
+ *
* @author Matthew T. Adams
* @author David Webb
* @param The type of the {@link IndexNameSpecification}
* @param The type of the {@link IndexNameCqlGenerator}
*/
-public abstract class IndexOperationCqlGeneratorTest, G extends IndexNameCqlGenerator>> {
+public abstract class AbstractIndexOperationCqlGeneratorTest, G extends IndexNameCqlGenerator>> {
public abstract S specification();
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/KeyspaceOperationCqlGeneratorTest.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractKeyspaceOperationCqlGeneratorTest.java
similarity index 78%
rename from spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/KeyspaceOperationCqlGeneratorTest.java
rename to spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractKeyspaceOperationCqlGeneratorTest.java
index 895174242..9ed3e84a0 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/KeyspaceOperationCqlGeneratorTest.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractKeyspaceOperationCqlGeneratorTest.java
@@ -1,26 +1,24 @@
/*
- * Copyright 2013-2014 the original author or authors.
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.cassandra.test.unit.core.cql.generator;
+package org.springframework.cassandra.core.cql.generator;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
-import org.springframework.cassandra.core.cql.generator.KeyspaceNameCqlGenerator;
-import org.springframework.cassandra.core.cql.generator.TableNameCqlGenerator;
import org.springframework.cassandra.core.keyspace.KeyspaceActionSpecification;
import org.springframework.cassandra.core.keyspace.TableNameSpecification;
@@ -28,12 +26,12 @@ import org.springframework.cassandra.core.keyspace.TableNameSpecification;
* Useful test class that specifies just about as much as you can for a CQL generation test. Intended to be extended by
* classes that contain methods annotated with {@link Test}. Everything is public because this is a test class with no
* need for encapsulation, and it makes for easier reuse in other tests like integration tests (hint hint).
- *
+ *
* @author Matthew T. Adams
* @param The type of the {@link TableNameSpecification}
* @param The type of the {@link TableNameCqlGenerator}
*/
-public abstract class KeyspaceOperationCqlGeneratorTest, G extends KeyspaceNameCqlGenerator>> {
+public abstract class AbstractKeyspaceOperationCqlGeneratorTest, G extends KeyspaceNameCqlGenerator>> {
public abstract S specification();
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/TableOperationCqlGeneratorTest.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractTableOperationCqlGeneratorTest.java
similarity index 78%
rename from spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/TableOperationCqlGeneratorTest.java
rename to spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractTableOperationCqlGeneratorTest.java
index bbba8e433..d10b5438e 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/TableOperationCqlGeneratorTest.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractTableOperationCqlGeneratorTest.java
@@ -1,33 +1,32 @@
/*
- * Copyright 2013-2014 the original author or authors.
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.cassandra.test.unit.core.cql.generator;
+package org.springframework.cassandra.core.cql.generator;
-import org.springframework.cassandra.core.cql.generator.TableNameCqlGenerator;
import org.springframework.cassandra.core.keyspace.TableNameSpecification;
/**
* Useful test class that specifies just about as much as you can for a CQL generation test. Intended to be extended by
* classes that contain methods annotated with {@link Test}. Everything is public because this is a test class with no
* need for encapsulation, and it makes for easier reuse in other tests like integration tests (hint hint).
- *
+ *
* @author Matthew T. Adams
* @param The type of the {@link TableNameSpecification}
* @param The type of the {@link TableNameCqlGenerator}
*/
-public abstract class TableOperationCqlGeneratorTest, G extends TableNameCqlGenerator>> {
+public abstract class AbstractTableOperationCqlGeneratorTest, G extends TableNameCqlGenerator>> {
public abstract S specification();
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/AlterKeyspaceCqlGeneratorTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java
similarity index 85%
rename from spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/AlterKeyspaceCqlGeneratorTests.java
rename to spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java
index b40aa1d60..4c302d5d3 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/AlterKeyspaceCqlGeneratorTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java
@@ -1,34 +1,39 @@
/*
- * Copyright 2013-2014 the original author or authors.
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.cassandra.test.unit.core.cql.generator;
+package org.springframework.cassandra.core.cql.generator;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
-import org.springframework.cassandra.core.cql.generator.AlterKeyspaceCqlGenerator;
import org.springframework.cassandra.core.keyspace.AlterKeyspaceSpecification;
import org.springframework.cassandra.core.keyspace.DefaultOption;
import org.springframework.cassandra.core.keyspace.KeyspaceOption;
import org.springframework.cassandra.core.keyspace.Option;
-import org.springframework.cassandra.test.unit.support.Utils;
+import org.springframework.cassandra.support.RandomKeySpaceName;
-public class AlterKeyspaceCqlGeneratorTests {
+/**
+ * Unit tests for {@link AlterKeyspaceCqlGenerator}.
+ *
+ * @author John McPeek
+ * @author Matthew T. Adams
+ */
+public class AlterKeyspaceCqlGeneratorUnitTests {
/**
* Asserts that the preamble is first & correctly formatted in the given CQL string.
@@ -53,12 +58,12 @@ public class AlterKeyspaceCqlGeneratorTests {
/**
* Convenient base class that other test classes can use so as not to repeat the generics declarations.
*/
- public static abstract class AlterKeyspaceTest extends
- KeyspaceOperationCqlGeneratorTest {}
+ public static abstract class AlterKeyspaceTest
+ extends AbstractKeyspaceOperationCqlGeneratorTest {}
public static class CompleteTest extends AlterKeyspaceTest {
- public String name = Utils.randomKeyspaceName();
+ public String name = RandomKeySpaceName.create();
public Boolean durableWrites = true;
public Map
-
- org.cassandraunit
- cassandra-unit-spring
- test
-
-
- slf4j-log4j12
- org.slf4j
-
-
-
-
org.apache.cassandracassandra-all
@@ -90,8 +78,8 @@
test
- slf4j-log4j12
- org.slf4j
+ ch.qos.logback
+ logback-coreguava
@@ -118,12 +106,6 @@
test
-
- org.hectorclient
- hector-core
- test
-
-
javax.validation
@@ -164,5 +146,4 @@
test
-
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/convert/ColumnReaderTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/ColumnReaderUnitTests.java
similarity index 69%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/convert/ColumnReaderTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/ColumnReaderUnitTests.java
index 4b55f7bad..4099d0fdd 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/convert/ColumnReaderTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/ColumnReaderUnitTests.java
@@ -1,29 +1,47 @@
-package org.springframework.data.cassandra.test.unit.convert;
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.data.cassandra.convert;
+
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.Row;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.cassandra.core.cql.CqlIdentifier;
-import org.springframework.data.cassandra.convert.ColumnReader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.given;
+import com.datastax.driver.core.ColumnDefinitions;
+import com.datastax.driver.core.Row;
+/**
+ * Unit tests for {@link ColumnReader}.
+ *
+ * @author Christopher Batey
+ */
@RunWith(MockitoJUnitRunner.class)
-public class ColumnReaderTest {
+public class ColumnReaderUnitTests {
public static final String NON_EXISTENT_COLUMN = "column_name";
- @Mock
- private Row row;
+ @Mock private Row row;
- @Mock
- private ColumnDefinitions columnDefinitions;
+ @Mock private ColumnDefinitions columnDefinitions;
private ColumnReader underTest;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/convert/MappingCassandraConverterTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUnitTests.java
similarity index 90%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/convert/MappingCassandraConverterTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUnitTests.java
index d567d0ce7..2d9ae4464 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/convert/MappingCassandraConverterTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUnitTests.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.convert;
+package org.springframework.data.cassandra.convert;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
+import static org.junit.Assume.*;
import java.io.Serializable;
import java.util.ArrayList;
@@ -27,8 +28,8 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.cassandra.core.PrimaryKeyType;
+import org.springframework.core.SpringVersion;
import org.springframework.core.convert.ConverterNotFoundException;
-import org.springframework.data.cassandra.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.mapping.CassandraType;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.PrimaryKeyClass;
@@ -47,12 +48,12 @@ import com.datastax.driver.core.querybuilder.Update;
import com.datastax.driver.core.querybuilder.Update.Assignments;
/**
- * Tests for {@link MappingCassandraConverter}.
- *
+ * Unit tests for {@link MappingCassandraConverter}.
+ *
* @author Mark Paluch
* @soundtrack Outlandich - Dont Leave Me Feat Cyt (Sun Kidz Electrocore Mix)
*/
-public class MappingCassandraConverterTests {
+public class MappingCassandraConverterUnitTests {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@@ -78,7 +79,9 @@ public class MappingCassandraConverterTests {
* @see DATACASS-260
*/
@Test
- public void insertEnumDoesNotMapToOrdinal() {
+ public void insertEnumDoesNotMapToOrdinalBeforeSpring43() {
+
+ assumeThat(SpringVersion.getVersion(), not(startsWith("4.3")));
expectedException.expect(ConverterNotFoundException.class);
expectedException.expectMessage(allOf(containsString("No converter found"), containsString("java.lang.Integer")));
@@ -91,6 +94,24 @@ public class MappingCassandraConverterTests {
mappingCassandraConverter.write(unsupportedEnumToOrdinalMapping, insert);
}
+ /**
+ * @see DATACASS-255
+ */
+ @Test
+ public void insertEnumMapsToOrdinalWithSpring43() {
+
+ assumeThat(SpringVersion.getVersion(), startsWith("4.3"));
+
+ UnsupportedEnumToOrdinalMapping unsupportedEnumToOrdinalMapping = new UnsupportedEnumToOrdinalMapping();
+ unsupportedEnumToOrdinalMapping.setAsOrdinal(Condition.USED);
+
+ Insert insert = QueryBuilder.insertInto("table");
+
+ mappingCassandraConverter.write(unsupportedEnumToOrdinalMapping, insert);
+
+ assertThat(getValues(insert), contains((Object) Integer.valueOf(Condition.USED.ordinal())));
+ }
+
/**
* @see DATACASS-260
*/
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentEntityVerifierIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityMetadataVerifierUnitTests.java
similarity index 71%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentEntityVerifierIntegrationTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityMetadataVerifierUnitTests.java
index 6fdaebf0a..a1034c20c 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentEntityVerifierIntegrationTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityMetadataVerifierUnitTests.java
@@ -1,19 +1,19 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.mapping;
+package org.springframework.data.cassandra.mapping;
import static org.junit.Assert.*;
@@ -21,81 +21,69 @@ import java.io.Serializable;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.LoggerFactory;
import org.springframework.cassandra.core.Ordering;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.annotation.Id;
-import org.springframework.data.cassandra.mapping.CassandraMappingContext;
-import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
-import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext;
-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.mapping.model.MappingException;
-/**
- * @author dwebb
- */
-public class BasicCassandraPersistentEntityVerifierIntegrationTest {
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
- CassandraMappingContext mappingContext;
+/**
+ * Unit tests for {@link org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntityMetadataVerifier}
+ * through {@link CassandraMappingContext}
+ *
+ * @author David Webb
+ * @author Mark Paluch
+ */
+public class BasicCassandraPersistentEntityMetadataVerifierUnitTests {
+
+ private static LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
+ private Logger logger = loggerContext.getLogger(BasicCassandraPersistentEntityMetadataVerifier.class);
+ private CassandraMappingContext mappingContext;
@Before
- public void init() {
-
+ public void setUp() {
mappingContext = new BasicCassandraMappingContext();
-
}
@Test(expected = MappingException.class)
public void testNonPersistentType() {
-
mappingContext.getPersistentEntity(NonPersistentClass.class);
-
}
@Test(expected = MappingException.class)
public void testTooManyAnnotations() {
-
mappingContext.getPersistentEntity(TooManyAnnotations.class);
-
}
@Test
public void testNonPrimaryKeyClass() {
-
mappingContext.getPersistentEntity(Person.class);
}
@Test(expected = MappingException.class)
public void testPrimaryKeyClassNotFullyImplemented() {
-
mappingContext.getPersistentEntity(AnimalPkNoOverrides.class);
-
}
@Test
public void testPrimaryKeyClass() {
mappingContext.getPersistentEntity(AnimalPK.class);
-
mappingContext.getPersistentEntity(Animal.class);
-
}
@Test(expected = MappingException.class)
public void testNoPartitionKey() {
-
mappingContext.getPersistentEntity(NoPartitionKey.class);
-
}
@Test(expected = MappingException.class)
public void testPkAndPkc() {
-
mappingContext.getPersistentEntity(PkAndPkc.class);
-
}
@Test
@@ -116,8 +104,7 @@ public class BasicCassandraPersistentEntityVerifierIntegrationTest {
static class NonPersistentClass {
- @Id
- private String id;
+ @Id private String id;
private String foo;
private String bar;
@@ -127,8 +114,7 @@ public class BasicCassandraPersistentEntityVerifierIntegrationTest {
@Table
static class Person {
- @Id
- private String id;
+ @Id private String id;
private String firstName;
private String lastName;
@@ -138,9 +124,7 @@ public class BasicCassandraPersistentEntityVerifierIntegrationTest {
@Table
static class Animal {
- @PrimaryKey
- private AnimalPK key;
-
+ @PrimaryKey AnimalPK key;
private String name;
}
@@ -157,28 +141,18 @@ public class BasicCassandraPersistentEntityVerifierIntegrationTest {
return super.equals(obj);
}
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private String species;
-
- @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED)
- private String breed;
-
- @PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.DESCENDING)
- private String color;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String species;
+ @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) String breed;
+ @PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.DESCENDING) String color;
}
@PrimaryKeyClass
static class AnimalPkNoOverrides {
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private String species;
-
- @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED)
- private String breed;
-
- @PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.DESCENDING)
- private String color;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String species;
+ @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) String breed;
+ @PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.DESCENDING) String color;
}
@Table
@@ -188,34 +162,26 @@ public class BasicCassandraPersistentEntityVerifierIntegrationTest {
@Table
public static class NoPartitionKey {
- @PrimaryKeyColumn(ordinal = 0)
- String key;
+ @PrimaryKeyColumn(ordinal = 0) String key;
}
@Table
public static class PkAndPkc {
- @PrimaryKey
- String primaryKey;
-
- @PrimaryKeyColumn(ordinal = 0)
- String primaryKeyColumn;
+ @PrimaryKey String primaryKey;
+ @PrimaryKeyColumn(ordinal = 0) String primaryKeyColumn;
}
@Table
public static class OnePkc {
- @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0)
- String pk;
+ @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0) String pk;
}
@Table
public static class MultiPkc {
- @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0)
- String pk0;
-
- @PrimaryKeyColumn(ordinal = 1)
- String pk1;
+ @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0) String pk0;
+ @PrimaryKeyColumn(ordinal = 1) String pk1;
}
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/BasicCassandraPersistentEntityOrderPropertiesTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityOrderPropertiesUnitTests.java
similarity index 79%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/BasicCassandraPersistentEntityOrderPropertiesTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityOrderPropertiesUnitTests.java
index 782d308bc..d3f25395a 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/BasicCassandraPersistentEntityOrderPropertiesTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityOrderPropertiesUnitTests.java
@@ -1,21 +1,21 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.unit;
+package org.springframework.data.cassandra.mapping;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
import java.io.Serializable;
import java.util.LinkedList;
@@ -25,19 +25,14 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.annotation.Id;
-import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
-import org.springframework.data.cassandra.mapping.CassandraPersistentProperty;
-import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext;
-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.mapping.PropertyHandler;
/**
+ * Unit tests for {@link BasicCassandraMappingContext}.
+ *
* @author David Webb
*/
-public class BasicCassandraPersistentEntityOrderPropertiesTest {
+public class BasicCassandraPersistentEntityOrderPropertiesUnitTests {
private List expected;
private BasicCassandraMappingContext mappingContext = new BasicCassandraMappingContext();
@@ -96,8 +91,7 @@ public class BasicCassandraPersistentEntityOrderPropertiesTest {
@Table
static class CompositeKeyEntity {
- @PrimaryKey
- private CompositePK key;
+ @PrimaryKey private CompositePK key;
private String attribute;
@@ -111,14 +105,11 @@ public class BasicCassandraPersistentEntityOrderPropertiesTest {
@PrimaryKeyClass
static class CompositePK implements Serializable {
- @PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.PARTITIONED)
- private String key0;
+ @PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.PARTITIONED) private String key0;
- @PrimaryKeyColumn(ordinal = 0)
- private String key1;
+ @PrimaryKeyColumn(ordinal = 0) private String key1;
- @PrimaryKeyColumn(ordinal = 1)
- private String key2;
+ @PrimaryKeyColumn(ordinal = 1) private String key2;
@Override
public int hashCode() {
@@ -162,8 +153,7 @@ public class BasicCassandraPersistentEntityOrderPropertiesTest {
@Table
static class SimpleKeyEntity {
- @Id
- private String id;
+ @Id private String id;
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentEntityIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityUnitTests.java
similarity index 78%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentEntityIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityUnitTests.java
index 28df7b5dc..83306656b 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentEntityIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityUnitTests.java
@@ -1,44 +1,41 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.mapping;
+package org.springframework.data.cassandra.mapping;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.when;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import org.junit.Test;
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;
/**
- * Integration tests for {@link BasicCassandraPersistentEntity}.
- *
+ * Unit tests for {@link BasicCassandraPersistentEntity}.
+ *
* @author Alex Shvid
* @author Matthew T. Adams
*/
@RunWith(MockitoJUnitRunner.class)
-public class BasicCassandraPersistentEntityIntegrationTests {
+public class BasicCassandraPersistentEntityUnitTests {
- @Mock
- ApplicationContext context;
+ @Mock ApplicationContext context;
@Test
public void subclassInheritsAtDocumentAnnotation() {
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentPropertyIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentPropertyUnitTests.java
similarity index 63%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentPropertyIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentPropertyUnitTests.java
index 18fb9df40..8be596e08 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/BasicCassandraPersistentPropertyIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentPropertyUnitTests.java
@@ -1,55 +1,45 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.mapping;
+package org.springframework.data.cassandra.mapping;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
import java.lang.reflect.Field;
import java.util.Date;
import org.junit.Before;
import org.junit.Test;
-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.CassandraSimpleTypeHolder;
-import org.springframework.data.cassandra.mapping.Column;
-import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.util.ReflectionUtils;
/**
- * Integration test for {@link BasicCassandraPersistentProperty}.
- *
+ * Unit tests for {@link BasicCassandraPersistentProperty}.
+ *
* @author Alex Shvid
*/
-public class BasicCassandraPersistentPropertyIntegrationTests {
+public class BasicCassandraPersistentPropertyUnitTests {
static class Timeline {
- @PrimaryKey
- String id;
+ @PrimaryKey String id;
Date time;
- @Column("message")
- String text;
+ @Column("message") String text;
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/CassandraCompositePrimaryKeyIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CassandraCompositePrimaryKeyUnitTests.java
similarity index 76%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/CassandraCompositePrimaryKeyIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CassandraCompositePrimaryKeyUnitTests.java
index 23892b034..1a3107852 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/CassandraCompositePrimaryKeyIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CassandraCompositePrimaryKeyUnitTests.java
@@ -1,23 +1,22 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.mapping;
+package org.springframework.data.cassandra.mapping;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
+import static org.junit.Assert.*;
+import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
import java.io.Serializable;
import java.lang.reflect.Field;
@@ -32,28 +31,17 @@ import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.cassandra.core.cql.CqlIdentifier;
import org.springframework.cassandra.core.keyspace.ColumnSpecification;
import org.springframework.cassandra.core.keyspace.CreateTableSpecification;
-import org.springframework.data.cassandra.mapping.BasicCassandraPersistentProperty;
-import org.springframework.data.cassandra.mapping.CassandraMappingContext;
-import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
-import org.springframework.data.cassandra.mapping.CassandraPersistentProperty;
-import org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder;
-import org.springframework.data.cassandra.mapping.Column;
-import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext;
-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;
import com.datastax.driver.core.DataType;
/**
- * Integration test for {@link BasicCassandraPersistentProperty} with a composite primary key class.
- *
+ * Unit tests for {@link BasicCassandraPersistentProperty} with a composite primary key class.
+ *
* @author Matthew T. Adams
*/
-public class CassandraCompositePrimaryKeyIntegrationTests {
+public class CassandraCompositePrimaryKeyUnitTests {
private static final CassandraSimpleTypeHolder SIMPLE_TYPE_HOLDER = new CassandraSimpleTypeHolder();
@@ -62,11 +50,9 @@ public class CassandraCompositePrimaryKeyIntegrationTests {
private static final long serialVersionUID = 1L;
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String z;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String z;
- @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.CLUSTERED)
- String a;
+ @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.CLUSTERED) String a;
@Override
public int hashCode() {
@@ -104,13 +90,11 @@ public class CassandraCompositePrimaryKeyIntegrationTests {
@Table
static class Thing {
- @PrimaryKey
- Key id;
+ @PrimaryKey Key id;
Date time;
- @Column("message")
- String text;
+ @Column("message") String text;
}
CassandraMappingContext context;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/CompoundPrimaryKeyIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CompoundPrimaryKeyUnitTests.java
similarity index 60%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/CompoundPrimaryKeyIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CompoundPrimaryKeyUnitTests.java
index 83474fadd..1e1d23a7e 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/CompoundPrimaryKeyIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CompoundPrimaryKeyUnitTests.java
@@ -1,21 +1,21 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.mapping;
+package org.springframework.data.cassandra.mapping;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.lang.reflect.Field;
import java.util.Date;
@@ -23,44 +23,30 @@ 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.CassandraPersistentEntity;
-import org.springframework.data.cassandra.mapping.CassandraPersistentProperty;
-import org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder;
-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;
/**
- * Integration test for {@link BasicCassandraPersistentProperty}.
- *
+ * Unit tests for {@link BasicCassandraPersistentProperty}.
+ *
* @author Alex Shvid
* @author Matthew T. Adams
*/
-public class CompoundPrimaryKeyIntegrationTests {
+public class CompoundPrimaryKeyUnitTests {
@PrimaryKeyClass
static class TimelineKey {
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String string;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String string;
- @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED)
- Date datetime;
+ @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) Date datetime;
}
@Table
static class Timeline {
- @PrimaryKey
- TimelineKey id;
+ @PrimaryKey TimelineKey id;
- @Column("message")
- String text;
+ @Column("message") String text;
}
CassandraPersistentEntity cpk;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/simple/ForceQuotedEntitiesSimpleIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedEntitiesSimpleUnitTests.java
similarity index 67%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/simple/ForceQuotedEntitiesSimpleIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedEntitiesSimpleUnitTests.java
index 8e53081ed..e8ae3518f 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/simple/ForceQuotedEntitiesSimpleIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedEntitiesSimpleUnitTests.java
@@ -1,13 +1,32 @@
-package org.springframework.data.cassandra.test.integration.forcequote.simple;
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-import static org.junit.Assert.assertEquals;
+package org.springframework.data.cassandra.mapping;
+
+import static org.junit.Assert.*;
import org.junit.Test;
-import org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntity;
-import org.springframework.data.cassandra.mapping.Table;
import org.springframework.data.util.ClassTypeInformation;
-public class ForceQuotedEntitiesSimpleIntegrationTests {
+/**
+ * Unit tests for {@link BasicCassandraPersistentEntity}.
+ *
+ * @author Matthew T. Adams
+ */
+public class ForceQuotedEntitiesSimpleUnitTests {
@Test
public void testImplicitTableNameForceQuoted() {
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/simple/ForceQuotedPropertiesSimpleIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedPropertiesSimpleUnitTests.java
similarity index 73%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/simple/ForceQuotedPropertiesSimpleIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedPropertiesSimpleUnitTests.java
index 8269eaf2f..c91e42ed1 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/simple/ForceQuotedPropertiesSimpleIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedPropertiesSimpleUnitTests.java
@@ -1,9 +1,23 @@
-package org.springframework.data.cassandra.test.integration.forcequote.simple;
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
-import static org.springframework.cassandra.core.cql.CqlIdentifier.quotedCqlId;
+package org.springframework.data.cassandra.mapping;
+
+import static org.junit.Assert.*;
+import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
import java.io.Serializable;
import java.util.Arrays;
@@ -12,17 +26,18 @@ import java.util.List;
import org.junit.Test;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.cassandra.core.cql.CqlIdentifier;
-import org.springframework.data.cassandra.mapping.CassandraMappingContext;
-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.BasicCassandraMappingContext;
-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;
-public class ForceQuotedPropertiesSimpleIntegrationTests {
+/**
+ * Unit tests for {@link BasicCassandraMappingContext}.
+ *
+ * @author Matthew T. Adams
+ */
+public class ForceQuotedPropertiesSimpleUnitTests {
+
+ public static final String EXPLICIT_PRIMARY_KEY_NAME = "ThePrimaryKey";
+ public static final String EXPLICIT_COLUMN_NAME = "AnotherColumn";
+ public static final String EXPLICIT_KEY_0 = "TheFirstKeyField";
+ public static final String EXPLICIT_KEY_1 = "TheSecondKeyField";
CassandraMappingContext context = new BasicCassandraMappingContext();
@@ -40,11 +55,9 @@ public class ForceQuotedPropertiesSimpleIntegrationTests {
@Table
public static class Implicit {
- @PrimaryKey(forceQuote = true)
- String primaryKey;
+ @PrimaryKey(forceQuote = true) String primaryKey;
- @Column(forceQuote = true)
- String aString;
+ @Column(forceQuote = true) String aString;
}
@Test
@@ -61,16 +74,11 @@ public class ForceQuotedPropertiesSimpleIntegrationTests {
@Table
public static class Default {
- @PrimaryKey
- String primaryKey;
+ @PrimaryKey String primaryKey;
- @Column
- String aString;
+ @Column String aString;
}
- public static final String EXPLICIT_PRIMARY_KEY_NAME = "ThePrimaryKey";
- public static final String EXPLICIT_COLUMN_NAME = "AnotherColumn";
-
@Test
public void testExplicit() {
CassandraPersistentEntity> entity = context.getPersistentEntity(Explicit.class);
@@ -85,11 +93,9 @@ public class ForceQuotedPropertiesSimpleIntegrationTests {
@Table
public static class Explicit {
- @PrimaryKey(value = EXPLICIT_PRIMARY_KEY_NAME, forceQuote = true)
- String primaryKey;
+ @PrimaryKey(value = EXPLICIT_PRIMARY_KEY_NAME, forceQuote = true) String primaryKey;
- @Column(value = EXPLICIT_COLUMN_NAME, forceQuote = true)
- String aString;
+ @Column(value = EXPLICIT_COLUMN_NAME, forceQuote = true) String aString;
}
@Test
@@ -114,21 +120,17 @@ public class ForceQuotedPropertiesSimpleIntegrationTests {
private static final long serialVersionUID = -1956747638065267667L;
- @PrimaryKeyColumn(ordinal = 0, forceQuote = true, type = PrimaryKeyType.PARTITIONED)
- String stringZero;
+ @PrimaryKeyColumn(ordinal = 0, forceQuote = true, type = PrimaryKeyType.PARTITIONED) String stringZero;
- @PrimaryKeyColumn(ordinal = 1, forceQuote = true)
- String stringOne;
+ @PrimaryKeyColumn(ordinal = 1, forceQuote = true) String stringOne;
}
@Table
public static class ImplicitComposite {
- @PrimaryKey(forceQuote = true)
- ImplicitKey primaryKey;
+ @PrimaryKey(forceQuote = true) ImplicitKey primaryKey;
- @Column(forceQuote = true)
- String aString;
+ @Column(forceQuote = true) String aString;
}
@Test
@@ -154,26 +156,19 @@ public class ForceQuotedPropertiesSimpleIntegrationTests {
private static final long serialVersionUID = -1956747638065267667L;
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String stringZero;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String stringZero;
- @PrimaryKeyColumn(ordinal = 1)
- String stringOne;
+ @PrimaryKeyColumn(ordinal = 1) String stringOne;
}
@Table
public static class DefaultComposite {
- @PrimaryKey
- DefaultKey primaryKey;
+ @PrimaryKey DefaultKey primaryKey;
- @Column
- String aString;
+ @Column String aString;
}
- public static final String EXPLICIT_KEY_0 = "TheFirstKeyField";
- public static final String EXPLICIT_KEY_1 = "TheSecondKeyField";
-
@Test
public void testExplicitComposite() {
CassandraPersistentEntity> key = context.getPersistentEntity(ExplicitKey.class);
@@ -184,8 +179,8 @@ public class ForceQuotedPropertiesSimpleIntegrationTests {
assertEquals("\"" + EXPLICIT_KEY_0 + "\"", stringZero.getColumnName().toCql());
assertEquals("\"" + EXPLICIT_KEY_1 + "\"", stringOne.getColumnName().toCql());
- List names = Arrays.asList(new CqlIdentifier[] { quotedCqlId(EXPLICIT_KEY_0),
- quotedCqlId(EXPLICIT_KEY_1) });
+ List names = Arrays
+ .asList(new CqlIdentifier[] { quotedCqlId(EXPLICIT_KEY_0), quotedCqlId(EXPLICIT_KEY_1) });
CassandraPersistentEntity> entity = context.getPersistentEntity(ExplicitComposite.class);
assertEquals(names, entity.getPersistentProperty("primaryKey").getColumnNames());
@@ -196,20 +191,17 @@ public class ForceQuotedPropertiesSimpleIntegrationTests {
private static final long serialVersionUID = -1956747638065267667L;
- @PrimaryKeyColumn(ordinal = 0, name = EXPLICIT_KEY_0, forceQuote = true, type = PrimaryKeyType.PARTITIONED)
- String stringZero;
+ @PrimaryKeyColumn(ordinal = 0, name = EXPLICIT_KEY_0, forceQuote = true,
+ type = PrimaryKeyType.PARTITIONED) String stringZero;
- @PrimaryKeyColumn(ordinal = 1, name = EXPLICIT_KEY_1, forceQuote = true)
- String stringOne;
+ @PrimaryKeyColumn(ordinal = 1, name = EXPLICIT_KEY_1, forceQuote = true) String stringOne;
}
@Table
public static class ExplicitComposite {
- @PrimaryKey(forceQuote = true)
- ExplicitKey primaryKey;
+ @PrimaryKey(forceQuote = true) ExplicitKey primaryKey;
- @Column(forceQuote = true)
- String aString;
+ @Column(forceQuote = true) String aString;
}
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mappingcontext/MappingContextIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/MappingContextIntegrationUnitTests.java
similarity index 63%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mappingcontext/MappingContextIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/MappingContextIntegrationUnitTests.java
index 2f201544a..3128b2c07 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mappingcontext/MappingContextIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/MappingContextIntegrationUnitTests.java
@@ -1,45 +1,42 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.mappingcontext;
+package org.springframework.data.cassandra.mapping;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import org.junit.Test;
-import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
-import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext;
-import org.springframework.data.cassandra.mapping.PrimaryKey;
-import org.springframework.data.cassandra.mapping.Table;
import org.springframework.data.mapping.model.MappingException;
-public class MappingContextIntegrationTests {
+/**
+ * Unit tests for {@link BasicCassandraMappingContext}.
+ *
+ * @author Matthew T. Adams
+ */
+public class MappingContextIntegrationUnitTests {
public static class Transient {}
@Table
public static class X {
- @PrimaryKey
- String key;
+ @PrimaryKey String key;
}
@Table
public static class Y {
- @PrimaryKey
- String key;
+ @PrimaryKey String key;
}
BasicCassandraMappingContext ctx = new BasicCassandraMappingContext();
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/MultipackageScanningIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/MultipackageScanningUnitTests.java
similarity index 72%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/MultipackageScanningIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/MultipackageScanningUnitTests.java
index d370ce991..1beea2194 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/MultipackageScanningIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/MultipackageScanningUnitTests.java
@@ -1,22 +1,21 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.multipackagescanning;
+package org.springframework.data.cassandra.mapping.multipackagescanning;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.util.Collection;
import java.util.HashSet;
@@ -24,13 +23,18 @@ import java.util.HashSet;
import org.junit.Before;
import org.junit.Test;
import org.springframework.data.cassandra.config.CassandraEntityClassScanner;
-import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext;
-import org.springframework.data.cassandra.test.integration.multipackagescanning.first.First;
-import org.springframework.data.cassandra.test.integration.multipackagescanning.second.Second;
-import org.springframework.data.cassandra.test.integration.multipackagescanning.third.Third;
+import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
+import org.springframework.data.cassandra.mapping.multipackagescanning.first.First;
+import org.springframework.data.cassandra.mapping.multipackagescanning.second.Second;
+import org.springframework.data.cassandra.mapping.multipackagescanning.third.Third;
-public class MultipackageScanningIntegrationTests {
+/**
+ * Unit tests for {@link BasicCassandraMappingContext}.
+ *
+ * @author Matthew T. Adams
+ */
+public class MultipackageScanningUnitTests {
BasicCassandraMappingContext mapping;
String pkg = getClass().getPackage().getName();
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/Top.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/Top.java
similarity index 74%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/Top.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/Top.java
index 0a6f09a16..0d721b541 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/Top.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/Top.java
@@ -1,19 +1,19 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.multipackagescanning;
+package org.springframework.data.cassandra.mapping.multipackagescanning;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
@@ -21,6 +21,5 @@ import org.springframework.data.cassandra.mapping.Table;
@Table
public class Top {
- @PrimaryKey
- String key;
+ @PrimaryKey String key;
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/first/First.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/first/First.java
similarity index 85%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/first/First.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/first/First.java
index 237de0b0f..75c2282f7 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/first/First.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/first/First.java
@@ -1,19 +1,19 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.multipackagescanning.first;
+package org.springframework.data.cassandra.mapping.multipackagescanning.first;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
@@ -21,6 +21,5 @@ import org.springframework.data.cassandra.mapping.Table;
@Table
public class First {
- @PrimaryKey
- String key;
+ @PrimaryKey String key;
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/second/Second.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/second/Second.java
similarity index 85%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/second/Second.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/second/Second.java
index 6fb615ce7..8349ae153 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/second/Second.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/second/Second.java
@@ -1,19 +1,19 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.multipackagescanning.second;
+package org.springframework.data.cassandra.mapping.multipackagescanning.second;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
@@ -21,6 +21,5 @@ import org.springframework.data.cassandra.mapping.Table;
@Table
public class Second {
- @PrimaryKey
- String key;
+ @PrimaryKey String key;
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/third/Third.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/third/Third.java
similarity index 85%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/third/Third.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/third/Third.java
index 60768176c..0e7062b06 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/multipackagescanning/third/Third.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/multipackagescanning/third/Third.java
@@ -1,19 +1,19 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.multipackagescanning.third;
+package org.springframework.data.cassandra.mapping.multipackagescanning.third;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
@@ -21,6 +21,5 @@ import org.springframework.data.cassandra.mapping.Table;
@Table
public class Third {
- @PrimaryKey
- String key;
+ @PrimaryKey String key;
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/repository/config/CassandraRepositoryConfigurationExtensionUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/CassandraRepositoryConfigurationExtensionUnitTests.java
similarity index 93%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/repository/config/CassandraRepositoryConfigurationExtensionUnitTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/CassandraRepositoryConfigurationExtensionUnitTests.java
index 5e5cc4bbf..44ebc7a68 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/repository/config/CassandraRepositoryConfigurationExtensionUnitTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/CassandraRepositoryConfigurationExtensionUnitTests.java
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.unit.repository.config;
+
+package org.springframework.data.cassandra.repository.config;
import static org.junit.Assert.*;
@@ -28,14 +29,14 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.data.cassandra.mapping.Table;
import org.springframework.data.cassandra.repository.CassandraRepository;
-import org.springframework.data.cassandra.repository.config.CassandraRepositoryConfigurationExtension;
-import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
import org.springframework.data.repository.config.RepositoryConfiguration;
import org.springframework.data.repository.config.RepositoryConfigurationSource;
/**
+ * Unit tests for {@link CassandraRepositoryConfigurationExtension}.
+ *
* @author Christoph Strobl
*/
public class CassandraRepositoryConfigurationExtensionUnitTests {
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/BasicMapIdUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/BasicMapIdUnitTests.java
new file mode 100644
index 000000000..fe01548f5
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/BasicMapIdUnitTests.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.data.cassandra.repository.support;
+
+import static org.junit.Assert.*;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+/**
+ * Unit tests for {@link BasicMapId}.
+ *
+ * @author Matthew T. Adams
+ */
+public class BasicMapIdUnitTests {
+ @Test
+ public void testMapConstructor() {
+ Map map = new HashMap();
+ map.put("field1", "value1");
+ map.put("field2", 2);
+
+ BasicMapId basicMapId = new BasicMapId(map);
+
+ assertEquals(basicMapId.get("field1"), map.get("field1"));
+ assertEquals(basicMapId.get("field2"), map.get("field2"));
+ }
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/mapidfactory/MapIdFactoryTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/MapIdFactoryUnitTests.java
similarity index 87%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/mapidfactory/MapIdFactoryTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/MapIdFactoryUnitTests.java
index 0d199fe19..cbd82d8a4 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/unit/mapidfactory/MapIdFactoryTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/MapIdFactoryUnitTests.java
@@ -1,21 +1,37 @@
-package org.springframework.data.cassandra.test.unit.mapidfactory;
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.springframework.data.cassandra.repository.support.IdInterfaceValidator.validate;
-import static org.springframework.data.cassandra.repository.support.MapIdFactory.id;
+package org.springframework.data.cassandra.repository.support;
+
+import static org.junit.Assert.*;
+import static org.springframework.data.cassandra.repository.support.IdInterfaceValidator.*;
+import static org.springframework.data.cassandra.repository.support.MapIdFactory.*;
import java.io.Serializable;
import java.util.Random;
import org.junit.Test;
import org.springframework.data.cassandra.repository.MapId;
-import org.springframework.data.cassandra.repository.support.IdInterfaceExceptions;
-public class MapIdFactoryTest {
+/**
+ * Unit tests for {@link MapIdFactory}.
+ *
+ * @author Matthew T. Adams
+ */
+public class MapIdFactoryUnitTests {
interface HappyExtendingMapIdAndSerializable extends MapId, Serializable {
HappyExtendingMapIdAndSerializable string(String s);
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderIntegrationTests.java
similarity index 93%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderIntegrationTests.java
index ce14d333f..4e75ef619 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderIntegrationTests.java
@@ -28,7 +28,9 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
+import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.test.integration.simpletons.Book;
import org.springframework.data.cassandra.test.integration.simpletons.BookHistory;
import org.springframework.data.cassandra.test.integration.simpletons.BookReference;
@@ -45,7 +47,7 @@ import com.datastax.driver.core.querybuilder.Select;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class CollectionsRowValueProviderTest extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class CollectionsRowValueProviderIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@Configuration
public static class Config extends IntegrationTestConfig {
@@ -56,6 +58,8 @@ public class CollectionsRowValueProviderTest extends AbstractSpringDataEmbeddedC
}
}
+ @Autowired CassandraOperations template;
+
@Before
public void before() throws IOException {
deleteAllEntities();
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Comment.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Comment.java
index 93e1877f4..80b68c562 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Comment.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Comment.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,15 +22,14 @@ import org.springframework.util.Assert;
/**
* This is an example of dynamic table (wide row). PartitionKey (former RowId) is pk.author. ClusteredColumn (former
* Column Id) is pk.time
- *
+ *
* @author Alex Shvid
* @author Matthew T. Adams
*/
@Table("comments")
public class Comment {
- @PrimaryKey
- private CommentKey pk;
+ @PrimaryKey private CommentKey pk;
private String text;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentKey.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentKey.java
index 9c0a31ac0..2d8380ee7 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentKey.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentKey.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@ import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
/**
* This is an example of dynamic table (wide row) that creates each time new column with timestamp.
- *
+ *
* @author Alex Shvid
* @author Matthew T. Adams
*/
@@ -32,11 +32,9 @@ public class CommentKey implements Serializable {
private static final long serialVersionUID = -7871651389236401141L;
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private String author;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String author;
- @PrimaryKeyColumn(ordinal = 1)
- private String company;
+ @PrimaryKeyColumn(ordinal = 1) private String company;
/**
* @deprecated Only for use by persistence infrastructure
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryIntegrationTests.java
index 42eda1044..2b9d871cc 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryIntegrationTests.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,15 +15,13 @@
*/
package org.springframework.data.cassandra.test.integration.composites;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
import org.springframework.data.cassandra.core.CassandraOperations;
/**
* Tests for {@link CommentRepository}.
- *
+ *
* @author Matthew T. Adams
*/
public class CommentRepositoryIntegrationTests {
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryJavaConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryJavaConfigIntegrationTests.java
index 07ffa027c..e0972bf82 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryJavaConfigIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryJavaConfigIntegrationTests.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
-import org.springframework.data.cassandra.test.integration.repository.UserRepository;
+import org.springframework.data.cassandra.test.integration.repository.simple.UserRepository;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig;
import org.springframework.test.context.ContextConfiguration;
@@ -30,7 +30,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Base class for Java config tests for {@link UserRepository}.
- *
+ *
* @author Matthew T. Adams
*/
@RunWith(SpringJUnit4ClassRunner.class)
@@ -52,11 +52,9 @@ public class CommentRepositoryJavaConfigIntegrationTests extends AbstractSpringD
}
}
- @Autowired
- protected CommentRepository repository;
+ @Autowired protected CommentRepository repository;
- @Autowired
- protected CassandraOperations template;
+ @Autowired protected CassandraOperations template;
CommentRepositoryIntegrationTests tests;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryXmlConfigIntegrationTests.java
index ce8e9ac42..492a95832 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryXmlConfigIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/CommentRepositoryXmlConfigIntegrationTests.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2013-2016 the original author or authors
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,27 +20,26 @@ 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.repository.UserRepository;
+import org.springframework.data.cassandra.test.integration.repository.simple.UserRepository;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Base class for xml config tests for {@link UserRepository}.
- *
+ *
* @author Matthew T. Adams
+ * @author Mark Paluch
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class CommentRepositoryXmlConfigIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
- @Autowired
- protected CommentRepository repository;
+ @Autowired private CommentRepository repository;
- @Autowired
- protected CassandraOperations template;
+ @Autowired private CassandraOperations template;
- CommentRepositoryIntegrationTests tests;
+ private CommentRepositoryIntegrationTests tests;
@Before
public void setUp() throws InterruptedException {
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Notification.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Notification.java
index f30554b70..ccbd952c6 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Notification.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Notification.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ import org.springframework.data.cassandra.mapping.Table;
* This is an example of dynamic table that creates each time new column with Notification timestamp. By default it is
* active Notification until user deactivate it. This table uses index on the field active to access in WHERE cause only
* for active notifications.
- *
+ *
* @author Alex Shvid
*/
@Table("notifications")
@@ -34,11 +34,9 @@ public class Notification {
/*
* Primary Key
*/
- @Id
- private NotificationPK pk;
+ @Id private NotificationPK pk;
- @Indexed
- private boolean active;
+ @Indexed private boolean active;
/*
* Reference data
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/NotificationPK.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/NotificationPK.java
index 12fab6925..d667074c4 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/NotificationPK.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/NotificationPK.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,7 @@ import com.datastax.driver.core.DataType;
* This is an example of dynamic table that creates each time new column with Notification timestamp. By default it is
* active Notification until user deactivate it. This table uses index on the field active to access in WHERE cause only
* for active notifications.
- *
+ *
* @author Alex Shvid
*/
@PrimaryKeyClass
@@ -40,15 +40,12 @@ public class NotificationPK implements Serializable {
/*
* Row ID
*/
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private String username;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String username;
/*
* Clustered Column
*/
- @PrimaryKeyColumn(ordinal = 1)
- @CassandraType(type = DataType.Name.TIMESTAMP)
- private Date time;
+ @PrimaryKeyColumn(ordinal = 1) @CassandraType(type = DataType.Name.TIMESTAMP) private Date time;
public String getUsername() {
return username;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Post.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Post.java
index 35574559f..67ec8ebf5 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Post.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Post.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,7 +27,7 @@ import org.springframework.data.cassandra.mapping.Table;
* static table for posts and identify them by PostId(UUID), but in this case we need to use MapReduce for Big Data to
* find posts for particular user, so it is better to have index (userId) -> index (post time) architecture. It helps a
* lot to build eventually a search index for the particular user.
- *
+ *
* @author Alex Shvid
*/
@Table("posts")
@@ -36,8 +36,7 @@ public class Post {
/*
* Primary Key
*/
- @Id
- private PostPK pk;
+ @Id private PostPK pk;
private String type; // status, share
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/PostPK.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/PostPK.java
index 98d832488..ce05c50b9 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/PostPK.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/PostPK.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,7 +27,7 @@ import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
* static table for posts and identify them by PostId(UUID), but in this case we need to use MapReduce for Big Data to
* find posts for particular user, so it is better to have index (userId) -> index (post time) architecture. It helps a
* lot to build eventually a search index for the particular user.
- *
+ *
* @author Alex Shvid
*/
@@ -36,11 +36,9 @@ public class PostPK implements Serializable {
private static final long serialVersionUID = 2390757126054483315L;
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private String author;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String author;
- @PrimaryKeyColumn(ordinal = 1)
- private Date time;
+ @PrimaryKeyColumn(ordinal = 1) private Date time;
public String getAuthor() {
return author;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Timeline.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Timeline.java
index 870a88f60..801860d25 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Timeline.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/Timeline.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ import org.springframework.data.cassandra.mapping.Table;
* value. The rest fields are places in Cassandra value. Timeline entity is used to store user's status updates that it
* follows in the site. Timeline always ordered by @ColumnId field and we can retrieve last top status updates by using
* limits.
- *
+ *
* @author Alex Shvid
*/
@Table("timeline")
@@ -34,8 +34,7 @@ public class Timeline {
/*
* Row ID
*/
- @Id
- private TimelinePK pk;
+ @Id private TimelinePK pk;
/*
* Reference to the post by author and postUID
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/TimelinePK.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/TimelinePK.java
index 55306ad6f..bfb470872 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/TimelinePK.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/composites/TimelinePK.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,7 +27,7 @@ import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
* value. The rest fields are places in Cassandra value. Timeline entity is used to store user's status updates that it
* follows in the site. Timeline always ordered by @ColumnId field and we can retrieve last top status updates by using
* limits.
- *
+ *
* @author Alex Shvid
*/
@@ -39,14 +39,12 @@ public class TimelinePK implements Serializable {
/*
* Row ID
*/
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private String username;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String username;
/*
* Clustered Column
*/
- @PrimaryKeyColumn(ordinal = 1)
- private Date time;
+ @PrimaryKeyColumn(ordinal = 1) private Date time;
public String getUsername() {
return username;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/config/CassandraNamespaceTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/config/CassandraNamespaceIntegrationTests.java
similarity index 83%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/config/CassandraNamespaceTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/config/CassandraNamespaceIntegrationTests.java
index 0373bf7d6..c98ec5540 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/config/CassandraNamespaceTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/config/CassandraNamespaceIntegrationTests.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2013-2016 the original author or authors
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,15 +24,18 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.Assert;
+/**
+ * @author Mark Paluch
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class CassandraNamespaceTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
- @Autowired
- private ApplicationContext ctx;
+ @Autowired ApplicationContext ctx;
@Test
public void test() {
Assert.notNull(ctx);
}
+
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/async/AsynchronousCassandraTemplateTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/AsynchronousCassandraTemplateIntegrationTests.java
similarity index 57%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/async/AsynchronousCassandraTemplateTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/AsynchronousCassandraTemplateIntegrationTests.java
index e48a5593b..f62a95fc6 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/async/AsynchronousCassandraTemplateTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/AsynchronousCassandraTemplateIntegrationTests.java
@@ -1,24 +1,23 @@
/*
- * Copyright 2013-2014 the original author or authors
- *
+ * Copyright 2013-2016 the original author or authors
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.template.async;
+package org.springframework.data.cassandra.test.integration.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-import static org.springframework.data.cassandra.repository.support.BasicMapId.id;
+import static org.junit.Assert.*;
+import static org.junit.Assume.*;
+import static org.springframework.data.cassandra.repository.support.BasicMapId.*;
import java.util.Collection;
import java.util.Random;
@@ -26,10 +25,10 @@ import java.util.UUID;
import java.util.concurrent.CancellationException;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cassandra.core.Cancellable;
import org.springframework.cassandra.core.ConsistencyLevel;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.cassandra.core.RetryPolicy;
@@ -50,45 +49,182 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
- * Asynchronous {@link CassandraTemplate} tests.
- *
+ * Integration tests for asynchronous {@link CassandraTemplate} operations.
+ *
* @author Matthew T. Adams
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class AsynchronousCassandraTemplateTest extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class AsynchronousCassandraTemplateIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+
+ @Autowired CassandraOperations cassandraOperations;
+
+ @Before
+ public void before() {
+ deleteAllEntities();
+ }
+
+ @Test
+ public void insertAsynchronously() throws Exception {
+ insertAsynchronously(ConsistencyLevel.ONE);
+ }
+
+ @Test(expected = CassandraConnectionFailureException.class)
+ public void insertAsynchronouslyThrows() throws Exception {
+ insertAsynchronously(ConsistencyLevel.TWO);
+ }
+
+ public void insertAsynchronously(ConsistencyLevel cl) throws Exception {
+
+ Thing thing = Thing.random();
+ ThingListener listener = new ThingListener();
+
+ cassandraOperations.insertAsynchronously(thing, listener, new WriteOptions(cl, RetryPolicy.LOGGING));
+ listener.await();
+
+ if (listener.exception != null) {
+ throw listener.exception;
+ }
+
+ assertEquals(thing, listener.entities.iterator().next());
+ }
+
+ @Test(expected = CancellationException.class)
+ public void insertAsynchronouslyCancelled() throws Exception {
+ insertOrUpdateAsynchronouslyCancelled(true);
+ }
+
+ @Test(expected = CancellationException.class)
+ public void updateAsynchronouslyCancelled() throws Exception {
+ insertOrUpdateAsynchronouslyCancelled(false);
+ }
+
+ public void insertOrUpdateAsynchronouslyCancelled(boolean insert) throws Exception {
+
+ Thing thing = Thing.random();
+ ThingListener listener = new ThingListener();
+
+ Cancellable cancellable;
+
+ if (insert) {
+ cancellable = cassandraOperations.insertAsynchronously(thing, listener, null);
+ } else {
+ cancellable = cassandraOperations.updateAsynchronously(thing, listener, null);
+ }
+ cancellable.cancel();
+ listener.await();
+
+ // if listener.success is true then the
+ // async operations was faster than it could be cancelled so we cannot
+ // verify that a CancellationException was thrown.
+ assumeFalse(listener.success);
+
+ if (listener.exception != null) {
+ throw listener.exception;
+ }
+
+ fail("should've thrown CancellationException");
+ }
+
+ @Test
+ public void updateAsynchronously() throws Exception {
+ updateAsynchronously(ConsistencyLevel.ONE);
+ }
+
+ @Test(expected = CassandraConnectionFailureException.class)
+ public void updateAsynchronouslyThrows() throws Exception {
+ updateAsynchronously(ConsistencyLevel.TWO);
+ }
+
+ public void updateAsynchronously(ConsistencyLevel cl) throws Exception {
+
+ Thing thing = Thing.random();
+ cassandraOperations.insert(thing);
+ thing.number = Thing.random().number;
+
+ ThingListener listener = new ThingListener();
+ cassandraOperations.updateAsynchronously(thing, listener, new WriteOptions(cl, RetryPolicy.LOGGING));
+
+ listener.await();
+ if (listener.exception != null) {
+ throw listener.exception;
+ }
+
+ assertEquals(thing, listener.entities.iterator().next());
+ }
+
+ @Test
+ public void deleteAsynchronously() throws Exception {
+ deleteAsynchronously(ConsistencyLevel.ONE);
+ }
+
+ @Test(expected = CassandraConnectionFailureException.class)
+ public void deleteAsynchronouslyThrows() throws Exception {
+ deleteAsynchronously(ConsistencyLevel.TWO);
+ }
+
+ public void deleteAsynchronously(ConsistencyLevel cl) throws Exception {
+
+ Thing thing = Thing.random();
+
+ cassandraOperations.insert(thing);
+
+ ThingListener listener = new ThingListener();
+ cassandraOperations.deleteAsynchronously(thing, listener, new WriteOptions(cl, RetryPolicy.LOGGING));
+
+ listener.await();
+ if (listener.exception != null) {
+ throw listener.exception;
+ }
+ assertFalse(cassandraOperations.exists(Thing.class, id("stuff", thing.stuff)));
+ }
+
+ @Test(expected = CancellationException.class)
+ public void deleteAsynchronouslyCancelled() throws Exception {
+
+ Thing thing = Thing.random();
+ ThingListener listener = new ThingListener();
+ cassandraOperations.deleteAsynchronously(thing, listener, null).cancel();
+ listener.await();
+
+ // if listener.success is true then the
+ // async operations was faster than it could be cancelled so we cannot
+ // verify that a CancellationException was thrown.
+ assumeFalse(listener.success);
+
+ if (listener.exception != null) {
+ throw listener.exception;
+ }
+
+ fail("should've thrown CancellationException");
+ }
@Configuration
- public static class Config extends IntegrationTestConfig {
- }
+ public static class Config extends IntegrationTestConfig {}
@Table
public static class Thing {
+ private static final Random RNG = new Random();
+
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) public String stuff;
+ @Column public int number;
+
+ public Thing() {}
+
+ public Thing(String stuff, int number) {
+ this.stuff = stuff;
+ this.number = number;
+ }
+
public static final String uuid() {
return UUID.randomUUID().toString();
}
- static final Random RNG = new Random();
-
public static Thing random() {
return new Thing(uuid(), RNG.nextInt());
}
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- public String stuff;
-
- @Column
- public int number;
-
- public Thing() {
- }
-
- public Thing(String stuff, int number) {
- this.stuff = stuff;
- this.number = number;
- }
-
@Override
public int hashCode() {
final int prime = 31;
@@ -118,148 +254,31 @@ public class AsynchronousCassandraTemplateTest extends AbstractSpringDataEmbedde
}
}
- public static class ThingWriteListener extends TestListener implements WriteListener {
+ public static class ThingListener extends TestListener implements WriteListener, DeletionListener {
- public Exception exception;
- public Collection entities;
+ public volatile Exception exception;
+ public volatile Collection entities;
+ public volatile boolean success;
@Override
public void onWriteComplete(Collection entities) {
this.entities = entities;
+ this.success = true;
countDown();
}
- @Override
- public void onException(Exception x) {
- this.exception = x;
- countDown();
- }
- }
-
- public static class ThingDeletionListener extends TestListener implements DeletionListener {
-
- public Exception exception;
- public Collection entities;
-
@Override
public void onDeletionComplete(Collection entities) {
this.entities = entities;
+ this.success = true;
countDown();
}
@Override
public void onException(Exception x) {
this.exception = x;
+ this.success = false;
countDown();
}
}
-
- @Autowired
- CassandraOperations t;
-
- @Before
- public void before() {
- deleteAllEntities();
- }
-
- public void testInsertAsynchronously(ConsistencyLevel cl) throws Exception {
- Thing thing = Thing.random();
- ThingWriteListener listener = new ThingWriteListener();
- t.insertAsynchronously(thing, listener, new WriteOptions(cl, RetryPolicy.LOGGING));
- listener.await();
- if (listener.exception != null) {
- throw listener.exception;
- }
- assertEquals(thing, listener.entities.iterator().next());
- }
-
- @Test
- public void testInsertAsynchronously() throws Exception {
- testInsertAsynchronously(ConsistencyLevel.ONE);
- }
-
- @Test(expected = CassandraConnectionFailureException.class)
- public void testInsertAsynchronouslyThrows() throws Exception {
- testInsertAsynchronously(ConsistencyLevel.TWO);
- }
-
- public void testInsertOrUpdateAsynchronouslyCancelled(boolean insert) throws Exception {
- Thing thing = Thing.random();
- ThingWriteListener listener = new ThingWriteListener();
- (insert ? t.insertAsynchronously(thing, listener, null) : t.updateAsynchronously(thing, listener, null)).cancel();
- listener.await();
- if (listener.exception != null) {
- throw listener.exception;
- }
- fail("should've thrown CancellationException");
- }
-
- @Test(expected = CancellationException.class)
- public void testInsertAsynchronouslyCancelled() throws Exception {
- testInsertOrUpdateAsynchronouslyCancelled(true);
- }
-
- @Test(expected = CancellationException.class)
- @Ignore
- public void testUpdateAsynchronouslyCancelled() throws Exception {
- testInsertOrUpdateAsynchronouslyCancelled(false);
- }
-
- public void testUpdateAsynchronously(ConsistencyLevel cl) throws Exception {
- Thing thing = Thing.random();
- t.insert(thing);
- thing.number = Thing.random().number;
- ThingWriteListener listener = new ThingWriteListener();
- t.updateAsynchronously(thing, listener, new WriteOptions(cl, RetryPolicy.LOGGING));
- listener.await();
- if (listener.exception != null) {
- throw listener.exception;
- }
- assertEquals(thing, listener.entities.iterator().next());
- }
-
- @Test
- public void testUpdateAsynchronously() throws Exception {
- testUpdateAsynchronously(ConsistencyLevel.ONE);
- }
-
- @Test(expected = CassandraConnectionFailureException.class)
- public void testUpdateAsynchronouslyThrows() throws Exception {
- testUpdateAsynchronously(ConsistencyLevel.TWO);
- }
-
- public void testDeleteAsynchronously(ConsistencyLevel cl) throws Exception {
- Thing thing = Thing.random();
- t.insert(thing);
- ThingDeletionListener listener = new ThingDeletionListener();
- t.deleteAsynchronously(thing, listener, new WriteOptions(cl, RetryPolicy.LOGGING));
- listener.await();
- if (listener.exception != null) {
- throw listener.exception;
- }
- assertFalse(t.exists(Thing.class, id("stuff", thing.stuff)));
- }
-
- @Test
- public void testDeleteAsynchronously() throws Exception {
- testDeleteAsynchronously(ConsistencyLevel.ONE);
- }
-
- @Test(expected = CassandraConnectionFailureException.class)
- public void testDeleteAsynchronouslyThrows() throws Exception {
- testDeleteAsynchronously(ConsistencyLevel.TWO);
- }
-
- @Test(expected = CancellationException.class)
- public void testDeleteAsynchronouslyCancelled() throws Exception {
- Thing thing = Thing.random();
- ThingDeletionListener listener = new ThingDeletionListener();
- t.deleteAsynchronously(thing, listener, null).cancel();
- listener.await();
- if (listener.exception != null) {
- throw listener.exception;
- }
- fail("should've thrown CancellationException");
- }
-
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/CassandraAdminTemplateTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/CassandraAdminTemplateIntegrationTests.java
similarity index 89%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/CassandraAdminTemplateTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/CassandraAdminTemplateIntegrationTests.java
index 0ef900b54..6e9564b5a 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/CassandraAdminTemplateTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/CassandraAdminTemplateIntegrationTests.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2013-2016 the original author or authors
+ * Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.template;
+package org.springframework.data.cassandra.test.integration.core;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
@@ -27,7 +27,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cassandra.core.cql.CqlIdentifier;
import org.springframework.cassandra.core.keyspace.DropTableSpecification;
import org.springframework.context.annotation.Configuration;
-import org.springframework.data.cassandra.convert.CassandraConverter;
import org.springframework.data.cassandra.core.CassandraAdminTemplate;
import org.springframework.data.cassandra.test.integration.simpletons.Book;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
@@ -41,13 +40,13 @@ import com.datastax.driver.core.Session;
import com.datastax.driver.core.TableMetadata;
/**
- * Test for CassandraAdminTemplate
+ * Integration tests for {@link CassandraAdminTemplate}.
*
* @author Mark Paluch
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class CassandraAdminTemplateTest extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class CassandraAdminTemplateIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@Configuration
public static class Config extends IntegrationTestConfig {
@@ -75,11 +74,10 @@ public class CassandraAdminTemplateTest extends AbstractSpringDataEmbeddedCassan
}
private Session getSession() {
- return template.getSession();
+ return cassandraAdminTemplate.getSession();
}
/**
- *
* @see DATACASS-173
*/
@Test
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/CassandraDataOperationsTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/CassandraOperationsIntegrationTests.java
similarity index 96%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/CassandraDataOperationsTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/CassandraOperationsIntegrationTests.java
index ba08a308f..4e38000c5 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/template/CassandraDataOperationsTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/core/CassandraOperationsIntegrationTests.java
@@ -1,23 +1,21 @@
/*
- * Copyright 2013-2016 the original author or authors
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.template;
+package org.springframework.data.cassandra.test.integration.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Date;
@@ -28,11 +26,13 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cassandra.core.ConsistencyLevel;
import org.springframework.cassandra.core.QueryOptions;
import org.springframework.cassandra.core.RetryPolicy;
import org.springframework.cassandra.core.WriteOptions;
import org.springframework.context.annotation.Configuration;
+import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.test.integration.simpletons.Book;
import org.springframework.data.cassandra.test.integration.simpletons.BookCondition;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
@@ -44,14 +44,14 @@ import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
/**
- * Unit Tests for CqlTemplate
- *
+ * Integration tests for {@link CassandraOperations}.
+ *
* @author David Webb
* @author Mark Paluch
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class CassandraDataOperationsTest extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class CassandraOperationsIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@Configuration
public static class Config extends IntegrationTestConfig {
@@ -62,6 +62,8 @@ public class CassandraDataOperationsTest extends AbstractSpringDataEmbeddedCassa
}
}
+ @Autowired CassandraOperations template;
+
@Before
public void before() {
deleteAllEntities();
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudIntegrationTests.java
similarity index 63%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudIntegrationTests.java
index 57b4dfbf4..74d1f42e4 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudIntegrationTests.java
@@ -1,6 +1,21 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Date;
@@ -27,18 +42,20 @@ import com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
+/**
+ * @author Mark Paluch
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class CompositeKeyCrudTest extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class CompositeKeyCrudIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@Configuration
@EnableCassandraRepositories(basePackageClasses = ImplicitRepository.class)
public static class Config extends IntegrationTestConfig {}
- @Autowired
- CassandraTemplate t;
+ @Autowired private CassandraTemplate template1;
- CorrelationEntity c1, c2;
+ private CorrelationEntity correlationEntity1, correlationEntity2;
@Before
public void setUp() throws Throwable {
@@ -50,31 +67,31 @@ public class CompositeKeyCrudTest extends AbstractSpringDataEmbeddedCassandraInt
map2.put("v", "1");
map2.put("labels", "4,5,6");
- c1 = new CorrelationEntity("a", "b", "c", new Date(1), "d", map1);
- c2 = new CorrelationEntity("a", "b", "c", new Date(2), "e", map2);
+ correlationEntity1 = new CorrelationEntity("a", "b", "c", new Date(1), "d", map1);
+ correlationEntity2 = new CorrelationEntity("a", "b", "c", new Date(2), "e", map2);
}
@Test
public void test() {
- t.insert(c1);
- t.insert(c2);
+ template1.insert(correlationEntity1);
+ template1.insert(correlationEntity2);
Select select = QueryBuilder.select().from("identity_correlations");
select.where(QueryBuilder.eq("type", "a")).and(QueryBuilder.eq("value", "b"));
select.setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
select.setConsistencyLevel(ConsistencyLevel.ONE);
- List correlationEntities = t.select(select, CorrelationEntity.class);
+ List correlationEntities = template1.select(select, CorrelationEntity.class);
assertEquals(2, correlationEntities.size());
QueryOptions qo = new QueryOptions();
qo.setConsistencyLevel(org.springframework.cassandra.core.ConsistencyLevel.ONE);
ArrayList entities = new ArrayList();
- entities.add(c1);
- entities.add(c2);
- t.delete(entities, qo);
+ entities.add(correlationEntity1);
+ entities.add(correlationEntity2);
+ template1.delete(entities, qo);
- correlationEntities = t.select(select, CorrelationEntity.class);
+ correlationEntities = template1.select(select, CorrelationEntity.class);
assertEquals(0, correlationEntities.size());
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/Explicit.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/Explicit.java
index 4f7b98502..e262dcfe6 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/Explicit.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/Explicit.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import java.util.UUID;
@@ -6,17 +21,18 @@ import org.springframework.data.cassandra.mapping.Column;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
+/**
+ * @author Matthew T. Adams
+ */
@Table(forceQuote = true, value = Explicit.TABLE_NAME)
public class Explicit {
public static final String TABLE_NAME = "JavaExplicitTable";
public static final String STRING_VALUE_COLUMN_NAME = "JavaExplicitStringValue";
- @PrimaryKey
- ExplicitKey primaryKey;
+ @PrimaryKey ExplicitKey primaryKey;
- @Column(value = STRING_VALUE_COLUMN_NAME, forceQuote = true)
- String stringValue = UUID.randomUUID().toString();
+ @Column(value = STRING_VALUE_COLUMN_NAME, forceQuote = true) String stringValue = UUID.randomUUID().toString();
@SuppressWarnings("unused")
private Explicit() {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ExplicitKey.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ExplicitKey.java
index 74e522cc7..df317f60a 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ExplicitKey.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ExplicitKey.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import java.io.Serializable;
@@ -6,6 +21,9 @@ import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.cassandra.mapping.PrimaryKeyClass;
import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
+/**
+ * @author Matthew T. Adams
+ */
@PrimaryKeyClass
public class ExplicitKey implements Serializable {
@@ -14,11 +32,10 @@ public class ExplicitKey implements Serializable {
private static final long serialVersionUID = 4459456944472099332L;
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED, forceQuote = true, name = EXPLICIT_KEY_ZERO)
- String keyZero;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED, forceQuote = true,
+ name = EXPLICIT_KEY_ZERO) String keyZero;
- @PrimaryKeyColumn(ordinal = 1, forceQuote = true, name = EXPLICIT_KEY_ONE)
- String keyOne;
+ @PrimaryKeyColumn(ordinal = 1, forceQuote = true, name = EXPLICIT_KEY_ONE) String keyOne;
public ExplicitKey(String keyZero, String keyOne) {
this.keyZero = keyZero;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ExplicitRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ExplicitRepository.java
index 3d65630ff..60811f52f 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ExplicitRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ExplicitRepository.java
@@ -1,5 +1,23 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;
+/**
+ * @author Matthew T. Adams
+ */
public interface ExplicitRepository extends TypedIdCassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator.java
index 82aa8c44d..a38644ff1 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import org.junit.Before;
@@ -8,27 +23,25 @@ import org.springframework.data.cassandra.core.CassandraTemplate;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * @author Matthew T. Adams
+ */
@RunWith(SpringJUnit4ClassRunner.class)
-public abstract class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator extends
- AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public abstract class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator
+ extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
- ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests tests = new ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests();
+ ForceQuotedCompositePrimaryKeyRepositoryTests tests = new ForceQuotedCompositePrimaryKeyRepositoryTests();
- @Autowired
- ImplicitRepository i;
-
- @Autowired
- ExplicitRepository e;
-
- @Autowired
- CassandraTemplate t;
+ @Autowired ImplicitRepository implicitRepository;
+ @Autowired ExplicitRepository explicitRepository;
+ @Autowired CassandraTemplate cassandraTemplate;
@Before
public void before() {
- tests.i = i;
- tests.e = e;
- tests.t = t;
+ tests.implicitRepository = implicitRepository;
+ tests.explicitRepository = explicitRepository;
+ tests.cassandraTemplate = cassandraTemplate;
tests.before();
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryJavaConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryJavaConfigIntegrationTests.java
index cad059156..2a1b8d9ad 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryJavaConfigIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryJavaConfigIntegrationTests.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import org.junit.Test;
@@ -6,9 +21,12 @@ import org.springframework.data.cassandra.repository.config.EnableCassandraRepos
import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig;
import org.springframework.test.context.ContextConfiguration;
+/**
+ * @author Matthew T. Adams
+ */
@ContextConfiguration
-public class ForceQuotedCompositePrimaryKeyRepositoryJavaConfigIntegrationTests extends
- ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator {
+public class ForceQuotedCompositePrimaryKeyRepositoryJavaConfigIntegrationTests
+ extends ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator {
@Configuration
@EnableCassandraRepositories(basePackageClasses = ImplicitRepository.class)
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryTests.java
similarity index 51%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryTests.java
index 771bdc9cb..f4e07c15d 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryTests.java
@@ -1,29 +1,44 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
import java.util.UUID;
import org.springframework.data.cassandra.core.CassandraTemplate;
-public class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests {
+/**
+ * @author Matthew T. Adams
+ */
+public class ForceQuotedCompositePrimaryKeyRepositoryTests {
- ImplicitRepository i;
- ExplicitRepository e;
- CassandraTemplate t;
+ ImplicitRepository implicitRepository;
+ ExplicitRepository explicitRepository;
+ CassandraTemplate cassandraTemplate;
public void before() {
- t.deleteAll(Implicit.class);
+ cassandraTemplate.deleteAll(Implicit.class);
}
public String query(String columnName, String tableName, String keyZeroColumnName, String keyZero,
String keyOneColumnName, String keyOne) {
- return t.queryForObject(String.format("select %s from %s where %s = '%s' and %s = '%s'", columnName, tableName,
- keyZeroColumnName, keyZero, keyOneColumnName, keyOne), String.class);
+ return cassandraTemplate.queryForObject(String.format("select %s from %s where %s = '%s' and %s = '%s'", columnName,
+ tableName, keyZeroColumnName, keyZero, keyOneColumnName, keyOne), String.class);
}
public void testImplicit() {
@@ -32,11 +47,11 @@ public class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests {
Implicit entity = new Implicit(key);
// insert
- Implicit s = i.save(entity);
+ Implicit s = implicitRepository.save(entity);
assertSame(s, entity);
// select
- Implicit f = i.findOne(key);
+ Implicit f = implicitRepository.findOne(key);
assertNotSame(f, entity);
String stringValue = query("stringvalue", "\"Implicit\"", "\"keyZero\"", f.getPrimaryKey().getKeyZero(),
"\"keyOne\"", f.getPrimaryKey().getKeyOne());
@@ -44,15 +59,15 @@ public class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests {
// update
f.setStringValue(f.getStringValue() + "X");
- Implicit u = i.save(f);
+ Implicit u = implicitRepository.save(f);
assertSame(u, f);
- f = i.findOne(u.getPrimaryKey());
+ f = implicitRepository.findOne(u.getPrimaryKey());
assertNotSame(f, u);
assertEquals(u.getStringValue(), f.getStringValue());
// delete
- i.delete(key);
- assertNull(i.findOne(key));
+ implicitRepository.delete(key);
+ assertNull(implicitRepository.findOne(key));
}
public void testExplicit(String tableName, String stringValueColumnName, String keyZeroColumnName,
@@ -61,11 +76,11 @@ public class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests {
Explicit entity = new Explicit(key);
// insert
- Explicit s = e.save(entity);
+ Explicit s = explicitRepository.save(entity);
assertSame(s, entity);
// select
- Explicit f = e.findOne(key);
+ Explicit f = explicitRepository.findOne(key);
assertNotSame(f, entity);
String stringValue = query(stringValueColumnName, tableName, keyZeroColumnName, f.getPrimaryKey().getKeyZero(),
keyOneColumnName, f.getPrimaryKey().getKeyOne());
@@ -73,14 +88,14 @@ public class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests {
// update
f.setStringValue(f.getStringValue() + "X");
- Explicit u = e.save(f);
+ Explicit u = explicitRepository.save(f);
assertSame(u, f);
- f = e.findOne(u.getPrimaryKey());
+ f = explicitRepository.findOne(u.getPrimaryKey());
assertNotSame(f, u);
assertEquals(u.getStringValue(), f.getStringValue());
// delete
- e.delete(key);
- assertNull(e.findOne(key));
+ explicitRepository.delete(key);
+ assertNull(explicitRepository.findOne(key));
}
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryXmlConfigIntegrationTests.java
index 935cf605f..19a93b768 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryXmlConfigIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ForceQuotedCompositePrimaryKeyRepositoryXmlConfigIntegrationTests.java
@@ -1,11 +1,29 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
+/**
+ * @author Matthew T. Adams
+ */
@ContextConfiguration
-public class ForceQuotedCompositePrimaryKeyRepositoryXmlConfigIntegrationTests extends
- ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator {
+public class ForceQuotedCompositePrimaryKeyRepositoryXmlConfigIntegrationTests
+ extends ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator {
@Test
public void testExplicit() {
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/Implicit.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/Implicit.java
index ca4182322..78d0d6b2e 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/Implicit.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/Implicit.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import java.util.UUID;
@@ -5,11 +20,13 @@ import java.util.UUID;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
+/**
+ * @author Matthew T. Adams
+ */
@Table(forceQuote = true)
public class Implicit {
- @PrimaryKey
- ImplicitKey primaryKey;
+ @PrimaryKey ImplicitKey primaryKey;
String stringValue = UUID.randomUUID().toString();
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ImplicitKey.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ImplicitKey.java
index 5494a3560..71a1ba905 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ImplicitKey.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ImplicitKey.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import java.io.Serializable;
@@ -6,16 +21,17 @@ import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.cassandra.mapping.PrimaryKeyClass;
import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
+/**
+ * @author Matthew T. Adams
+ */
@PrimaryKeyClass
public class ImplicitKey implements Serializable {
private static final long serialVersionUID = 4459456944472099332L;
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED, forceQuote = true)
- String keyZero;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED, forceQuote = true) String keyZero;
- @PrimaryKeyColumn(ordinal = 1, forceQuote = true)
- String keyOne;
+ @PrimaryKeyColumn(ordinal = 1, forceQuote = true) String keyOne;
public ImplicitKey(String keyZero, String keyOne) {
this.keyZero = keyZero;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ImplicitRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ImplicitRepository.java
index e7077ddda..bf2ace3ac 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ImplicitRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/ImplicitRepository.java
@@ -1,5 +1,23 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;
+/**
+ * @author Matthew T. Adams
+ */
public interface ImplicitRepository extends TypedIdCassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/entity/CorrelationEntity.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/entity/CorrelationEntity.java
index 6835b1dba..c9b2255b8 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/entity/CorrelationEntity.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/entity/CorrelationEntity.java
@@ -1,12 +1,34 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey.entity;
-import org.springframework.cassandra.core.PrimaryKeyType;
-import org.springframework.data.cassandra.mapping.*;
-
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
+import org.springframework.cassandra.core.PrimaryKeyType;
+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;
+
+/**
+ * @author Matthew T. Adams
+ */
@Table(value = "identity_correlations")
public class CorrelationEntity {
@@ -15,20 +37,17 @@ public class CorrelationEntity {
private static final long serialVersionUID = 1027559675696864950L;
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private String type;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String type;
- @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED)
- private String value;
+ @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) private String value;
- @PrimaryKeyColumn(name = "correlated_type", ordinal = 2, type = PrimaryKeyType.CLUSTERED)
- private String correlatedType;
+ @PrimaryKeyColumn(name = "correlated_type", ordinal = 2,
+ type = PrimaryKeyType.CLUSTERED) private String correlatedType;
- @PrimaryKeyColumn(ordinal = 3, type = PrimaryKeyType.CLUSTERED)
- private Date ts;
+ @PrimaryKeyColumn(ordinal = 3, type = PrimaryKeyType.CLUSTERED) private Date ts;
- @PrimaryKeyColumn(name = "correlated_value", ordinal = 4, type = PrimaryKeyType.CLUSTERED)
- private String correlatedValue;
+ @PrimaryKeyColumn(name = "correlated_value", ordinal = 4,
+ type = PrimaryKeyType.CLUSTERED) private String correlatedValue;
public IdentityEntity() {}
@@ -132,11 +151,9 @@ public class CorrelationEntity {
}
}
- @PrimaryKey(forceQuote = true)
- private IdentityEntity identityEntity;
+ @PrimaryKey(forceQuote = true) private IdentityEntity identityEntity;
- @Column
- private Map extra;
+ @Column private Map extra;
public CorrelationEntity() {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/Explicit.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/Explicit.java
index de2337a6b..cabd11351 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/Explicit.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/Explicit.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.config;
import java.util.UUID;
@@ -5,13 +20,15 @@ import java.util.UUID;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
+/**
+ * @author Matthew T. Adams
+ */
@Table(forceQuote = true, value = Explicit.TABLE_NAME)
public class Explicit {
public static final String TABLE_NAME = "Xx";
- @PrimaryKey
- String primaryKey;
+ @PrimaryKey String primaryKey;
String stringValue = UUID.randomUUID().toString();
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitProperties.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitProperties.java
index 632739b1e..f1cc7c69a 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitProperties.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitProperties.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.data.cassandra.test.integration.forcequote.config;
import java.util.UUID;
@@ -6,17 +22,18 @@ import org.springframework.data.cassandra.mapping.Column;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
+/**
+ * @author Matthew T. Adams
+ */
@Table
public class ExplicitProperties {
public static final String EXPLICIT_PRIMARY_KEY = "ThePrimaryKey";
public static final String EXPLICIT_STRING_VALUE = "TheStringValue";
- @PrimaryKey(forceQuote = true, value = EXPLICIT_PRIMARY_KEY)
- String primaryKey;
+ @PrimaryKey(forceQuote = true, value = EXPLICIT_PRIMARY_KEY) String primaryKey;
- @Column(forceQuote = true, value = EXPLICIT_STRING_VALUE)
- String stringValue = UUID.randomUUID().toString();
+ @Column(forceQuote = true, value = EXPLICIT_STRING_VALUE) String stringValue = UUID.randomUUID().toString();
public ExplicitProperties() {
this(UUID.randomUUID().toString());
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitPropertiesRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitPropertiesRepository.java
index f676978f8..327083f9b 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitPropertiesRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitPropertiesRepository.java
@@ -1,5 +1,23 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.config;
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;
+/**
+ * @author Matthew T. Adams
+ */
public interface ExplicitPropertiesRepository extends TypedIdCassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitRepository.java
index 907721dbc..e31b8b3b1 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ExplicitRepository.java
@@ -1,5 +1,23 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.config;
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;
+/**
+ * @author Matthew T. Adams
+ */
public interface ExplicitRepository extends TypedIdCassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryIntegrationTests.java
index f40e2818c..cf767727c 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryIntegrationTests.java
@@ -1,99 +1,78 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.config;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import org.junit.Before;
+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.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.data.cassandra.core.CassandraTemplate;
+/**
+ * @author Matthew T. Adams
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+public abstract class ForceQuotedRepositoryIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
-public class ForceQuotedRepositoryIntegrationTests {
+ @Autowired CassandraOperations template;
+ @Autowired ImplicitRepository implicitRepository;
+ @Autowired ImplicitPropertiesRepository implicitPropertiesRepository;
+ @Autowired ExplicitRepository explicitRepository;
+ @Autowired ExplicitPropertiesRepository explicitPropertiesRepository;
- ImplicitRepository i;
- ImplicitPropertiesRepository ip;
- ExplicitRepository e;
- ExplicitPropertiesRepository ep;
- CassandraTemplate t;
+ ForceQuotedRepositoryTests tests;
+ @Before
public void before() {
- t.deleteAll(Implicit.class);
- }
-
- public String query(String columnName, String tableName, String keyColumnName, String key) {
- return t.queryForObject(
- String.format("select %s from %s where %s = '%s'", columnName, tableName, keyColumnName, key), String.class);
+ tests = new ForceQuotedRepositoryTests();
+ tests.implicitRepository = implicitRepository;
+ tests.implicitPropertiesRepository = implicitPropertiesRepository;
+ tests.explicitRepository = explicitRepository;
+ tests.explicitPropertiesRepository = explicitPropertiesRepository;
+ tests.cassandraTemplate = template;
+
+ tests.before();
}
+ @Test
public void testImplicit() {
- Implicit entity = new Implicit();
- String key = entity.getPrimaryKey();
-
- Implicit s = i.save(entity);
- assertSame(s, entity);
-
- Implicit f = i.findOne(key);
- assertNotSame(f, entity);
-
- String stringValue = query("stringvalue", "\"Implicit\"", "primarykey", f.getPrimaryKey());
- assertEquals(f.getStringValue(), stringValue);
-
- i.delete(key);
-
- assertNull(i.findOne(key));
+ tests.testImplicit();
}
+ /**
+ * Not a @Test -- used by subclasses!
+ */
public void testExplicit(String tableName) {
- Explicit entity = new Explicit();
- String key = entity.getPrimaryKey();
-
- Explicit s = e.save(entity);
- assertSame(s, entity);
-
- Explicit f = e.findOne(key);
- assertNotSame(f, entity);
-
- String stringValue = query("stringvalue", String.format("\"%s\"", tableName), "primarykey", f.getPrimaryKey());
- assertEquals(f.getStringValue(), stringValue);
-
- e.delete(key);
-
- assertNull(e.findOne(key));
+ tests.testExplicit(tableName);
}
+ @Test
public void testImplicitProperties() {
- ImplicitProperties entity = new ImplicitProperties();
- String key = entity.getPrimaryKey();
-
- ImplicitProperties s = ip.save(entity);
- assertSame(s, entity);
-
- ImplicitProperties f = ip.findOne(key);
- assertNotSame(f, entity);
-
- String stringValue = query("\"stringValue\"", "implicitproperties", "\"primaryKey\"", f.getPrimaryKey());
- assertEquals(f.getStringValue(), stringValue);
-
- ip.delete(key);
-
- assertNull(ip.findOne(key));
+ tests.testImplicitProperties();
}
+ /**
+ * Not a @Test -- used by subclasses!
+ *
+ * @see ForceQuotedRepositoryJavaConfigIntegrationTests#testExplicitPropertiesWithJavaValues()
+ * @see ForceQuotedRepositoryXmlConfigIntegrationTests#testExplicitPropertiesWithXmlValues()
+ */
public void testExplicitProperties(String stringValueColumnName, String primaryKeyColumnName) {
- ExplicitProperties entity = new ExplicitProperties();
- String key = entity.getPrimaryKey();
-
- ExplicitProperties s = ep.save(entity);
- assertSame(s, entity);
-
- ExplicitProperties f = ep.findOne(key);
- assertNotSame(f, entity);
-
- String stringValue = query(String.format("\"%s\"", stringValueColumnName), "explicitproperties",
- String.format("\"%s\"", primaryKeyColumnName), f.getPrimaryKey());
- assertEquals(f.getStringValue(), stringValue);
-
- ip.delete(key);
-
- assertNull(ip.findOne(key));
+ tests.testExplicitProperties(stringValueColumnName, primaryKeyColumnName);
}
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryIntegrationTestsDelegator.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryIntegrationTestsDelegator.java
deleted file mode 100644
index 4391c6a24..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryIntegrationTestsDelegator.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.springframework.data.cassandra.test.integration.forcequote.config;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.cassandra.core.CassandraTemplate;
-import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-public abstract class ForceQuotedRepositoryIntegrationTestsDelegator extends
- AbstractSpringDataEmbeddedCassandraIntegrationTest {
-
- @Autowired
- ImplicitRepository i;
-
- @Autowired
- ImplicitPropertiesRepository ip;
-
- @Autowired
- ExplicitRepository e;
-
- @Autowired
- ExplicitPropertiesRepository ep;
-
- @Autowired
- CassandraTemplate t;
-
- ForceQuotedRepositoryIntegrationTests tests;
-
- @Before
- public void before() {
- tests = new ForceQuotedRepositoryIntegrationTests();
- tests.i = i;
- tests.ip = ip;
- tests.e = e;
- tests.ep = ep;
- tests.t = t;
-
- tests.before();
- }
-
- @Test
- public void testImplicit() {
- tests.testImplicit();
- }
-
- /**
- * Not a @Test -- used by subclasses!
- */
- public void testExplicit(String tableName) {
- tests.testExplicit(tableName);
- }
-
- @Test
- public void testImplicitProperties() {
- tests.testImplicitProperties();
- }
-
- /**
- * Not a @Test -- used by subclasses!
- *
- * @see ForceQuotedRepositoryJavaConfigIntegrationTests#testExplicitPropertiesWithJavaValues()
- * @see ForceQuotedRepositoryXmlConfigIntegrationTests#testExplicitPropertiesWithXmlValues()
- */
- public void testExplicitProperties(String stringValueColumnName, String primaryKeyColumnName) {
- tests.testExplicitProperties(stringValueColumnName, primaryKeyColumnName);
- }
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryJavaConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryJavaConfigIntegrationTests.java
index d120941bf..1e6024461 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryJavaConfigIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryJavaConfigIntegrationTests.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.config;
import org.junit.Test;
@@ -6,11 +21,14 @@ import org.springframework.data.cassandra.repository.config.EnableCassandraRepos
import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig;
import org.springframework.test.context.ContextConfiguration;
+/**
+ * @author Matthew T. Adams
+ */
@ContextConfiguration
-public class ForceQuotedRepositoryJavaConfigIntegrationTests extends ForceQuotedRepositoryIntegrationTestsDelegator {
+public class ForceQuotedRepositoryJavaConfigIntegrationTests extends ForceQuotedRepositoryIntegrationTests {
@Configuration
- @EnableCassandraRepositories(basePackageClasses = ForceQuotedRepositoryIntegrationTests.class)
+ @EnableCassandraRepositories(basePackageClasses = ForceQuotedRepositoryTests.class)
public static class Config extends IntegrationTestConfig {}
@Test
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryTests.java
new file mode 100644
index 000000000..87e75bf9e
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryTests.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.forcequote.config;
+
+import static org.junit.Assert.*;
+
+import org.springframework.data.cassandra.core.CassandraOperations;
+
+/**
+ * Tests to be executed using Java/XML configuration.
+ *
+ * @author Matthew T. Adams
+ */
+public class ForceQuotedRepositoryTests {
+
+ ImplicitRepository implicitRepository;
+ ImplicitPropertiesRepository implicitPropertiesRepository;
+ ExplicitRepository explicitRepository;
+ ExplicitPropertiesRepository explicitPropertiesRepository;
+ CassandraOperations cassandraTemplate;
+
+ public void before() {
+ cassandraTemplate.deleteAll(Implicit.class);
+ }
+
+ public String query(String columnName, String tableName, String keyColumnName, String key) {
+ return cassandraTemplate.queryForObject(
+ String.format("select %s from %s where %s = '%s'", columnName, tableName, keyColumnName, key), String.class);
+ }
+
+ public void testImplicit() {
+ Implicit entity = new Implicit();
+ String key = entity.getPrimaryKey();
+
+ Implicit s = implicitRepository.save(entity);
+ assertSame(s, entity);
+
+ Implicit f = implicitRepository.findOne(key);
+ assertNotSame(f, entity);
+
+ String stringValue = query("stringvalue", "\"Implicit\"", "primarykey", f.getPrimaryKey());
+ assertEquals(f.getStringValue(), stringValue);
+
+ implicitRepository.delete(key);
+
+ assertNull(implicitRepository.findOne(key));
+ }
+
+ public void testExplicit(String tableName) {
+ Explicit entity = new Explicit();
+ String key = entity.getPrimaryKey();
+
+ Explicit s = explicitRepository.save(entity);
+ assertSame(s, entity);
+
+ Explicit f = explicitRepository.findOne(key);
+ assertNotSame(f, entity);
+
+ String stringValue = query("stringvalue", String.format("\"%s\"", tableName), "primarykey", f.getPrimaryKey());
+ assertEquals(f.getStringValue(), stringValue);
+
+ explicitRepository.delete(key);
+
+ assertNull(explicitRepository.findOne(key));
+ }
+
+ public void testImplicitProperties() {
+ ImplicitProperties entity = new ImplicitProperties();
+ String key = entity.getPrimaryKey();
+
+ ImplicitProperties s = implicitPropertiesRepository.save(entity);
+ assertSame(s, entity);
+
+ ImplicitProperties f = implicitPropertiesRepository.findOne(key);
+ assertNotSame(f, entity);
+
+ String stringValue = query("\"stringValue\"", "implicitproperties", "\"primaryKey\"", f.getPrimaryKey());
+ assertEquals(f.getStringValue(), stringValue);
+
+ implicitPropertiesRepository.delete(key);
+
+ assertNull(implicitPropertiesRepository.findOne(key));
+ }
+
+ public void testExplicitProperties(String stringValueColumnName, String primaryKeyColumnName) {
+ ExplicitProperties entity = new ExplicitProperties();
+ String key = entity.getPrimaryKey();
+
+ ExplicitProperties s = explicitPropertiesRepository.save(entity);
+ assertSame(s, entity);
+
+ ExplicitProperties f = explicitPropertiesRepository.findOne(key);
+ assertNotSame(f, entity);
+
+ String stringValue = query(String.format("\"%s\"", stringValueColumnName), "explicitproperties",
+ String.format("\"%s\"", primaryKeyColumnName), f.getPrimaryKey());
+ assertEquals(f.getStringValue(), stringValue);
+
+ implicitPropertiesRepository.delete(key);
+
+ assertNull(implicitPropertiesRepository.findOne(key));
+ }
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryXmlConfigIntegrationTests.java
index 28e988a93..46d32f0ba 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryXmlConfigIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryXmlConfigIntegrationTests.java
@@ -1,13 +1,31 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.config;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
+/**
+ * @author Matthew T. Adams
+ */
@ContextConfiguration
-public class ForceQuotedRepositoryXmlConfigIntegrationTests extends ForceQuotedRepositoryIntegrationTestsDelegator {
+public class ForceQuotedRepositoryXmlConfigIntegrationTests extends ForceQuotedRepositoryIntegrationTests {
// these values must match the values in
- // src/test/resources/org/springframework/data/cassandra/test/integration/forcequote/config/ForceQuotedRepositoryXmlConfigIntegrationTests-context.xml
+ // ForceQuotedRepositoryXmlConfigIntegrationTests-context.xml
@Test
public void testExplicit() {
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/Implicit.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/Implicit.java
index 3f6136fae..2e2c58c60 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/Implicit.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/Implicit.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.data.cassandra.test.integration.forcequote.config;
import java.util.UUID;
@@ -5,11 +21,13 @@ import java.util.UUID;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
+/**
+ * @author Matthew T. Adams
+ */
@Table(forceQuote = true)
public class Implicit {
- @PrimaryKey
- String primaryKey;
+ @PrimaryKey String primaryKey;
String stringValue = UUID.randomUUID().toString();
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitProperties.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitProperties.java
index aacef094c..04c0454a9 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitProperties.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitProperties.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.data.cassandra.test.integration.forcequote.config;
import java.util.UUID;
@@ -6,14 +22,15 @@ import org.springframework.data.cassandra.mapping.Column;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
+/**
+ * @author Matthew T. Adams
+ */
@Table
public class ImplicitProperties {
- @PrimaryKey(forceQuote = true)
- String primaryKey;
+ @PrimaryKey(forceQuote = true) String primaryKey;
- @Column(forceQuote = true)
- String stringValue = UUID.randomUUID().toString();
+ @Column(forceQuote = true) String stringValue = UUID.randomUUID().toString();
public ImplicitProperties() {
this(UUID.randomUUID().toString());
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitPropertiesRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitPropertiesRepository.java
index 46c7f54d7..a6e3f99f6 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitPropertiesRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitPropertiesRepository.java
@@ -1,5 +1,23 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.config;
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;
+/**
+ * @author Matthew T. Adams
+ */
public interface ImplicitPropertiesRepository extends TypedIdCassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitRepository.java
index e9c3d9829..6f8dfd8d0 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/config/ImplicitRepository.java
@@ -1,5 +1,23 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.forcequote.config;
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;
+/**
+ * @author Matthew T. Adams
+ */
public interface ImplicitRepository extends TypedIdCassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTests.java
similarity index 69%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTests.java
index db222d64f..2ac30418b 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTests.java
@@ -1,11 +1,22 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.mapping.mapid.proxy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.springframework.data.cassandra.repository.support.MapIdFactory.id;
+import static org.junit.Assert.*;
+import static org.springframework.data.cassandra.repository.support.MapIdFactory.*;
import org.junit.Before;
import org.junit.Test;
@@ -23,10 +34,15 @@ import org.springframework.data.cassandra.test.integration.support.IntegrationTe
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * Integration tests for {@link org.springframework.data.cassandra.core.CassandraTemplate} using {@link MapId}.
+ *
+ * @author Matthew T. Adams
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class CassandraTemplateMapIdProxyDelegateIntegrationTest extends
- AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class CassandraTemplateMapIdProxyDelegateIntegrationTests
+ extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@Configuration
public static class Config extends IntegrationTestConfig {
@@ -37,12 +53,11 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTest extends
}
}
- @Autowired
- CassandraOperations t;
+ @Autowired CassandraOperations template;
@Before
public void before() {
- assertNotNull(t);
+ assertNotNull(template);
}
@Test
@@ -51,28 +66,28 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTest extends
// insert
SinglePkc inserted = new SinglePkc(uuid());
inserted.setValue(uuid());
- SinglePkc saved = t.insert(inserted);
+ SinglePkc saved = template.insert(inserted);
assertSame(saved, inserted);
// select
SinglePkcId id = id(SinglePkcId.class).key(saved.getKey());
- SinglePkc selected = t.selectOneById(SinglePkc.class, id);
+ SinglePkc selected = template.selectOneById(SinglePkc.class, id);
assertNotSame(selected, saved);
assertEquals(saved.getKey(), selected.getKey());
assertEquals(saved.getValue(), selected.getValue());
// update
selected.setValue(uuid());
- SinglePkc updated = t.update(selected);
+ SinglePkc updated = template.update(selected);
assertSame(updated, selected);
- selected = t.selectOneById(SinglePkc.class, id);
+ selected = template.selectOneById(SinglePkc.class, id);
assertNotSame(selected, updated);
assertEquals(updated.getValue(), selected.getValue());
// delete
- t.delete(selected);
- assertNull(t.selectOneById(SinglePkc.class, id));
+ template.delete(selected);
+ assertNull(template.selectOneById(SinglePkc.class, id));
}
public interface SinglePkcId {
@@ -84,11 +99,9 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTest extends
@Table
public static class SinglePkc {
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String key;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key;
- @Column
- String value;
+ @Column String value;
/**
* @deprecated for persistence use only
@@ -124,12 +137,12 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTest extends
// insert
MultiPkc inserted = new MultiPkc(uuid(), uuid());
inserted.setValue(uuid());
- MultiPkc saved = t.insert(inserted);
+ MultiPkc saved = template.insert(inserted);
assertSame(saved, inserted);
// select
MultiPkcId id = id(MultiPkcId.class).key0(saved.getKey0()).key1(saved.getKey1());
- MultiPkc selected = t.selectOneById(MultiPkc.class, id);
+ MultiPkc selected = template.selectOneById(MultiPkc.class, id);
assertNotSame(selected, saved);
assertEquals(saved.getKey0(), selected.getKey0());
assertEquals(saved.getKey1(), selected.getKey1());
@@ -137,16 +150,16 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTest extends
// update
selected.setValue(uuid());
- MultiPkc updated = t.update(selected);
+ MultiPkc updated = template.update(selected);
assertSame(updated, selected);
- selected = t.selectOneById(MultiPkc.class, id);
+ selected = template.selectOneById(MultiPkc.class, id);
assertNotSame(selected, updated);
assertEquals(updated.getValue(), selected.getValue());
// delete
- t.delete(selected);
- assertNull(t.selectOneById(MultiPkc.class, id));
+ template.delete(selected);
+ assertNull(template.selectOneById(MultiPkc.class, id));
}
public interface MultiPkcId {
@@ -162,14 +175,11 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTest extends
@Table
public static class MultiPkc {
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String key0;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key0;
- @PrimaryKeyColumn(ordinal = 1)
- String key1;
+ @PrimaryKeyColumn(ordinal = 1) String key1;
- @Column
- String value;
+ @Column String value;
/**
* @deprecated for persistence use only
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPkc.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPkc.java
deleted file mode 100644
index 4331eb050..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPkc.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
-
-import org.springframework.cassandra.core.PrimaryKeyType;
-import org.springframework.data.cassandra.mapping.Column;
-import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
-import org.springframework.data.cassandra.mapping.Table;
-
-@Table
-public class MultiPkc {
-
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String key0;
-
- @PrimaryKeyColumn(ordinal = 1)
- String key1;
-
- @Column
- String value;
-
- /**
- * @deprecated for persistence use only
- */
- @Deprecated
- @SuppressWarnings("unused")
- private MultiPkc() {}
-
- public MultiPkc(String key0, String key1) {
- setKey0(key0);
- setKey1(key1);
- }
-
- public String getKey0() {
- return key0;
- }
-
- public void setKey0(String key0) {
- this.key0 = key0;
- }
-
- public String getKey1() {
- return key1;
- }
-
- public void setKey1(String key1) {
- this.key1 = key1;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPkcRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPkcRepository.java
deleted file mode 100644
index 1a4a3721b..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPkcRepository.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
-
-import org.springframework.data.cassandra.repository.CassandraRepository;
-
-public interface MultiPkcRepository extends CassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPrimaryKeyColumns.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPrimaryKeyColumns.java
new file mode 100644
index 000000000..a747f3a4d
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPrimaryKeyColumns.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
+
+import org.springframework.cassandra.core.PrimaryKeyType;
+import org.springframework.data.cassandra.mapping.Column;
+import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
+import org.springframework.data.cassandra.mapping.Table;
+
+/**
+ * @author Matthew T. Adams
+ */
+@Table
+public class MultiPrimaryKeyColumns {
+
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key0;
+
+ @PrimaryKeyColumn(ordinal = 1) String key1;
+
+ @Column String value;
+
+ /**
+ * @deprecated for persistence use only
+ */
+ @Deprecated
+ @SuppressWarnings("unused")
+ private MultiPrimaryKeyColumns() {}
+
+ public MultiPrimaryKeyColumns(String key0, String key1) {
+ setKey0(key0);
+ setKey1(key1);
+ }
+
+ public String getKey0() {
+ return key0;
+ }
+
+ public void setKey0(String key0) {
+ this.key0 = key0;
+ }
+
+ public String getKey1() {
+ return key1;
+ }
+
+ public void setKey1(String key1) {
+ this.key1 = key1;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/CqlStringUtilsTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPrimaryKeyColumnsRepository.java
similarity index 55%
rename from spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/CqlStringUtilsTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPrimaryKeyColumnsRepository.java
index 9b72fe303..b70cc7250 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/test/unit/core/cql/CqlStringUtilsTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/MultiPrimaryKeyColumnsRepository.java
@@ -1,18 +1,23 @@
/*
- * Copyright 2013-2014 the original author or authors.
- *
+ * Copyright 2016 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.cassandra.test.unit.core.cql;
+package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
-public class CqlStringUtilsTest {}
+import org.springframework.data.cassandra.repository.CassandraRepository;
+
+/**
+ * @author Matthew T. Adams
+ */
+public interface MultiPrimaryKeyColumnsRepository extends CassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTests.java
similarity index 50%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTests.java
index 2df98426d..63ca1d62e 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTests.java
@@ -1,11 +1,22 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.springframework.data.cassandra.repository.support.BasicMapId.id;
+import static org.junit.Assert.*;
+import static org.springframework.data.cassandra.repository.support.BasicMapId.*;
import org.junit.Before;
import org.junit.Test;
@@ -20,78 +31,78 @@ import org.springframework.data.cassandra.test.integration.support.IntegrationTe
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * Integration tests for repositories using {@link MapId}.
+ *
+ * @author Matthew T. Adams.
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class RepositoryMapIdIntegrationTest extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class RepositoryMapIdIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@Configuration
- @EnableCassandraRepositories(basePackageClasses = RepositoryMapIdIntegrationTest.class)
+ @EnableCassandraRepositories(basePackageClasses = RepositoryMapIdIntegrationTests.class)
public static class Config extends IntegrationTestConfig {
@Override
public String[] getEntityBasePackages() {
- return new String[] { SinglePkc.class.getPackage().getName() };
+ return new String[] { SinglePrimaryKeyColumn.class.getPackage().getName() };
}
}
- @Autowired
- CassandraOperations t;
-
- @Autowired
- SinglePkcRepository sr;
-
- @Autowired
- MultiPkcRepository mr;
+ @Autowired CassandraOperations template;
+ @Autowired SinglePrimaryKecColumnRepository singlePrimaryKecColumnRepository;
+ @Autowired MultiPrimaryKeyColumnsRepository multiPrimaryKeyColumnsRepository;
@Before
public void before() {
- assertNotNull(t);
- assertNotNull(sr);
- assertNotNull(mr);
+ assertNotNull(template);
+ assertNotNull(singlePrimaryKecColumnRepository);
+ assertNotNull(multiPrimaryKeyColumnsRepository);
}
@Test
public void testSinglePkc() {
// insert
- SinglePkc inserted = new SinglePkc(uuid());
+ SinglePrimaryKeyColumn inserted = new SinglePrimaryKeyColumn(uuid());
inserted.setValue(uuid());
- SinglePkc saved = sr.save(inserted);
+ SinglePrimaryKeyColumn saved = singlePrimaryKecColumnRepository.save(inserted);
assertSame(saved, inserted);
// select
MapId id = id("key", saved.getKey());
- SinglePkc selected = sr.findOne(id);
+ SinglePrimaryKeyColumn selected = singlePrimaryKecColumnRepository.findOne(id);
assertNotSame(selected, saved);
assertEquals(saved.getKey(), selected.getKey());
assertEquals(saved.getValue(), selected.getValue());
// update
selected.setValue(uuid());
- SinglePkc updated = sr.save(selected);
+ SinglePrimaryKeyColumn updated = singlePrimaryKecColumnRepository.save(selected);
assertSame(updated, selected);
- selected = sr.findOne(id);
+ selected = singlePrimaryKecColumnRepository.findOne(id);
assertNotSame(selected, updated);
assertEquals(updated.getValue(), selected.getValue());
// delete
- sr.delete(selected);
- assertNull(sr.findOne(id));
+ singlePrimaryKecColumnRepository.delete(selected);
+ assertNull(singlePrimaryKecColumnRepository.findOne(id));
}
@Test
public void testMultiPkc() {
// insert
- MultiPkc inserted = new MultiPkc(uuid(), uuid());
+ MultiPrimaryKeyColumns inserted = new MultiPrimaryKeyColumns(uuid(), uuid());
inserted.setValue(uuid());
- MultiPkc saved = mr.save(inserted);
+ MultiPrimaryKeyColumns saved = multiPrimaryKeyColumnsRepository.save(inserted);
assertSame(saved, inserted);
// select
MapId id = id("key0", saved.getKey0()).with("key1", saved.getKey1());
- MultiPkc selected = mr.findOne(id);
+ MultiPrimaryKeyColumns selected = multiPrimaryKeyColumnsRepository.findOne(id);
assertNotSame(selected, saved);
assertEquals(saved.getKey0(), selected.getKey0());
assertEquals(saved.getKey1(), selected.getKey1());
@@ -99,16 +110,16 @@ public class RepositoryMapIdIntegrationTest extends AbstractSpringDataEmbeddedCa
// update
selected.setValue(uuid());
- MultiPkc updated = mr.save(selected);
+ MultiPrimaryKeyColumns updated = multiPrimaryKeyColumnsRepository.save(selected);
assertSame(updated, selected);
- selected = mr.findOne(id);
+ selected = multiPrimaryKeyColumnsRepository.findOne(id);
assertNotSame(selected, updated);
assertEquals(updated.getValue(), selected.getValue());
// delete
- t.delete(selected);
- assertNull(mr.findOne(id));
+ template.delete(selected);
+ assertNull(multiPrimaryKeyColumnsRepository.findOne(id));
}
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePkc.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePkc.java
deleted file mode 100644
index 1a00dad81..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePkc.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
-
-import org.springframework.cassandra.core.PrimaryKeyType;
-import org.springframework.data.cassandra.mapping.Column;
-import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
-import org.springframework.data.cassandra.mapping.Table;
-
-@Table
-public class SinglePkc {
-
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String key;
-
- @Column
- String value;
-
- /**
- * @deprecated for persistence use only
- */
- @Deprecated
- @SuppressWarnings("unused")
- private SinglePkc() {}
-
- public SinglePkc(String key) {
- setKey(key);
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePkcRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePkcRepository.java
deleted file mode 100644
index 98fd736f7..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePkcRepository.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
-
-import org.springframework.data.cassandra.repository.CassandraRepository;
-
-public interface SinglePkcRepository extends CassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePrimaryKecColumnRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePrimaryKecColumnRepository.java
new file mode 100644
index 000000000..ba4cf89b8
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePrimaryKecColumnRepository.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
+
+import org.springframework.data.cassandra.repository.CassandraRepository;
+
+/**
+ * @author Matthew T. Adams
+ */
+public interface SinglePrimaryKecColumnRepository extends CassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePrimaryKeyColumn.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePrimaryKeyColumn.java
new file mode 100644
index 000000000..34086f655
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/SinglePrimaryKeyColumn.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.mapping.mapid.repo;
+
+import org.springframework.cassandra.core.PrimaryKeyType;
+import org.springframework.data.cassandra.mapping.Column;
+import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
+import org.springframework.data.cassandra.mapping.Table;
+
+/**
+ * @author Matthew T. Adams
+ */
+@Table
+public class SinglePrimaryKeyColumn {
+
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key;
+
+ @Column String value;
+
+ /**
+ * @deprecated for persistence use only
+ */
+ @Deprecated
+ @SuppressWarnings("unused")
+ private SinglePrimaryKeyColumn() {}
+
+ public SinglePrimaryKeyColumn(String key) {
+ setKey(key);
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/template/CassandraTemplateMapIdIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/template/CassandraTemplateMapIdIntegrationTest.java
index 28a0ae56c..cfd626d9c 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/template/CassandraTemplateMapIdIntegrationTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/template/CassandraTemplateMapIdIntegrationTest.java
@@ -1,11 +1,23 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.data.cassandra.test.integration.mapping.mapid.template;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.springframework.data.cassandra.repository.support.BasicMapId.id;
+import static org.junit.Assert.*;
+import static org.springframework.data.cassandra.repository.support.BasicMapId.*;
import org.junit.Before;
import org.junit.Test;
@@ -23,6 +35,11 @@ import org.springframework.data.cassandra.test.integration.support.IntegrationTe
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * Integration tests for {@link org.springframework.data.cassandra.core.CassandraTemplate} with {@link MapId}.
+ *
+ * @author Matthew T. Adams
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class CassandraTemplateMapIdIntegrationTest extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@@ -36,12 +53,11 @@ public class CassandraTemplateMapIdIntegrationTest extends AbstractSpringDataEmb
}
}
- @Autowired
- CassandraOperations t;
+ @Autowired CassandraOperations template;
@Before
public void before() {
- assertNotNull(t);
+ assertNotNull(template);
}
@Test
@@ -50,38 +66,36 @@ public class CassandraTemplateMapIdIntegrationTest extends AbstractSpringDataEmb
// insert
SinglePkc inserted = new SinglePkc(uuid());
inserted.setValue(uuid());
- SinglePkc saved = t.insert(inserted);
+ SinglePkc saved = template.insert(inserted);
assertSame(saved, inserted);
// select
MapId id = id("key", saved.getKey());
- SinglePkc selected = t.selectOneById(SinglePkc.class, id);
+ SinglePkc selected = template.selectOneById(SinglePkc.class, id);
assertNotSame(selected, saved);
assertEquals(saved.getKey(), selected.getKey());
assertEquals(saved.getValue(), selected.getValue());
// update
selected.setValue(uuid());
- SinglePkc updated = t.update(selected);
+ SinglePkc updated = template.update(selected);
assertSame(updated, selected);
- selected = t.selectOneById(SinglePkc.class, id);
+ selected = template.selectOneById(SinglePkc.class, id);
assertNotSame(selected, updated);
assertEquals(updated.getValue(), selected.getValue());
// delete
- t.delete(selected);
- assertNull(t.selectOneById(SinglePkc.class, id));
+ template.delete(selected);
+ assertNull(template.selectOneById(SinglePkc.class, id));
}
@Table
public static class SinglePkc {
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String key;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key;
- @Column
- String value;
+ @Column String value;
/**
* @deprecated for persistence use only
@@ -117,12 +131,12 @@ public class CassandraTemplateMapIdIntegrationTest extends AbstractSpringDataEmb
// insert
MultiPkc inserted = new MultiPkc(uuid(), uuid());
inserted.setValue(uuid());
- MultiPkc saved = t.insert(inserted);
+ MultiPkc saved = template.insert(inserted);
assertSame(saved, inserted);
// select
MapId id = id("key0", saved.getKey0()).with("key1", saved.getKey1());
- MultiPkc selected = t.selectOneById(MultiPkc.class, id);
+ MultiPkc selected = template.selectOneById(MultiPkc.class, id);
assertNotSame(selected, saved);
assertEquals(saved.getKey0(), selected.getKey0());
assertEquals(saved.getKey1(), selected.getKey1());
@@ -130,29 +144,26 @@ public class CassandraTemplateMapIdIntegrationTest extends AbstractSpringDataEmb
// update
selected.setValue(uuid());
- MultiPkc updated = t.update(selected);
+ MultiPkc updated = template.update(selected);
assertSame(updated, selected);
- selected = t.selectOneById(MultiPkc.class, id);
+ selected = template.selectOneById(MultiPkc.class, id);
assertNotSame(selected, updated);
assertEquals(updated.getValue(), selected.getValue());
// delete
- t.delete(selected);
- assertNull(t.selectOneById(MultiPkc.class, id));
+ template.delete(selected);
+ assertNull(template.selectOneById(MultiPkc.class, id));
}
@Table
public static class MultiPkc {
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- String key0;
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key0;
- @PrimaryKeyColumn(ordinal = 1)
- String key1;
+ @PrimaryKeyColumn(ordinal = 1) String key1;
- @Column
- String value;
+ @Column String value;
/**
* @deprecated for persistence use only
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTests.java
similarity index 82%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTest.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTests.java
index 9e001668c..a25d707d0 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTest.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTests.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,7 +15,7 @@
*/
package org.springframework.data.cassandra.test.integration.minimal.config;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,18 +26,21 @@ import org.springframework.data.cassandra.test.integration.support.AbstractSprin
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * Integration tests for XML-based configuration.
+ *
+ * @author Matthew T. Adams
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class AbsoluteMinimumXmlConfigIntegrationTest extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class AbsoluteMinimumXmlConfigIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
- @Autowired
- CassandraMappingContext context;
+ @Autowired CassandraMappingContext context;
@Test
public void test() {
assertNotNull(context);
-
context.getPersistentEntity(AbsMin.class);
}
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMin.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMin.java
index 3d4965b0b..7642eecd1 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMin.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMin.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,10 +18,12 @@ package org.springframework.data.cassandra.test.integration.minimal.config.entit
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
+/**
+ * @author Matthew T. Adams
+ */
@Table
public class AbsMin {
- @PrimaryKey
- String key;
+ @PrimaryKey String key;
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMinRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMinRepository.java
index a6564f2c6..6c5172298 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMinRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMinRepository.java
@@ -1,12 +1,12 @@
/*
* Copyright 2013-2014 the original author or authors
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,4 +17,7 @@ package org.springframework.data.cassandra.test.integration.minimal.config.entit
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;
+/**
+ * @author Matthew T. Adams
+ */
public interface AbsMinRepository extends TypedIdCassandraRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigThing.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigThing.java
deleted file mode 100644
index ce2c22129..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigThing.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.bigintparam;
-
-import org.springframework.cassandra.core.PrimaryKeyType;
-import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
-import org.springframework.data.cassandra.mapping.Table;
-
-import java.math.BigInteger;
-
-@Table
-public class BigThing {
-
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private BigInteger number;
-
- public BigThing() {}
-
- public BigThing(BigInteger number) {
- setNumber(number);
- }
-
- public BigInteger getNumber() {
- return number;
- }
-
- public void setNumber(BigInteger number) {
- this.number = number;
- }
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigThingRepo.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigThingRepo.java
deleted file mode 100644
index be6118efe..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigThingRepo.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.bigintparam;
-
-import org.springframework.data.cassandra.repository.CassandraRepository;
-import org.springframework.data.cassandra.repository.Query;
-
-import java.math.BigInteger;
-
-public interface BigThingRepo extends CassandraRepository {
-
- @Query("SELECT * from bigthing where number = ?0")
- BigThing findThingByBigInteger(BigInteger number);
-
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/Thing.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/Thing.java
deleted file mode 100644
index 09d5c55e4..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/Thing.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.datekey;
-
-import java.util.Date;
-
-import org.springframework.cassandra.core.PrimaryKeyType;
-import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
-import org.springframework.data.cassandra.mapping.Table;
-import org.springframework.util.Assert;
-
-@Table
-public class Thing {
-
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private Date date;
-
- protected Thing() {}
-
- public Thing(Date date) {
- setDate(date);
- }
-
- public Date getDate() {
- return new Date(date.getTime());
- }
-
- public void setDate(Date date) {
- Assert.notNull(date);
- this.date = new Date(date.getTime());
- }
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/ThingRepo.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/ThingRepo.java
deleted file mode 100644
index fa659d385..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/ThingRepo.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.datekey;
-
-import java.util.Date;
-
-import org.springframework.data.cassandra.repository.CassandraRepository;
-import org.springframework.data.cassandra.repository.Query;
-
-public interface ThingRepo extends CassandraRepository {
-
- @Query("SELECT * from thing where date = ?0")
- Thing findThingByDate(Date date);
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/anno/QueryAnnotationIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/anno/QueryAnnotationIntegrationTests.java
deleted file mode 100644
index 9b6c184a5..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/anno/QueryAnnotationIntegrationTests.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.declared.anno;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
-import org.springframework.data.cassandra.test.integration.querymethods.declared.QueryIntegrationTests;
-import org.springframework.test.context.ContextConfiguration;
-
-@ContextConfiguration
-public class QueryAnnotationIntegrationTests extends QueryIntegrationTests {
-
- @Configuration
- @EnableCassandraRepositories(basePackageClasses = PersonRepositoryWithQueryAnnotations.class)
- public static class Config extends QueryIntegrationTests.Config {}
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/named/NamedQueryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/named/NamedQueryIntegrationTests.java
deleted file mode 100644
index ca629a0cc..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/named/NamedQueryIntegrationTests.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.declared.named;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
-import org.springframework.data.cassandra.test.integration.querymethods.declared.QueryIntegrationTests;
-import org.springframework.test.context.ContextConfiguration;
-
-@ContextConfiguration
-public class NamedQueryIntegrationTests extends QueryIntegrationTests {
-
- @Configuration
- @EnableCassandraRepositories(basePackageClasses = PersonRepositoryWithNamedQueries.class,
- namedQueriesLocation = "classpath:META-INF/PersonRepositoryWithNamedQueries.properties")
- public static class Config extends QueryIntegrationTests.Config {}
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/named/PersonRepositoryWithNamedQueries.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/named/PersonRepositoryWithNamedQueries.java
deleted file mode 100644
index 954ec79d8..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/named/PersonRepositoryWithNamedQueries.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.declared.named;
-
-import org.springframework.data.cassandra.test.integration.querymethods.declared.base.PersonRepository;
-
-public interface PersonRepositoryWithNamedQueries extends PersonRepository {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/derived/TODO.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/derived/TODO.java
deleted file mode 100644
index 678cd8808..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/derived/TODO.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.derived;
-
-// TODO
-public class TODO {}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/intparam/Thing.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/intparam/Thing.java
deleted file mode 100644
index 09f8cba66..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/intparam/Thing.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.intparam;
-
-import org.springframework.cassandra.core.PrimaryKeyType;
-import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
-import org.springframework.data.cassandra.mapping.Table;
-
-@Table
-public class Thing {
-
- @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
- private int number;
-
- public Thing() {}
-
- public Thing(int number) {
- setNumber(number);
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/intparam/ThingRepo.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/intparam/ThingRepo.java
deleted file mode 100644
index afe78522f..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/intparam/ThingRepo.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.springframework.data.cassandra.test.integration.querymethods.intparam;
-
-import org.springframework.data.cassandra.repository.CassandraRepository;
-import org.springframework.data.cassandra.repository.Query;
-
-public interface ThingRepo extends CassandraRepository {
-
- @Query("SELECT * from thing where number = ?0")
- Thing findThingByIntPrimitive(int number);
-
- @Query("SELECT * from thing where number = ?0")
- Thing findThingByIntReference(Integer number);
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CassandraOperationsProducer.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CassandraOperationsProducer.java
index e7fab7c0b..0592f1f71 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CassandraOperationsProducer.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CassandraOperationsProducer.java
@@ -21,35 +21,52 @@ import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.Service;
import org.springframework.cassandra.core.cql.CqlIdentifier;
import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification;
-import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.core.keyspace.DropKeyspaceSpecification;
+import org.springframework.cassandra.support.RandomKeySpaceName;
+import org.springframework.cassandra.test.integration.support.CassandraConnectionProperties;
import org.springframework.data.cassandra.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.core.CassandraAdminTemplate;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
-import org.springframework.data.cassandra.test.integration.repository.User;
+import org.springframework.data.cassandra.test.integration.repository.simple.User;
+
+import com.datastax.driver.core.Cluster;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.Service;
/**
* @author Mark Paluch
*/
-@ApplicationScoped
class CassandraOperationsProducer {
+ public final static String KEYSPACE_NAME = RandomKeySpaceName.create();
+
@Produces
- public CassandraOperations createCassandraOperations() throws Exception {
- String keySpace = AbstractEmbeddedCassandraIntegrationTest.randomKeyspaceName();
+ @Singleton
+ public Cluster createCluster() throws Exception {
+ CassandraConnectionProperties properties = new CassandraConnectionProperties();
+
+ Cluster cluster = Cluster.builder().addContactPoint(properties.getCassandraHost())
+ .withPort(properties.getCassandraPort()).build();
+ return cluster;
+ }
+
+ @Produces
+ @ApplicationScoped
+ public CassandraOperations createCassandraOperations(Cluster cluster) throws Exception {
MappingCassandraConverter cassandraConverter = new MappingCassandraConverter();
- CassandraAdminTemplate cassandraTemplate = new CassandraAdminTemplate(AbstractEmbeddedCassandraIntegrationTest
- .cluster().connect(), cassandraConverter);
- CreateKeyspaceSpecification createKeyspaceSpecification = new CreateKeyspaceSpecification(keySpace).ifNotExists();
+ CassandraAdminTemplate cassandraTemplate = new CassandraAdminTemplate(cluster.connect(), cassandraConverter);
+
+ CreateKeyspaceSpecification createKeyspaceSpecification = new CreateKeyspaceSpecification(KEYSPACE_NAME)
+ .ifNotExists();
cassandraTemplate.execute(createKeyspaceSpecification);
- cassandraTemplate.execute("USE " + keySpace);
+ cassandraTemplate.execute("USE " + KEYSPACE_NAME);
cassandraTemplate.createTable(true, CqlIdentifier.cqlId("users"), User.class, new HashMap());
@@ -62,9 +79,15 @@ class CassandraOperationsProducer {
}
public void close(@Disposes CassandraOperations cassandraOperations) {
+
+ cassandraOperations.execute(DropKeyspaceSpecification.dropKeyspace(KEYSPACE_NAME));
cassandraOperations.getSession().close();
}
+ public void close(@Disposes Cluster cluster) {
+ cluster.close();
+ }
+
@Produces
public Set producerToSatisfyGuavaDependenciesWhenTesting() {
return Sets.newHashSet();
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiRepositoryTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiRepositoryTests.java
index 68ea58f5a..ec526d7fb 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiRepositoryTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiRepositoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 the original author or authors.
+ * Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,13 +25,12 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
-import org.springframework.data.cassandra.test.integration.repository.User;
+import org.springframework.data.cassandra.test.integration.repository.simple.User;
/**
* @author Mohsin Husen
* @author Mark Paluch
*/
-
public class CdiRepositoryTests extends AbstractEmbeddedCassandraIntegrationTest {
private static CdiTestContainer cdiContainer;
@@ -40,9 +39,13 @@ public class CdiRepositoryTests extends AbstractEmbeddedCassandraIntegrationTest
@BeforeClass
public static void init() throws Exception {
- startCassandra();
+ // CDI container is booted before the @Rule can be triggered.
+ // Ensure that we have a usable Cassandra instance otherwise the container won't boot
+ // because it needs a CassandraOperations with a working Session/Cluster
+
cdiContainer = CdiTestContainerLoader.getCdiContainer();
cdiContainer.startApplicationScope();
+ cdiContainer.startContexts();
cdiContainer.bootContainer();
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiUserRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiUserRepository.java
index 8a3b5dac0..0f735ede1 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiUserRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiUserRepository.java
@@ -15,7 +15,7 @@
*/
package org.springframework.data.cassandra.test.integration.repository.cdi;
-import org.springframework.data.cassandra.test.integration.repository.User;
+import org.springframework.data.cassandra.test.integration.repository.simple.User;
import org.springframework.data.repository.CrudRepository;
/**
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepository.java
index bba7a5f7e..515051797 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepository.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepository.java
@@ -16,7 +16,7 @@
package org.springframework.data.cassandra.test.integration.repository.cdi;
-import org.springframework.data.cassandra.test.integration.querymethods.declared.Person;
+import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person;
import org.springframework.data.repository.Repository;
/**
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigIntParamIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigIntParamIntegrationTests.java
similarity index 63%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigIntParamIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigIntParamIntegrationTests.java
index 0de834747..c1320bbea 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/bigintparam/BigIntParamIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigIntParamIntegrationTests.java
@@ -1,4 +1,24 @@
-package org.springframework.data.cassandra.test.integration.querymethods.bigintparam;
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.data.cassandra.test.integration.repository.querymethods.bigintparam;
+
+import static org.junit.Assert.*;
+
+import java.math.BigInteger;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -11,10 +31,11 @@ import org.springframework.data.cassandra.test.integration.support.IntegrationTe
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.math.BigInteger;
-
-import static org.junit.Assert.assertNotNull;
-
+/**
+ * Integration tests for {@link BigInteger} usage in repositories.
+ *
+ * @author Pete Cable
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class BigIntParamIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@@ -33,8 +54,7 @@ public class BigIntParamIntegrationTests extends AbstractSpringDataEmbeddedCassa
}
}
- @Autowired
- BigThingRepo repo;
+ @Autowired BigThingRepo repo;
@Test
public void testQueryWithReference() {
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThing.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThing.java
new file mode 100644
index 000000000..fd7a47934
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThing.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.repository.querymethods.bigintparam;
+
+import java.math.BigInteger;
+
+import org.springframework.cassandra.core.PrimaryKeyType;
+import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
+import org.springframework.data.cassandra.mapping.Table;
+
+/**
+ * @author Pete Cable
+ */
+@Table
+public class BigThing {
+
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private BigInteger number;
+
+ public BigThing() {}
+
+ public BigThing(BigInteger number) {
+ setNumber(number);
+ }
+
+ public BigInteger getNumber() {
+ return number;
+ }
+
+ public void setNumber(BigInteger number) {
+ this.number = number;
+ }
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThingRepo.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThingRepo.java
new file mode 100644
index 000000000..7ffee3f9e
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThingRepo.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.repository.querymethods.bigintparam;
+
+import java.math.BigInteger;
+
+import org.springframework.data.cassandra.repository.CassandraRepository;
+import org.springframework.data.cassandra.repository.Query;
+
+/**
+ * @author Pete Cable
+ */
+public interface BigThingRepo extends CassandraRepository {
+
+ @Query("SELECT * from bigthing where number = ?0")
+ BigThing findThingByBigInteger(BigInteger number);
+
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/DateKeyIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateKeyIntegrationTests.java
similarity index 52%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/DateKeyIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateKeyIntegrationTests.java
index c3a800586..756df1238 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/datekey/DateKeyIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateKeyIntegrationTests.java
@@ -1,6 +1,21 @@
-package org.springframework.data.cassandra.test.integration.querymethods.datekey;
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.repository.querymethods.datekey;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
import java.util.Date;
@@ -15,16 +30,21 @@ import org.springframework.data.cassandra.test.integration.support.IntegrationTe
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * Integration tests for {@link Date} usage in repositories.
+ *
+ * @author Matthew T. Adams
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class DateKeyIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@Configuration
- @EnableCassandraRepositories(basePackageClasses = ThingRepo.class)
+ @EnableCassandraRepositories(basePackageClasses = DateThingRepo.class)
public static class Config extends IntegrationTestConfig {
@Override
public String[] getEntityBasePackages() {
- return new String[] { Thing.class.getPackage().getName() };
+ return new String[] { DateThing.class.getPackage().getName() };
}
@Override
@@ -33,16 +53,15 @@ public class DateKeyIntegrationTests extends AbstractSpringDataEmbeddedCassandra
}
}
- @Autowired
- ThingRepo repo;
+ @Autowired DateThingRepo repo;
@Test
public void testQueryWithDate() {
Date date = new Date();
- Thing saved = new Thing(date);
+ DateThing saved = new DateThing(date);
repo.save(saved);
- Thing found = repo.findThingByDate(date);
+ DateThing found = repo.findThingByDate(date);
assertNotNull(found);
}
}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThing.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThing.java
new file mode 100644
index 000000000..55b3aed23
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThing.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.repository.querymethods.datekey;
+
+import java.util.Date;
+
+import org.springframework.cassandra.core.PrimaryKeyType;
+import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
+import org.springframework.data.cassandra.mapping.Table;
+import org.springframework.util.Assert;
+
+/**
+ * @author Matthew T. Adams
+ */
+@Table
+public class DateThing {
+
+ @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private Date date;
+
+ protected DateThing() {}
+
+ public DateThing(Date date) {
+ setDate(date);
+ }
+
+ public Date getDate() {
+ return new Date(date.getTime());
+ }
+
+ public void setDate(Date date) {
+ Assert.notNull(date);
+ this.date = new Date(date.getTime());
+ }
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThingRepo.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThingRepo.java
new file mode 100644
index 000000000..f276ded4b
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThingRepo.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.repository.querymethods.datekey;
+
+import java.util.Date;
+
+import org.springframework.data.cassandra.repository.CassandraRepository;
+import org.springframework.data.cassandra.repository.Query;
+
+/**
+ * Integration tests for {@link Date} usage in repositories.
+ *
+ * @author Matthew T. Adams
+ */
+public interface DateThingRepo extends CassandraRepository {
+
+ @Query("SELECT * from datething where date = ?0")
+ DateThing findThingByDate(Date date);
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/Person.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/Person.java
similarity index 91%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/Person.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/Person.java
index b9213795d..85ef492f3 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/Person.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/Person.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2013 the original author or authors.
+ * Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.data.cassandra.test.integration.querymethods.declared;
+package org.springframework.data.cassandra.test.integration.repository.querymethods.declared;
import java.util.Date;
@@ -27,11 +27,9 @@ import org.springframework.data.cassandra.mapping.Table;
@Table
public class Person {
- @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0)
- private String lastname;
+ @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0) private String lastname;
- @PrimaryKeyColumn(type = PrimaryKeyType.CLUSTERED, ordinal = 1)
- private String firstname;
+ @PrimaryKeyColumn(type = PrimaryKeyType.CLUSTERED, ordinal = 1) private String firstname;
private String nickname;
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/QueryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java
similarity index 68%
rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/QueryIntegrationTests.java
rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java
index 907cf0feb..2e062d4db 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/querymethods/declared/QueryIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java
@@ -1,8 +1,21 @@
-package org.springframework.data.cassandra.test.integration.querymethods.declared;
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.cassandra.test.integration.repository.querymethods.declared;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.util.Collection;
import java.util.Date;
@@ -14,11 +27,14 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.cassandra.config.SchemaAction;
-import org.springframework.data.cassandra.test.integration.querymethods.declared.base.PersonRepository;
+import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.base.PersonRepository;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * @author Matthew T. Adams
+ */
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@@ -35,8 +51,7 @@ public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCa
}
}
- @Autowired
- PersonRepository r;
+ @Autowired PersonRepository personRepository;
@Before
public void before() {
@@ -50,9 +65,9 @@ public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCa
saved.setFirstname(uuid());
saved.setLastname(uuid());
- saved = r.save(saved);
+ saved = personRepository.save(saved);
- List results = r.findFolksWithLastnameAsList(saved.getLastname());
+ List results = personRepository.findFolksWithLastnameAsList(saved.getLastname());
assertNotNull(results);
assertTrue(results.size() == 1);
@@ -69,15 +84,15 @@ public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCa
saved.setFirstname("a");
saved.setLastname(uuid());
- saved = r.save(saved);
+ saved = personRepository.save(saved);
Person saved2 = new Person();
saved2.setFirstname("b");
saved2.setLastname(saved.getLastname());
- saved2 = r.save(saved2);
+ saved2 = personRepository.save(saved2);
- List results = r.findFolksWithLastnameAsList(saved.getLastname());
+ List results = personRepository.findFolksWithLastnameAsList(saved.getLastname());
assertNotNull(results);
assertTrue(results.size() == 2);
@@ -97,9 +112,10 @@ public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCa
saved.setFirstname(uuid());
saved.setLastname(uuid());
- saved = r.save(saved);
+ saved = personRepository.save(saved);
- List