diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/AbstractEmbeddedCassandraIntegrationTest.java similarity index 90% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/AbstractEmbeddedCassandraIntegrationTest.java index d0236192b..d7a23dcb7 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/AbstractEmbeddedCassandraIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration; +package org.springframework.cassandra; import java.util.UUID; import org.junit.ClassRule; import org.junit.Rule; -import org.springframework.cassandra.test.integration.support.CqlDataSet; +import org.springframework.cassandra.support.CqlDataSet; import com.datastax.driver.core.Cluster; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractKeyspaceCreatingIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/AbstractKeyspaceCreatingIntegrationTest.java similarity index 94% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractKeyspaceCreatingIntegrationTest.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/AbstractKeyspaceCreatingIntegrationTest.java index 1107bfd9e..9c94ed5ac 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractKeyspaceCreatingIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/AbstractKeyspaceCreatingIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration; +package org.springframework.cassandra; import org.junit.ClassRule; import org.springframework.util.Assert; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/CassandraRule.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/CassandraRule.java similarity index 96% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/CassandraRule.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/CassandraRule.java index 0b86fc7dd..667fc5f1d 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/CassandraRule.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/CassandraRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration; +package org.springframework.cassandra; -import static org.springframework.cassandra.test.integration.CassandraRule.InvocationMode.*; +import static org.springframework.cassandra.CassandraRule.InvocationMode.*; import java.util.ArrayList; import java.util.HashMap; @@ -25,9 +25,9 @@ import java.util.concurrent.TimeUnit; import org.junit.rules.ExternalResource; import org.springframework.cassandra.core.SessionCallback; -import org.springframework.cassandra.test.integration.support.CassandraConnectionProperties; -import org.springframework.cassandra.test.integration.support.CqlDataSet; -import org.springframework.cassandra.test.integration.support.IntegrationTestNettyOptions; +import org.springframework.cassandra.support.CassandraConnectionProperties; +import org.springframework.cassandra.support.CqlDataSet; +import org.springframework.cassandra.support.IntegrationTestNettyOptions; import org.springframework.util.Assert; import org.springframework.util.SocketUtils; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/EmbeddedCassandraServerHelper.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/EmbeddedCassandraServerHelper.java similarity index 98% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/EmbeddedCassandraServerHelper.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/EmbeddedCassandraServerHelper.java index 67898692c..170759e36 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/EmbeddedCassandraServerHelper.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/EmbeddedCassandraServerHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration; +package org.springframework.cassandra; import static java.util.concurrent.TimeUnit.*; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/KeyspaceRule.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/KeyspaceRule.java similarity index 97% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/KeyspaceRule.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/KeyspaceRule.java index f4ab418d2..096342a4e 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/KeyspaceRule.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/KeyspaceRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration; +package org.springframework.cassandra; import org.junit.rules.ExternalResource; import org.springframework.cassandra.support.RandomKeySpaceName; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java index bca973320..e470edf1e 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.*; import static org.mockito.Mockito.anyString; import org.junit.Test; +import org.springframework.cassandra.support.IntegrationTestNettyOptions; import org.springframework.test.util.ReflectionTestUtils; import com.datastax.driver.core.*; @@ -344,6 +345,36 @@ public class CassandraCqlClusterFactoryBeanUnitTests { assertThat(getPolicies(bean).getTimestampGenerator()).isEqualTo(mockTimestampGenerator); } + @Test + public void configuredProtocolVersionShouldBeSet() throws Exception { + + CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean(); + + bean.setNettyOptions(IntegrationTestNettyOptions.INSTANCE); + bean.setProtocolVersion(ProtocolVersion.V2); + bean.afterPropertiesSet(); + + assertThat(getProtocolVersionEnum(bean)).isEqualTo(ProtocolVersion.V2); + } + + @Test + public void defaultProtocolVersionShouldBeSet() throws Exception { + + CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean(); + + bean.afterPropertiesSet(); + + assertThat(getProtocolVersionEnum(bean)).isNull(); + } + + private ProtocolVersion getProtocolVersionEnum(CassandraCqlClusterFactoryBean cassandraCqlClusterFactoryBean) + throws Exception { + + // initialize connection factory + return (ProtocolVersion) ReflectionTestUtils.getField( + cassandraCqlClusterFactoryBean.getObject().getConfiguration().getProtocolOptions(), "initialProtocolVersion"); + } + private Policies getPolicies(CassandraCqlClusterFactoryBean bean) throws Exception { return getConfiguration(bean).getPolicies(); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/ConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/ConfigIntegrationTests.java new file mode 100755 index 000000000..1e7d945e7 --- /dev/null +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/ConfigIntegrationTests.java @@ -0,0 +1,59 @@ +/* + * Copyright 2017 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.cassandra.config.java; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.support.AbstractTestJavaConfig; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +import com.datastax.driver.core.Session; + +/** + * @author Matthew T. Adams + * @author Mark Paluch + */ +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = ConfigIntegrationTests.Config.class) +public class ConfigIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { + + @Configuration + static class Config extends AbstractTestJavaConfig { + + @Override + protected String getKeyspaceName() { + return null; + } + } + + @Autowired Session session; + + @Test + public void test() { + + session.execute("DROP KEYSPACE IF EXISTS ConfigTest"); + + session.execute("CREATE KEYSPACE ConfigTest " + "WITH " + + "REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"); + + session.execute("USE ConfigTest"); + } + +} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/CqlTemplateConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/CqlTemplateConfigIntegrationTests.java similarity index 81% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/CqlTemplateConfigIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/CqlTemplateConfigIntegrationTests.java index 5b560fa46..4eee9eb4c 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/CqlTemplateConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/CqlTemplateConfigIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.config.java; +package org.springframework.cassandra.config.java; import static org.assertj.core.api.Assertions.*; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.springframework.cassandra.config.java.AbstractCqlTemplateConfiguration; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; import org.springframework.cassandra.core.CqlTemplate; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.cassandra.test.integration.support.IntegrationTestNettyOptions; +import org.springframework.cassandra.support.IntegrationTestNettyOptions; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; @@ -41,7 +40,7 @@ import com.datastax.driver.core.Session; public class CqlTemplateConfigIntegrationTests extends AbstractEmbeddedCassandraIntegrationTest { @Configuration - public static class Config extends AbstractCqlTemplateConfiguration { + static class Config extends AbstractCqlTemplateConfiguration { @Override protected String getKeyspaceName() { diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/KeyspaceCreatingJavaConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/KeyspaceCreatingJavaConfigIntegrationTests.java new file mode 100755 index 000000000..ce3202bf7 --- /dev/null +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/java/KeyspaceCreatingJavaConfigIntegrationTests.java @@ -0,0 +1,82 @@ +/* + * Copyright 2017 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.cassandra.config.java; + +import static org.assertj.core.api.Assertions.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.config.KeyspaceAttributes; +import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification; +import org.springframework.cassandra.core.keyspace.KeyspaceOption; +import org.springframework.cassandra.support.AbstractTestJavaConfig; +import org.springframework.cassandra.support.KeyspaceTestUtils; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +import com.datastax.driver.core.Session; + +/** + * @author Matthew T. Adams + * @author Mark Paluch + */ +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = KeyspaceCreatingJavaConfigIntegrationTests.KeyspaceCreatingJavaConfig.class) +public class KeyspaceCreatingJavaConfigIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { + + @Autowired Session session; + + @Test + public void test() { + + assertThat(session).isNotNull(); + KeyspaceTestUtils.assertKeyspaceExists(KeyspaceCreatingJavaConfig.KEYSPACE_NAME, session); + + session.execute("DROP KEYSPACE " + KeyspaceCreatingJavaConfig.KEYSPACE_NAME + ";"); + } + + /** + * @author Matthew T. Adams + * @author Mark Paluch + */ + @Configuration + static class KeyspaceCreatingJavaConfig extends AbstractTestJavaConfig { + + public static final String KEYSPACE_NAME = "foo"; + + @Override + protected String getKeyspaceName() { + return KEYSPACE_NAME; + } + + @Override + protected List getKeyspaceCreations() { + ArrayList list = new ArrayList<>(); + + CreateKeyspaceSpecification specification = CreateKeyspaceSpecification.createKeyspace().name(getKeyspaceName()); + specification.with(KeyspaceOption.REPLICATION, KeyspaceAttributes.newSimpleReplication(1L)); + + list.add(specification); + return list; + } + } +} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java similarity index 64% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java index cac711fb8..efa6bd4fa 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.config.xml; +package org.springframework.cassandra.config.xml; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.cassandra.test.integration.config.IntegrationTestUtils; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.cassandra.support.KeyspaceTestUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -36,9 +36,9 @@ public class FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests extends Abs @Test public void test() { - IntegrationTestUtils.assertKeyspaceExists("full1", session); - IntegrationTestUtils.assertKeyspaceExists("full2", session); - IntegrationTestUtils.assertKeyspaceExists("script1", session); - IntegrationTestUtils.assertKeyspaceExists("script2", session); + KeyspaceTestUtils.assertKeyspaceExists("full1", session); + KeyspaceTestUtils.assertKeyspaceExists("full2", session); + KeyspaceTestUtils.assertKeyspaceExists("script1", session); + KeyspaceTestUtils.assertKeyspaceExists("script2", session); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java similarity index 72% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java index 84cba5d67..6e4c357d7 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.config.xml; +package org.springframework.cassandra.config.xml; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.cassandra.test.integration.config.IntegrationTestUtils; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.cassandra.support.KeyspaceTestUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -36,6 +36,6 @@ public class MinimalKeyspaceCreatingXmlConfigIntegrationTests extends AbstractEm @Test public void test() { - IntegrationTestUtils.assertKeyspaceExists("minimal", session); + KeyspaceTestUtils.assertKeyspaceExists("minimal", session); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/MinimalXmlConfigIntegrationTests.java similarity index 78% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalXmlConfigIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/MinimalXmlConfigIntegrationTests.java index d7e4dee7b..5485fa935 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalXmlConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/MinimalXmlConfigIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.config.xml; +package org.springframework.cassandra.config.xml; import static org.assertj.core.api.AssertionsForInterfaceTypes.*; @@ -21,10 +21,10 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.cassandra.KeyspaceRule; import org.springframework.cassandra.core.CqlOperations; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.cassandra.test.integration.KeyspaceRule; -import org.springframework.cassandra.test.integration.config.IntegrationTestUtils; +import org.springframework.cassandra.support.KeyspaceTestUtils; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -59,7 +59,7 @@ public class MinimalXmlConfigIntegrationTests extends AbstractEmbeddedCassandraI @Test public void test() { - IntegrationTestUtils.assertKeyspaceExists(KEYSPACE, session); + KeyspaceTestUtils.assertKeyspaceExists(KEYSPACE, session); CqlOperations cqlOperations = context.getBean(CqlOperations.class); assertThat(cqlOperations.describeRing()).isNotEmpty(); diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests.java similarity index 88% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests.java index 72f0ba164..ba519289c 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.config.xml; +package org.springframework.cassandra.config.xml; import static org.assertj.core.api.Assertions.*; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; import org.springframework.cassandra.core.CqlOperations; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.cassandra.test.integration.config.IntegrationTestUtils; +import org.springframework.cassandra.support.KeyspaceTestUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -51,8 +51,7 @@ public class PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests @Test public void keyspaceExists() { - IntegrationTestUtils.assertSession(session); - IntegrationTestUtils.assertKeyspaceExists("ppncxct", session); + KeyspaceTestUtils.assertKeyspaceExists("ppncxct", session); assertThat(ops).isNotNull(); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/TestHostStateListener.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/TestHostStateListener.java similarity index 90% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/TestHostStateListener.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/TestHostStateListener.java index 48b6d92e9..f99b95820 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/TestHostStateListener.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/TestHostStateListener.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.config.xml; +package org.springframework.cassandra.config.xml; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/TestLatencyTracker.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/TestLatencyTracker.java similarity index 90% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/TestLatencyTracker.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/TestLatencyTracker.java index 821cd01a9..d2c562376 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/TestLatencyTracker.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/TestLatencyTracker.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.config.xml; +package org.springframework.cassandra.config.xml; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/XmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/XmlConfigIntegrationTests.java similarity index 92% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/XmlConfigIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/XmlConfigIntegrationTests.java index 4d2a31273..15c48605b 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/XmlConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/config/xml/XmlConfigIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.config.xml; +package org.springframework.cassandra.config.xml; import static org.assertj.core.api.Assertions.*; @@ -24,10 +24,10 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.cassandra.KeyspaceRule; import org.springframework.cassandra.config.ClusterBuilderConfigurer; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.cassandra.test.integration.KeyspaceRule; -import org.springframework.cassandra.test.integration.config.IntegrationTestUtils; +import org.springframework.cassandra.support.KeyspaceTestUtils; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -87,7 +87,7 @@ public class XmlConfigIntegrationTests extends AbstractEmbeddedCassandraIntegrat @Test public void keyspaceExists() { - IntegrationTestUtils.assertKeyspaceExists(KEYSPACE, session); + KeyspaceTestUtils.assertKeyspaceExists(KEYSPACE, session); } @Test diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/AsyncCqlTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/AsyncCqlTemplateIntegrationTests.java index d515579ae..5f75d52d0 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/AsyncCqlTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/AsyncCqlTemplateIntegrationTests.java @@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import com.datastax.driver.core.querybuilder.QueryBuilder; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/CqlTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/CqlTemplateIntegrationTests.java index ad435a966..d141212d2 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/CqlTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/CqlTemplateIntegrationTests.java @@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import com.datastax.driver.core.querybuilder.QueryBuilder; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java index 1836ea212..d50daeb64 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java @@ -23,9 +23,9 @@ import reactor.test.StepVerifier; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.session.DefaultBridgedReactiveSession; import org.springframework.cassandra.core.session.ReactiveResultSet; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import com.datastax.driver.core.KeyspaceMetadata; import com.datastax.driver.core.exceptions.SyntaxError; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateIntegrationTests.java index b19ebded0..d13b37c28 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/ReactiveCqlTemplateIntegrationTests.java @@ -24,10 +24,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.session.DefaultBridgedReactiveSession; import org.springframework.cassandra.core.session.DefaultReactiveSessionFactory; import org.springframework.cassandra.core.session.ReactiveSession; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import com.datastax.driver.core.querybuilder.QueryBuilder; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/AlterTableCqlGeneratorIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/AlterTableCqlGeneratorIntegrationTests.java index 5d944a209..95a33d467 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/AlterTableCqlGeneratorIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/AlterTableCqlGeneratorIntegrationTests.java @@ -23,12 +23,12 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.keyspace.AlterTableSpecification; import org.springframework.cassandra.core.keyspace.TableOption; import org.springframework.cassandra.core.keyspace.TableOption.CachingOption; import org.springframework.cassandra.core.keyspace.TableOption.KeyCachingOption; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; -import org.springframework.cassandra.test.integration.support.CassandraVersion; +import org.springframework.cassandra.support.CassandraVersion; import org.springframework.data.util.Version; import com.datastax.driver.core.ColumnMetadata; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/AlterUserTypeCqlGeneratorIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/AlterUserTypeCqlGeneratorIntegrationTests.java index 157e86c81..a2589a9b2 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/AlterUserTypeCqlGeneratorIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/AlterUserTypeCqlGeneratorIntegrationTests.java @@ -20,9 +20,9 @@ import static org.springframework.cassandra.core.cql.generator.AlterUserTypeCqlG import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.keyspace.AlterUserTypeSpecification; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; -import org.springframework.cassandra.test.integration.support.CassandraVersion; +import org.springframework.cassandra.support.CassandraVersion; import org.springframework.data.util.Version; import com.datastax.driver.core.DataType; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlIndexSpecificationAssertions.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlIndexSpecificationAssertions.java similarity index 91% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlIndexSpecificationAssertions.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlIndexSpecificationAssertions.java index 33a464950..5773d3ab9 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlIndexSpecificationAssertions.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlIndexSpecificationAssertions.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.core.cql.generator; +package org.springframework.cassandra.core.cql.generator; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlKeyspaceSpecificationAssertions.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlKeyspaceSpecificationAssertions.java similarity index 91% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlKeyspaceSpecificationAssertions.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlKeyspaceSpecificationAssertions.java index a0691f866..349767e2b 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlKeyspaceSpecificationAssertions.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlKeyspaceSpecificationAssertions.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.core.cql.generator; +package org.springframework.cassandra.core.cql.generator; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlTableSpecificationAssertions.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlTableSpecificationAssertions.java similarity index 97% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlTableSpecificationAssertions.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlTableSpecificationAssertions.java index ee0399674..f2c551789 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlTableSpecificationAssertions.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CqlTableSpecificationAssertions.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.core.cql.generator; +package org.springframework.cassandra.core.cql.generator; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java similarity index 77% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java index 7d30db877..7f405d16e 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.core.cql.generator; - -import static org.springframework.cassandra.test.integration.core.cql.generator.CqlIndexSpecificationAssertions.*; +package org.springframework.cassandra.core.cql.generator; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.cql.generator.CreateIndexCqlGeneratorUnitTests.BasicTest; import org.springframework.cassandra.core.cql.generator.CreateIndexCqlGeneratorUnitTests.CreateIndexTest; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; -import org.springframework.cassandra.test.integration.support.CqlDataSet; +import org.springframework.cassandra.support.CqlDataSet; /** * Integration tests that reuse unit tests. @@ -50,7 +48,7 @@ public class CreateIndexCqlGeneratorIntegrationTests { session.execute(unit.cql); - assertIndex(unit.specification, keyspace, session); + CqlIndexSpecificationAssertions.assertIndex(unit.specification, keyspace, session); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java similarity index 80% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java index 41845a5a6..034030f9b 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.core.cql.generator; - -import static org.springframework.cassandra.test.integration.core.cql.generator.CqlKeyspaceSpecificationAssertions.*; +package org.springframework.cassandra.core.cql.generator; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.cql.generator.CreateKeyspaceCqlGeneratorUnitTests.BasicTest; import org.springframework.cassandra.core.cql.generator.CreateKeyspaceCqlGeneratorUnitTests.CreateKeyspaceTest; import org.springframework.cassandra.core.cql.generator.CreateKeyspaceCqlGeneratorUnitTests.NetworkTopologyTest; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; /** * Integration tests that reuse unit tests. @@ -49,7 +47,7 @@ public class CreateKeyspaceCqlGeneratorIntegrationTests { session.execute(unit.cql); - assertKeyspace(unit.specification, unit.keyspace, session); + CqlKeyspaceSpecificationAssertions.assertKeyspace(unit.specification, unit.keyspace, session); dropKeyspace(unit.keyspace); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java similarity index 81% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java index 8b18349f8..242ab6fc9 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.core.cql.generator; - -import static org.springframework.cassandra.test.integration.core.cql.generator.CqlTableSpecificationAssertions.*; +package org.springframework.cassandra.core.cql.generator; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.cql.generator.CreateTableCqlGeneratorUnitTests.BasicTest; import org.springframework.cassandra.core.cql.generator.CreateTableCqlGeneratorUnitTests.CompositePartitionKeyTest; import org.springframework.cassandra.core.cql.generator.CreateTableCqlGeneratorUnitTests.CreateTableTest; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; /** * Integration tests that reuse unit tests. @@ -51,7 +49,7 @@ public class CreateTableCqlGeneratorIntegrationTests { session.execute(unit.cql); - assertTable(unit.specification, keyspace, session); + CqlTableSpecificationAssertions.assertTable(unit.specification, keyspace, session); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateUserTypeCqlGeneratorIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateUserTypeCqlGeneratorIntegrationTests.java index b7f98b0c5..5aafbc949 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateUserTypeCqlGeneratorIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/CreateUserTypeCqlGeneratorIntegrationTests.java @@ -20,8 +20,8 @@ import static org.springframework.cassandra.core.cql.generator.CreateUserTypeCql import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.keyspace.CreateUserTypeSpecification; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import com.datastax.driver.core.DataType; import com.datastax.driver.core.KeyspaceMetadata; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java similarity index 71% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java index b500daba9..6ae57905d 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,17 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.core.cql.generator; - -import static org.springframework.cassandra.test.integration.core.cql.generator.CqlIndexSpecificationAssertions.*; +package org.springframework.cassandra.core.cql.generator; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.cassandra.core.cql.generator.CreateIndexCqlGeneratorUnitTests; -import org.springframework.cassandra.core.cql.generator.DropIndexCqlGeneratorUnitTests; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; /** * Integration tests that reuse unit tests. @@ -55,11 +51,11 @@ public class IndexLifecycleCqlGeneratorIntegrationTests extends AbstractKeyspace log.info(createTest.cql); session.execute(createTest.cql); - assertIndex(createTest.specification, keyspace, session); + CqlIndexSpecificationAssertions.assertIndex(createTest.specification, keyspace, session); log.info(dropTest.cql); session.execute(dropTest.cql); - assertNoIndex(createTest.specification, keyspace, session); + CqlIndexSpecificationAssertions.assertNoIndex(createTest.specification, keyspace, session); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableLifecycleIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/TableLifecycleIntegrationTests.java similarity index 71% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableLifecycleIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/TableLifecycleIntegrationTests.java index 9b0720491..2a74219e6 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableLifecycleIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/TableLifecycleIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,19 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.core.cql.generator; - -import static org.springframework.cassandra.test.integration.core.cql.generator.CqlTableSpecificationAssertions.*; +package org.springframework.cassandra.core.cql.generator; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.cassandra.core.cql.generator.CreateTableCqlGeneratorUnitTests; -import org.springframework.cassandra.core.cql.generator.DropTableCqlGenerator; -import org.springframework.cassandra.core.cql.generator.DropTableCqlGeneratorUnitTests; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.keyspace.DropTableSpecification; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; /** * Test CREATE TABLE / ALTER TABLE / DROP TABLE @@ -54,7 +49,7 @@ public class TableLifecycleIntegrationTests extends AbstractKeyspaceCreatingInte session.execute(createTableTest.cql); - assertTable(createTableTest.specification, keyspace, session); + CqlTableSpecificationAssertions.assertTable(createTableTest.specification, keyspace, session); DropTableTest dropTest = new DropTableTest(); dropTest.prepare(); @@ -63,7 +58,7 @@ public class TableLifecycleIntegrationTests extends AbstractKeyspaceCreatingInte session.execute(dropTest.cql); - assertNoTable(dropTest.specification, keyspace, session); + CqlTableSpecificationAssertions.assertNoTable(dropTest.specification, keyspace, session); } public class DropTableTest extends DropTableCqlGeneratorUnitTests.DropTableTest { diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableOptionsIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/TableOptionsIntegrationTests.java similarity index 68% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableOptionsIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/TableOptionsIntegrationTests.java index f667f4bfe..9100be708 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableOptionsIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/core/cql/generator/TableOptionsIntegrationTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,15 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.core.cql.generator; - -import static org.springframework.cassandra.test.integration.core.cql.generator.CqlTableSpecificationAssertions.*; +package org.springframework.cassandra.core.cql.generator; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.cassandra.core.cql.generator.CreateTableCqlGeneratorUnitTests; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; /** * Test CREATE TABLE for all Options and assert against C* TableMetaData @@ -44,6 +41,6 @@ public class TableOptionsIntegrationTests extends AbstractKeyspaceCreatingIntegr session.execute(optionsTest.cql); - assertTable(optionsTest.specification, keyspace, session); + CqlTableSpecificationAssertions.assertTable(optionsTest.specification, keyspace, session); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/AbstractTestJavaConfig.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/AbstractTestJavaConfig.java similarity index 91% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/AbstractTestJavaConfig.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/support/AbstractTestJavaConfig.java index 1e12af8b8..89558a1d6 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/AbstractTestJavaConfig.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/AbstractTestJavaConfig.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.support; +package org.springframework.cassandra.support; import org.springframework.cassandra.config.java.AbstractSessionConfiguration; import org.springframework.context.annotation.Configuration; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CassandraConnectionProperties.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CassandraConnectionProperties.java similarity index 96% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CassandraConnectionProperties.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CassandraConnectionProperties.java index 104833a3e..cd3181ec3 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CassandraConnectionProperties.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CassandraConnectionProperties.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.support; +package org.springframework.cassandra.support; import java.io.InputStream; import java.util.Properties; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CassandraVersion.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CassandraVersion.java similarity index 95% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CassandraVersion.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CassandraVersion.java index 00c8c2446..4fb9ba722 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CassandraVersion.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CassandraVersion.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.support; +package org.springframework.cassandra.support; import lombok.experimental.UtilityClass; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CqlDataSet.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CqlDataSet.java similarity index 94% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CqlDataSet.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CqlDataSet.java index 474fa7956..d11870ac1 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CqlDataSet.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/CqlDataSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.support; +package org.springframework.cassandra.support; import lombok.SneakyThrows; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/IntegrationTestNettyOptions.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/IntegrationTestNettyOptions.java similarity index 94% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/IntegrationTestNettyOptions.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/support/IntegrationTestNettyOptions.java index 6bfc7bf65..454e44278 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/IntegrationTestNettyOptions.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/IntegrationTestNettyOptions.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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.cassandra.test.integration.support; +package org.springframework.cassandra.support; import io.netty.channel.EventLoopGroup; import io.netty.util.Timer; diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/IntegrationTestUtils.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/KeyspaceTestUtils.java similarity index 64% rename from spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/IntegrationTestUtils.java rename to spring-data-cassandra/src/test/java/org/springframework/cassandra/support/KeyspaceTestUtils.java index 1e3eb8073..de1fb7c4f 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/IntegrationTestUtils.java +++ b/spring-data-cassandra/src/test/java/org/springframework/cassandra/support/KeyspaceTestUtils.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2017 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,26 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.cassandra.test.integration.config; +package org.springframework.cassandra.support; import static org.assertj.core.api.Assertions.*; -import org.springframework.cassandra.core.CqlTemplate; - import com.datastax.driver.core.Session; /** * @author Matthew T. Adams + * @author Mark Paluch */ -public class IntegrationTestUtils { - - public static void assertCqlTemplate(CqlTemplate cqlTemplate) { - assertThat(cqlTemplate).isNotNull(); - } - - public static void assertSession(Session session) { - assertThat(session).isNotNull(); - } +public class KeyspaceTestUtils { public static void assertKeyspaceExists(String keyspace, Session session) { assertThat(session.getCluster().getMetadata().getKeyspace(keyspace)).isNotNull(); diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/CassandraCqlClusterFactoryBeanIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/CassandraCqlClusterFactoryBeanIntegrationTests.java deleted file mode 100755 index 283a6d34c..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/CassandraCqlClusterFactoryBeanIntegrationTests.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2016-2017 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.cassandra.test.integration.config; - -import static org.assertj.core.api.Assertions.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.cassandra.config.CassandraCqlClusterFactoryBean; -import org.springframework.cassandra.test.integration.support.IntegrationTestNettyOptions; -import org.springframework.test.util.ReflectionTestUtils; - -import com.datastax.driver.core.ProtocolVersion; - -/** - * Unit tests for {@link CassandraCqlClusterFactoryBean}. - * - * @author Kirk Clemens - * @author Mark Paluch - */ -public class CassandraCqlClusterFactoryBeanIntegrationTests { - - private CassandraCqlClusterFactoryBean cassandraCqlClusterFactoryBean; - - @Before - public void setUp() throws Exception { - cassandraCqlClusterFactoryBean = new CassandraCqlClusterFactoryBean(); - } - - @After - public void tearDown() throws Exception { - cassandraCqlClusterFactoryBean.destroy(); - } - - @Test - public void configuredProtocolVersionShouldBeSet() throws Exception { - - cassandraCqlClusterFactoryBean.setNettyOptions(IntegrationTestNettyOptions.INSTANCE); - cassandraCqlClusterFactoryBean.setProtocolVersion(ProtocolVersion.V2); - cassandraCqlClusterFactoryBean.afterPropertiesSet(); - - assertThat(getProtocolVersionEnum(cassandraCqlClusterFactoryBean)).isEqualTo(ProtocolVersion.V2); - } - - @Test - public void defaultProtocolVersionShouldBeSet() throws Exception { - - cassandraCqlClusterFactoryBean.afterPropertiesSet(); - - assertThat(getProtocolVersionEnum(cassandraCqlClusterFactoryBean)).isNull(); - } - - private ProtocolVersion getProtocolVersionEnum(CassandraCqlClusterFactoryBean cassandraCqlClusterFactoryBean) - throws Exception { - - // initialize connection factory - return (ProtocolVersion) ReflectionTestUtils.getField( - cassandraCqlClusterFactoryBean.getObject().getConfiguration().getProtocolOptions(), "initialProtocolVersion"); - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/AbstractIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/AbstractIntegrationTest.java deleted file mode 100755 index 8e16bd333..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/AbstractIntegrationTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2013-2017 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.cassandra.test.integration.config.java; - -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.datastax.driver.core.Session; - -/** - * Base class for Cassandra integration tests. - * - * @author Matthew T. Adams - * @author Mark Paluch - */ -@RunWith(SpringJUnit4ClassRunner.class) -public abstract class AbstractIntegrationTest extends AbstractEmbeddedCassandraIntegrationTest { - - @Autowired protected Session session; -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/Config.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/Config.java deleted file mode 100644 index 11ad80356..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/Config.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013-2017 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.cassandra.test.integration.config.java; - -import org.springframework.cassandra.test.integration.support.AbstractTestJavaConfig; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class Config extends AbstractTestJavaConfig { - - @Override - protected String getKeyspaceName() { - return null; - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/ConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/ConfigIntegrationTests.java deleted file mode 100755 index 57dbe962c..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/ConfigIntegrationTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013-2017 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.cassandra.test.integration.config.java; - -import org.junit.Test; -import org.springframework.test.context.ContextConfiguration; - -/** - * @author Matthew T. Adams - */ -@ContextConfiguration(classes = Config.class) -public class ConfigIntegrationTests extends AbstractIntegrationTest { - - @Test - public void test() { - - session.execute("DROP KEYSPACE IF EXISTS ConfigTest"); - - session.execute("CREATE KEYSPACE ConfigTest " + "WITH " - + "REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"); - - session.execute("USE ConfigTest"); - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfig.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfig.java deleted file mode 100644 index 6f801537c..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013-2017 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.cassandra.test.integration.config.java; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.cassandra.config.KeyspaceAttributes; -import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification; -import org.springframework.cassandra.core.keyspace.KeyspaceOption; -import org.springframework.cassandra.test.integration.support.AbstractTestJavaConfig; -import org.springframework.context.annotation.Configuration; - -/** - * @author Matthew T. Adams - * @author Mark Paluch - */ -@Configuration -public class KeyspaceCreatingJavaConfig extends AbstractTestJavaConfig { - - public static final String KEYSPACE_NAME = "foo"; - - @Override - protected String getKeyspaceName() { - return KEYSPACE_NAME; - } - - @Override - protected List getKeyspaceCreations() { - ArrayList list = new ArrayList<>(); - - CreateKeyspaceSpecification specification = CreateKeyspaceSpecification.createKeyspace().name(getKeyspaceName()); - specification.with(KeyspaceOption.REPLICATION, KeyspaceAttributes.newSimpleReplication(1L)); - - list.add(specification); - return list; - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfigIntegrationTests.java deleted file mode 100755 index 68517b63e..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfigIntegrationTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013-2017 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.cassandra.test.integration.config.java; - -import static org.assertj.core.api.Assertions.*; - -import org.junit.Test; -import org.springframework.cassandra.test.integration.config.IntegrationTestUtils; -import org.springframework.test.context.ContextConfiguration; - -/** - * @author Matthew T. Adams - */ -@ContextConfiguration(classes = KeyspaceCreatingJavaConfig.class) -public class KeyspaceCreatingJavaConfigIntegrationTests extends AbstractIntegrationTest { - - @Test - public void test() { - assertThat(session).isNotNull(); - IntegrationTestUtils.assertKeyspaceExists(KeyspaceCreatingJavaConfig.KEYSPACE_NAME, session); - - session.execute("DROP KEYSPACE " + KeyspaceCreatingJavaConfig.KEYSPACE_NAME + ";"); - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/Book.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/Book.java deleted file mode 100644 index 73d59cb08..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/Book.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2016-2017 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.cassandra.test.integration.core; - -/** - * Test POJO - * - * @author David Webb - */ -public class Book { - - private String isbn; - - private String title; - private String author; - private int pages; - - /** - * @return Returns the isbn. - */ - public String getIsbn() { - return isbn; - } - - /** - * @param isbn The isbn to set. - */ - public void setIsbn(String isbn) { - this.isbn = isbn; - } - - /** - * @return Returns the title. - */ - public String getTitle() { - return title; - } - - /** - * @param title The title to set. - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * @return Returns the author. - */ - public String getAuthor() { - return author; - } - - /** - * @param author The author to set. - */ - public void setAuthor(String author) { - this.author = author; - } - - /** - * @return Returns the pages. - */ - public int getPages() { - return pages; - } - - /** - * @param pages The pages to set. - */ - public void setPages(int pages) { - this.pages = pages; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("isbn -> " + isbn).append("\n"); - sb.append("tile -> " + title).append("\n"); - sb.append("author -> " + author).append("\n"); - sb.append("pages -> " + pages).append("\n"); - return sb.toString(); - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/BookListener.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/BookListener.java deleted file mode 100644 index 5ee55d496..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/BookListener.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2016-2017 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.cassandra.test.integration.core; - -import org.springframework.cassandra.core.AsynchronousQueryListener; -import org.springframework.cassandra.test.integration.support.CallbackSynchronizationSupport; - -import com.datastax.driver.core.ResultSetFuture; -import com.datastax.driver.core.Row; - -/** - * Test Implementation of the {@link AsynchronousQueryListener} - * - * @author David Webb - * @author Matthew T. Adams - * @author Mark Paluch - */ -public class BookListener extends CallbackSynchronizationSupport implements AsynchronousQueryListener { - - private Book book; - private boolean done; - - @Override - public void onQueryComplete(ResultSetFuture resultSetFuture) { - - Row row; - - try { - row = resultSetFuture.get().one(); - } catch (Exception e) { - throw new RuntimeException("Failed to get ResultSet from ResultSetFuture", e); - } - - book = new Book(); - book.setIsbn(row.getString("isbn")); - book.setTitle(row.getString("title")); - book.setAuthor(row.getString("author")); - book.setPages(row.getInt("pages")); - - done = true; - - countDown(); - } - - /** - * @return Returns the done. - */ - public boolean isDone() { - return done; - } - - /** - * @return Returns the book. - */ - public Book getBook() { - return book; - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CallbackSynchronizationSupport.java b/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CallbackSynchronizationSupport.java deleted file mode 100644 index 82011dd40..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/cassandra/test/integration/support/CallbackSynchronizationSupport.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2016-2017 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.cassandra.test.integration.support; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.springframework.util.Assert; - -/** - * Convenient listener base class that includes a {@link CountDownLatch} in order to test asynchronous behavior. This - * class can be extended - * - * @author Matthew T. Adams - * @author Mark Paluch - */ -public abstract class CallbackSynchronizationSupport { - - private final CountDownLatch latch; - - /** - * Create a new {@link CallbackSynchronizationSupport} - */ - protected CallbackSynchronizationSupport() { - this(1); - } - - /** - * Create a new {@link CallbackSynchronizationSupport} for a given {@code latchCount} of callbacks. - * - * @param latchCount {@link CallbackSynchronizationSupport} for a given {@code latchCount} of callbacks - */ - protected CallbackSynchronizationSupport(int latchCount) { - latch = new CountDownLatch(latchCount); - } - - /** - * Await results without a timeout. - * - * @throws InterruptedException - */ - public final void await() throws InterruptedException { - latch.await(); - } - - /** - * Await the results with a timeout. - * - * @param timeout must be greater or equal to 0 - * @param timeUnit must not be {@literal null}. - * @throws InterruptedException - */ - public final void await(long timeout, TimeUnit timeUnit) throws InterruptedException { - - Assert.isTrue(timeout >= 0, "Timeout must be greater or equal to 0"); - Assert.notNull(timeUnit, "TimeUnit must not be null"); - - latch.await(timeout, timeUnit); - } - - /** - * Indicate an incoming event and count down the latch by {@literal 1}. - */ - protected final void countDown() { - latch.countDown(); - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java index 4139e3b43..4248e144b 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java @@ -20,21 +20,22 @@ import static org.assertj.core.api.Assertions.*; import java.util.Collections; import java.util.List; +import java.util.Set; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.beans.factory.BeanCreationException; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.cassandra.KeyspaceRule; import org.springframework.cassandra.config.CassandraCqlClusterFactoryBean; import org.springframework.cassandra.core.SessionCallback; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.cassandra.test.integration.KeyspaceRule; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.config.java.AbstractCassandraConfiguration; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; +import org.springframework.data.cassandra.domain.Person; import com.datastax.driver.core.Cluster; import com.datastax.driver.core.KeyspaceMetadata; @@ -232,8 +233,8 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg } @Override - public String[] getEntityBasePackages() { - return new String[] { Person.class.getPackage().getName() }; + protected Set> getInitialEntitySet() throws ClassNotFoundException { + return Collections.singleton(Person.class); } @Override diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/xml/CassandraNamespaceIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/xml/CassandraNamespaceIntegrationTests.java index f6521f4f4..4d0194ff1 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/xml/CassandraNamespaceIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/xml/CassandraNamespaceIntegrationTests.java @@ -25,7 +25,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.data.cassandra.core.CassandraTemplate; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.SimpleUserTypeResolver; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.util.ReflectionTestUtils; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/CassandraTypeMappingIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/CassandraTypeMappingIntegrationTest.java index 1939180f6..71afde895 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/CassandraTypeMappingIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/CassandraTypeMappingIntegrationTest.java @@ -36,13 +36,13 @@ import org.assertj.core.api.Assertions; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; -import org.springframework.cassandra.test.integration.support.CassandraVersion; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.support.CassandraVersion; import org.springframework.data.annotation.Id; import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.core.CassandraTemplate; import org.springframework.data.cassandra.domain.AllPossibleTypes; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.util.Version; import com.datastax.driver.core.Duration; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/CustomConversionIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/CustomConversionIntegrationTests.java index 76f8901d6..4d0bb1c97 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/CustomConversionIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/CustomConversionIntegrationTests.java @@ -30,13 +30,13 @@ import java.util.Set; import org.junit.Before; import org.junit.Test; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.core.convert.converter.Converter; import org.springframework.data.annotation.Id; import org.springframework.data.cassandra.core.CassandraTemplate; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.Table; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.convert.CustomConversions; import org.springframework.util.StringUtils; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUDTIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUDTIntegrationTests.java index 928fda7ea..1db5fac9f 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUDTIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUDTIntegrationTests.java @@ -42,8 +42,8 @@ import org.springframework.data.cassandra.mapping.SimpleUserTypeResolver; import org.springframework.data.cassandra.mapping.Table; import org.springframework.data.cassandra.mapping.UserDefinedType; import org.springframework.data.cassandra.mapping.UserTypeResolver; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.data.convert.CustomConversions; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUnitTests.java index 09ebaf1f6..b00ee7b41 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/convert/MappingCassandraConverterUnitTests.java @@ -54,10 +54,10 @@ import org.springframework.core.SpringVersion; import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.data.cassandra.RowMockUtil; import org.springframework.data.cassandra.domain.CompositeKey; -import org.springframework.data.cassandra.domain.Person; import org.springframework.data.cassandra.domain.TypeWithCompositeKey; import org.springframework.data.cassandra.domain.TypeWithKeyClass; import org.springframework.data.cassandra.domain.TypeWithMapId; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.domain.UserToken; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.CassandraMappingContext; @@ -674,7 +674,7 @@ public class MappingCassandraConverterUnitTests { Delete delete = QueryBuilder.delete().from("table"); - mappingCassandraConverter.write("42", delete.where(), mappingContext.getRequiredPersistentEntity(Person.class)); + mappingCassandraConverter.write("42", delete.where(), mappingContext.getRequiredPersistentEntity(User.class)); assertThat(getWherePredicates(delete)).containsEntry("id", "42"); } @@ -684,10 +684,10 @@ public class MappingCassandraConverterUnitTests { Delete delete = QueryBuilder.delete().from("table"); - Person person = new Person(); - person.setId("42"); + User user = new User(); + user.setId("42"); - mappingCassandraConverter.write(person, delete.where(), mappingContext.getRequiredPersistentEntity(Person.class)); + mappingCassandraConverter.write(user, delete.where(), mappingContext.getRequiredPersistentEntity(User.class)); assertThat(getWherePredicates(delete)).containsEntry("id", "42"); } @@ -697,8 +697,7 @@ public class MappingCassandraConverterUnitTests { Delete delete = QueryBuilder.delete().from("table"); - mappingCassandraConverter.write(new Person(), delete.where(), - mappingContext.getRequiredPersistentEntity(Person.class)); + mappingCassandraConverter.write(new User(), delete.where(), mappingContext.getRequiredPersistentEntity(User.class)); } @Test // DATACASS-308 @@ -707,7 +706,7 @@ public class MappingCassandraConverterUnitTests { Delete delete = QueryBuilder.delete().from("table"); mappingCassandraConverter.write(id("id", "42"), delete.where(), - mappingContext.getRequiredPersistentEntity(Person.class)); + mappingContext.getRequiredPersistentEntity(User.class)); assertThat(getWherePredicates(delete)).containsEntry("id", "42"); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateIntegrationTests.java index b750bfb5f..e0af81f22 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateIntegrationTests.java @@ -21,16 +21,16 @@ import java.util.concurrent.Future; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.AsyncCqlTemplate; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.query.Columns; import org.springframework.data.cassandra.core.query.Criteria; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.core.query.Update; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.domain.UserToken; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.domain.Sort; import org.springframework.util.concurrent.ListenableFuture; @@ -52,9 +52,9 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea CassandraTemplate cassandraTemplate = new CassandraTemplate(session, converter); template = new AsyncCassandraTemplate(new AsyncCqlTemplate(session), converter); - SchemaTestUtils.potentiallyCreateTableFor(Person.class, cassandraTemplate); + SchemaTestUtils.potentiallyCreateTableFor(User.class, cassandraTemplate); SchemaTestUtils.potentiallyCreateTableFor(UserToken.class, cassandraTemplate); - SchemaTestUtils.truncate(Person.class, cassandraTemplate); + SchemaTestUtils.truncate(User.class, cassandraTemplate); SchemaTestUtils.truncate(UserToken.class, cassandraTemplate); } @@ -97,78 +97,78 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea @Test // DATACASS-292 public void insertShouldInsertEntity() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isNull(); + assertThat(getUninterruptibly(template.selectOneById(user.getId(), User.class))).isNull(); - ListenableFuture insert = template.insert(person); + ListenableFuture insert = template.insert(user); - assertThat(getUninterruptibly(insert)).isEqualTo(person); - assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isEqualTo(person); + assertThat(getUninterruptibly(insert)).isEqualTo(user); + assertThat(getUninterruptibly(template.selectOneById(user.getId(), User.class))).isEqualTo(user); } @Test // DATACASS-292 public void shouldInsertAndCountEntities() throws Exception { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - getUninterruptibly(template.insert(person)); + getUninterruptibly(template.insert(user)); - ListenableFuture count = template.count(Person.class); + ListenableFuture count = template.count(User.class); assertThat(getUninterruptibly(count)).isEqualTo(1L); } @Test // DATACASS-292 public void updateShouldUpdateEntity() throws Exception { - Person person = new Person("heisenberg", "Walter", "White"); - getUninterruptibly(template.insert(person)); + User user = new User("heisenberg", "Walter", "White"); + getUninterruptibly(template.insert(user)); - person.setFirstname("Walter Hartwell"); - Person updated = getUninterruptibly(template.update(person)); + user.setFirstname("Walter Hartwell"); + User updated = getUninterruptibly(template.update(user)); assertThat(updated).isNotNull(); - assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isEqualTo(person); + assertThat(getUninterruptibly(template.selectOneById(user.getId(), User.class))).isEqualTo(user); } @Test // DATACASS-343 public void updateShouldUpdateEntityByQuery() throws Exception { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person).get(); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user).get(); Query query = Query.query(Criteria.where("id").is("heisenberg")); boolean result = getUninterruptibly( - template.update(query, Update.empty().set("firstname", "Walter Hartwell"), Person.class)); + template.update(query, Update.empty().set("firstname", "Walter Hartwell"), User.class)); assertThat(result).isTrue(); - assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class)).getFirstname()) + assertThat(getUninterruptibly(template.selectOneById(user.getId(), User.class)).getFirstname()) .isEqualTo("Walter Hartwell"); } @Test // DATACASS-343 public void deleteByQueryShouldRemoveEntity() throws Exception { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person).get(); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user).get(); Query query = Query.query(Criteria.where("id").is("heisenberg")); - assertThat(getUninterruptibly(template.delete(query, Person.class))).isTrue(); + assertThat(getUninterruptibly(template.delete(query, User.class))).isTrue(); - assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isNull(); + assertThat(getUninterruptibly(template.selectOneById(user.getId(), User.class))).isNull(); } @Test // DATACASS-343 public void deleteColumnsByQueryShouldRemoveColumn() throws Exception { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person).get(); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user).get(); Query query = Query.query(Criteria.where("id").is("heisenberg")).columns(Columns.from("lastname")); - assertThat(getUninterruptibly(template.delete(query, Person.class))).isTrue(); + assertThat(getUninterruptibly(template.delete(query, User.class))).isTrue(); - Person loaded = getUninterruptibly(template.selectOneById(person.getId(), Person.class)); + User loaded = getUninterruptibly(template.selectOneById(user.getId(), User.class)); assertThat(loaded.getFirstname()).isEqualTo("Walter"); assertThat(loaded.getLastname()).isNull(); } @@ -176,25 +176,25 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea @Test // DATACASS-292 public void deleteShouldRemoveEntity() throws Exception { - Person person = new Person("heisenberg", "Walter", "White"); - getUninterruptibly(template.insert(person)); + User user = new User("heisenberg", "Walter", "White"); + getUninterruptibly(template.insert(user)); - Person deleted = getUninterruptibly(template.delete(person)); + User deleted = getUninterruptibly(template.delete(user)); assertThat(deleted).isNotNull(); - assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isNull(); + assertThat(getUninterruptibly(template.selectOneById(user.getId(), User.class))).isNull(); } @Test // DATACASS-292 public void deleteByIdShouldRemoveEntity() throws Exception { - Person person = new Person("heisenberg", "Walter", "White"); - getUninterruptibly(template.insert(person)); + User user = new User("heisenberg", "Walter", "White"); + getUninterruptibly(template.insert(user)); - Boolean deleted = getUninterruptibly(template.deleteById(person.getId(), Person.class)); + Boolean deleted = getUninterruptibly(template.deleteById(user.getId(), User.class)); assertThat(deleted).isTrue(); - assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isNull(); + assertThat(getUninterruptibly(template.selectOneById(user.getId(), User.class))).isNull(); } private static T getUninterruptibly(Future future) { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateUnitTests.java index 35509c135..aa05dd5be 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateUnitTests.java @@ -37,7 +37,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.cassandra.support.exception.CassandraConnectionFailureException; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; import org.springframework.util.concurrent.ListenableFuture; import com.datastax.driver.core.ColumnDefinitions; @@ -71,6 +71,7 @@ public class AsyncCassandraTemplateUnitTests { public void setUp() { template = new AsyncCassandraTemplate(session); + when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet)); when(row.getColumnDefinitions()).thenReturn(columnDefinitions); } @@ -90,11 +91,11 @@ public class AsyncCassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - ListenableFuture> list = template.select("SELECT * FROM person", Person.class); + ListenableFuture> list = template.select("SELECT * FROM users", User.class); - assertThat(getUninterruptibly(list)).hasSize(1).contains(new Person("myid", "Walter", "White")); + assertThat(getUninterruptibly(list)).hasSize(1).contains(new User("myid", "Walter", "White")); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users"); } @Test // DATACASS-292 @@ -112,14 +113,14 @@ public class AsyncCassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - List list = new ArrayList<>(); + List list = new ArrayList<>(); - ListenableFuture result = template.select("SELECT * FROM person", list::add, Person.class); + ListenableFuture result = template.select("SELECT * FROM users", list::add, User.class); assertThat(getUninterruptibly(result)).isNull(); - assertThat(list).hasSize(1).contains(new Person("myid", "Walter", "White")); + assertThat(list).hasSize(1).contains(new User("myid", "Walter", "White")); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users"); } @Test // DATACASS-292 @@ -127,7 +128,7 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.iterator()).thenThrow(new NoHostAvailableException(Collections.emptyMap())); - ListenableFuture> list = template.select("SELECT * FROM person", Person.class); + ListenableFuture> list = template.select("SELECT * FROM users", User.class); try { list.get(); @@ -154,11 +155,11 @@ public class AsyncCassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - ListenableFuture future = template.selectOne("SELECT * FROM person WHERE id='myid';", Person.class); + ListenableFuture future = template.selectOne("SELECT * FROM users WHERE id='myid';", User.class); - assertThat(getUninterruptibly(future)).isEqualTo(new Person("myid", "Walter", "White")); + assertThat(getUninterruptibly(future)).isEqualTo(new User("myid", "Walter", "White")); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-292 @@ -176,11 +177,11 @@ public class AsyncCassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - ListenableFuture future = template.selectOneById("myid", Person.class); + ListenableFuture future = template.selectOneById("myid", User.class); - assertThat(getUninterruptibly(future)).isEqualTo(new Person("myid", "Walter", "White")); + assertThat(getUninterruptibly(future)).isEqualTo(new User("myid", "Walter", "White")); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-292 @@ -188,11 +189,11 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); - ListenableFuture future = template.exists("myid", Person.class); + ListenableFuture future = template.exists("myid", User.class); assertThat(getUninterruptibly(future)).isTrue(); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-292 @@ -200,11 +201,11 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.iterator()).thenReturn(Collections.emptyIterator()); - ListenableFuture future = template.exists("myid", Person.class); + ListenableFuture future = template.exists("myid", User.class); assertThat(getUninterruptibly(future)).isFalse(); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-292 @@ -214,11 +215,11 @@ public class AsyncCassandraTemplateUnitTests { when(row.getLong(0)).thenReturn(42L); when(columnDefinitions.size()).thenReturn(1); - ListenableFuture future = template.count(Person.class); + ListenableFuture future = template.count(User.class); assertThat(getUninterruptibly(future)).isEqualTo(42L); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM person;"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM users;"); } @Test // DATACASS-292 @@ -226,14 +227,14 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - ListenableFuture future = template.insert(person); + ListenableFuture future = template.insert(user); - assertThat(getUninterruptibly(future)).isEqualTo(person); + assertThat(getUninterruptibly(future)).isEqualTo(user); verify(session).executeAsync(statementCaptor.capture()); assertThat(statementCaptor.getValue().toString()) - .isEqualTo("INSERT INTO person (firstname,id,lastname) VALUES ('Walter','heisenberg','White');"); + .isEqualTo("INSERT INTO users (firstname,id,lastname) VALUES ('Walter','heisenberg','White');"); } @Test // DATACASS-292 @@ -243,7 +244,7 @@ public class AsyncCassandraTemplateUnitTests { when(session.executeAsync(any(Statement.class))) .thenReturn(TestResultSetFuture.failed(new NoHostAvailableException(Collections.emptyMap()))); - ListenableFuture future = template.insert(new Person("heisenberg", "Walter", "White")); + ListenableFuture future = template.insert(new User("heisenberg", "Walter", "White")); try { future.get(); @@ -260,9 +261,9 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - ListenableFuture future = template.insert(person); + ListenableFuture future = template.insert(user); assertThat(getUninterruptibly(future)).isNull(); } @@ -272,14 +273,14 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - ListenableFuture future = template.update(person); + ListenableFuture future = template.update(user); - assertThat(getUninterruptibly(future)).isEqualTo(person); + assertThat(getUninterruptibly(future)).isEqualTo(user); verify(session).executeAsync(statementCaptor.capture()); assertThat(statementCaptor.getValue().toString()) - .isEqualTo("UPDATE person SET firstname='Walter',lastname='White' WHERE id='heisenberg';"); + .isEqualTo("UPDATE users SET firstname='Walter',lastname='White' WHERE id='heisenberg';"); } @Test // DATACASS-292 @@ -289,7 +290,7 @@ public class AsyncCassandraTemplateUnitTests { when(session.executeAsync(any(Statement.class))) .thenReturn(TestResultSetFuture.failed(new NoHostAvailableException(Collections.emptyMap()))); - ListenableFuture future = template.update(new Person("heisenberg", "Walter", "White")); + ListenableFuture future = template.update(new User("heisenberg", "Walter", "White")); try { future.get(); @@ -306,9 +307,9 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - ListenableFuture future = template.update(person); + ListenableFuture future = template.update(user); assertThat(getUninterruptibly(future)).isNull(); } @@ -318,13 +319,13 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - ListenableFuture future = template.deleteById(person.getId(), Person.class); + ListenableFuture future = template.deleteById(user.getId(), User.class); assertThat(getUninterruptibly(future)).isTrue(); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM users WHERE id='heisenberg';"); } @Test // DATACASS-292 @@ -332,13 +333,13 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - ListenableFuture future = template.delete(person); + ListenableFuture future = template.delete(user); - assertThat(getUninterruptibly(future)).isEqualTo(person); + assertThat(getUninterruptibly(future)).isEqualTo(user); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM users WHERE id='heisenberg';"); } @Test // DATACASS-292 @@ -348,7 +349,7 @@ public class AsyncCassandraTemplateUnitTests { when(session.executeAsync(any(Statement.class))) .thenReturn(TestResultSetFuture.failed(new NoHostAvailableException(Collections.emptyMap()))); - ListenableFuture future = template.delete(new Person("heisenberg", "Walter", "White")); + ListenableFuture future = template.delete(new User("heisenberg", "Walter", "White")); try { future.get(); @@ -365,9 +366,9 @@ public class AsyncCassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - ListenableFuture future = template.delete(person); + ListenableFuture future = template.delete(user); assertThat(getUninterruptibly(future)).isNull(); } @@ -375,10 +376,10 @@ public class AsyncCassandraTemplateUnitTests { @Test // DATACASS-292 public void truncateShouldRemoveEntities() { - template.truncate(Person.class); + template.truncate(User.class); verify(session).executeAsync(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("TRUNCATE person;"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("TRUNCATE users;"); } private static T getUninterruptibly(Future future) { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraAdminTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraAdminTemplateIntegrationTests.java index e6442842b..953602943 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraAdminTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraAdminTemplateIntegrationTests.java @@ -21,12 +21,12 @@ import java.util.Collection; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.cql.CqlIdentifier; import org.springframework.cassandra.core.cql.generator.DropTableCqlGenerator; import org.springframework.cassandra.core.keyspace.DropTableSpecification; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.data.cassandra.convert.MappingCassandraConverter; -import org.springframework.data.cassandra.test.integration.simpletons.Book; +import org.springframework.data.cassandra.domain.User; import com.datastax.driver.core.KeyspaceMetadata; import com.datastax.driver.core.Metadata; @@ -60,28 +60,28 @@ public class CassandraAdminTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-173 - public void testCreateTables() throws Exception { + public void testCreateTables() { assertThat(getKeyspaceMetadata().getTables()).hasSize(0); - cassandraAdminTemplate.createTable(true, CqlIdentifier.cqlId("book"), Book.class, null); + cassandraAdminTemplate.createTable(true, CqlIdentifier.cqlId("users"), User.class, null); assertThat(getKeyspaceMetadata().getTables()).hasSize(1); - cassandraAdminTemplate.createTable(true, CqlIdentifier.cqlId("book"), Book.class, null); + cassandraAdminTemplate.createTable(true, CqlIdentifier.cqlId("users"), User.class, null); assertThat(getKeyspaceMetadata().getTables()).hasSize(1); } @Test - public void testDropTable() throws Exception { + public void testDropTable() { - cassandraAdminTemplate.createTable(true, CqlIdentifier.cqlId("book"), Book.class, null); + cassandraAdminTemplate.createTable(true, CqlIdentifier.cqlId("users"), User.class, null); assertThat(getKeyspaceMetadata().getTables()).hasSize(1); - cassandraAdminTemplate.dropTable(Book.class); + cassandraAdminTemplate.dropTable(User.class); assertThat(getKeyspaceMetadata().getTables()).hasSize(0); - cassandraAdminTemplate.createTable(true, CqlIdentifier.cqlId("book"), Book.class, null); - cassandraAdminTemplate.dropTable(CqlIdentifier.cqlId("book")); + cassandraAdminTemplate.createTable(true, CqlIdentifier.cqlId("users"), User.class, null); + cassandraAdminTemplate.dropTable(CqlIdentifier.cqlId("users")); assertThat(getKeyspaceMetadata().getTables()).hasSize(0); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraBatchTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraBatchTemplateIntegrationTests.java index 67b3fca7d..bb1840a2a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraBatchTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraBatchTemplateIntegrationTests.java @@ -23,11 +23,11 @@ import java.util.concurrent.TimeUnit; import org.junit.Before; import org.junit.Test; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.data.cassandra.domain.FlatGroup; import org.springframework.data.cassandra.domain.Group; import org.springframework.data.cassandra.domain.GroupKey; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java index 5ff7ff9e1..382fa4646 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java @@ -26,19 +26,19 @@ import java.util.stream.Stream; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.CqlTemplate; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; -import org.springframework.cassandra.test.integration.support.CassandraVersion; +import org.springframework.cassandra.support.CassandraVersion; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.query.Columns; import org.springframework.data.cassandra.core.query.Criteria; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.core.query.Update; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.BookReference; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.domain.UserToken; import org.springframework.data.cassandra.repository.support.BasicMapId; -import org.springframework.data.cassandra.test.integration.simpletons.BookReference; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.domain.Sort; import org.springframework.data.util.Version; @@ -67,10 +67,10 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI template = new CassandraTemplate(new CqlTemplate(session), converter); - SchemaTestUtils.potentiallyCreateTableFor(Person.class, template); + SchemaTestUtils.potentiallyCreateTableFor(User.class, template); SchemaTestUtils.potentiallyCreateTableFor(UserToken.class, template); SchemaTestUtils.potentiallyCreateTableFor(BookReference.class, template); - SchemaTestUtils.truncate(Person.class, template); + SchemaTestUtils.truncate(User.class, template); SchemaTestUtils.truncate(UserToken.class, template); SchemaTestUtils.truncate(BookReference.class, template); } @@ -136,77 +136,77 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI @Test // DATACASS-292 public void insertShouldInsertEntity() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - assertThat(template.selectOneById(person.getId(), Person.class)).isNull(); + assertThat(template.selectOneById(user.getId(), User.class)).isNull(); - Person inserted = template.insert(person); + User inserted = template.insert(user); - assertThat(inserted).isEqualTo(person); - assertThat(template.selectOneById(person.getId(), Person.class)).isEqualTo(person); + assertThat(inserted).isEqualTo(user); + assertThat(template.selectOneById(user.getId(), User.class)).isEqualTo(user); } @Test // DATACASS-292 public void shouldInsertAndCountEntities() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - template.insert(person); + template.insert(user); - long count = template.count(Person.class); + long count = template.count(User.class); assertThat(count).isEqualTo(1L); } @Test // DATACASS-292 public void updateShouldUpdateEntity() { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user); - person.setFirstname("Walter Hartwell"); + user.setFirstname("Walter Hartwell"); - Person updated = template.update(person); + User updated = template.update(user); assertThat(updated).isNotNull(); - assertThat(template.selectOneById(person.getId(), Person.class)).isEqualTo(person); + assertThat(template.selectOneById(user.getId(), User.class)).isEqualTo(user); } @Test // DATACASS-343 public void updateShouldUpdateEntityByQuery() { - Person person = new Person("heisenberg", "Walter", "White"); + User person = new User("heisenberg", "Walter", "White"); template.insert(person); Query query = Query.query(Criteria.where("id").is("heisenberg")); - boolean result = template.update(query, Update.empty().set("firstname", "Walter Hartwell"), Person.class); + boolean result = template.update(query, Update.empty().set("firstname", "Walter Hartwell"), User.class); assertThat(result).isTrue(); - assertThat(template.selectOneById(person.getId(), Person.class).getFirstname()).isEqualTo("Walter Hartwell"); + assertThat(template.selectOneById(person.getId(), User.class).getFirstname()).isEqualTo("Walter Hartwell"); } @Test // DATACASS-343 public void deleteByQueryShouldRemoveEntity() { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user); Query query = Query.query(Criteria.where("id").is("heisenberg")); - assertThat(template.delete(query, Person.class)).isTrue(); + assertThat(template.delete(query, User.class)).isTrue(); - assertThat(template.selectOneById(person.getId(), Person.class)).isNull(); + assertThat(template.selectOneById(user.getId(), User.class)).isNull(); } @Test // DATACASS-343 public void deleteColumnsByQueryShouldRemoveColumn() { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user); Query query = Query.query(Criteria.where("id").is("heisenberg")).columns(Columns.from("lastname")); - assertThat(template.delete(query, Person.class)).isTrue(); + assertThat(template.delete(query, User.class)).isTrue(); - Person loaded = template.selectOneById(person.getId(), Person.class); + User loaded = template.selectOneById(user.getId(), User.class); assertThat(loaded.getFirstname()).isEqualTo("Walter"); assertThat(loaded.getLastname()).isNull(); } @@ -214,47 +214,47 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI @Test // DATACASS-292 public void deleteShouldRemoveEntity() { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user); - Person deleted = template.delete(person); + User deleted = template.delete(user); assertThat(deleted).isNotNull(); - assertThat(template.selectOneById(person.getId(), Person.class)).isNull(); + assertThat(template.selectOneById(user.getId(), User.class)).isNull(); } @Test // DATACASS-292 public void deleteByIdShouldRemoveEntity() { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user); - Boolean deleted = template.deleteById(person.getId(), Person.class); + Boolean deleted = template.deleteById(user.getId(), User.class); assertThat(deleted).isTrue(); - assertThat(template.selectOneById(person.getId(), Person.class)).isNull(); + assertThat(template.selectOneById(user.getId(), User.class)).isNull(); } @Test // DATACASS-182 public void stream() { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user); - Stream stream = template.stream("SELECT * FROM person", Person.class); + Stream stream = template.stream("SELECT * FROM users", User.class); - assertThat(stream.collect(Collectors.toList())).hasSize(1).contains(person); + assertThat(stream.collect(Collectors.toList())).hasSize(1).contains(user); } @Test // DATACASS-343 public void streamByQuery() { - Person person = new Person("heisenberg", "Walter", "White"); + User person = new User("heisenberg", "Walter", "White"); template.insert(person); Query query = Query.query(Criteria.where("id").is("heisenberg")); - Stream stream = template.stream(query, Person.class); + Stream stream = template.stream(query, User.class); assertThat(stream.collect(Collectors.toList())).hasSize(1).contains(person); } @@ -262,14 +262,14 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI @Test // DATACASS-182 public void updateShouldRemoveFields() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - template.insert(person); + template.insert(user); - person.setFirstname(null); - template.update(person); + user.setFirstname(null); + template.update(user); - Person loaded = template.selectOneById(person.getId(), Person.class); + User loaded = template.selectOneById(user.getId(), User.class); assertThat(loaded.getFirstname()).isNull(); assertThat(loaded.getId()).isEqualTo("heisenberg"); @@ -278,14 +278,14 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI @Test // DATACASS-182, DATACASS-420 public void insertShouldNotRemoveFields() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - template.insert(person); + template.insert(user); - person.setFirstname(null); - template.insert(person); + user.setFirstname(null); + template.insert(user); - Person loaded = template.selectOneById(person.getId(), Person.class); + User loaded = template.selectOneById(user.getId(), User.class); assertThat(loaded.getFirstname()).isEqualTo("Walter"); assertThat(loaded.getId()).isEqualTo("heisenberg"); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateUnitTests.java index 404b5ad50..4ea53c16e 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateUnitTests.java @@ -34,9 +34,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.cassandra.support.exception.CassandraConnectionFailureException; -import org.springframework.data.cassandra.convert.MappingCassandraConverter; -import org.springframework.data.cassandra.domain.Person; -import org.springframework.data.cassandra.test.integration.simpletons.Book; +import org.springframework.data.cassandra.domain.User; import com.datastax.driver.core.ColumnDefinitions; import com.datastax.driver.core.DataType; @@ -67,7 +65,8 @@ public class CassandraTemplateUnitTests { @Before public void setUp() { - template = new CassandraTemplate(session, new MappingCassandraConverter()); + template = new CassandraTemplate(session); + when(session.execute(any(Statement.class))).thenReturn(resultSet); when(row.getColumnDefinitions()).thenReturn(columnDefinitions); } @@ -87,11 +86,11 @@ public class CassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - List list = template.select("SELECT * FROM person", Person.class); + List list = template.select("SELECT * FROM users", User.class); - assertThat(list).hasSize(1).contains(new Person("myid", "Walter", "White")); + assertThat(list).hasSize(1).contains(new User("myid", "Walter", "White")); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users"); } @Test // DATACASS-292 @@ -100,7 +99,7 @@ public class CassandraTemplateUnitTests { when(resultSet.iterator()).thenThrow(new NoHostAvailableException(Collections.emptyMap())); try { - template.select("SELECT * FROM person", Person.class); + template.select("SELECT * FROM users", User.class); fail("Missing CassandraConnectionFailureException"); } catch (CassandraConnectionFailureException e) { @@ -123,11 +122,11 @@ public class CassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - Person person = template.selectOne("SELECT * FROM person WHERE id='myid';", Person.class); + User user = template.selectOne("SELECT * FROM users WHERE id='myid';", User.class); - assertThat(person).isEqualTo(new Person("myid", "Walter", "White")); + assertThat(user).isEqualTo(new User("myid", "Walter", "White")); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-292 @@ -145,11 +144,11 @@ public class CassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - Person person = template.selectOneById("myid", Person.class); + User user = template.selectOneById("myid", User.class); - assertThat(person).isEqualTo(new Person("myid", "Walter", "White")); + assertThat(user).isEqualTo(new User("myid", "Walter", "White")); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-292 @@ -157,11 +156,11 @@ public class CassandraTemplateUnitTests { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); - boolean exists = template.exists("myid", Person.class); + boolean exists = template.exists("myid", User.class); assertThat(exists).isTrue(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-292 @@ -169,11 +168,11 @@ public class CassandraTemplateUnitTests { when(resultSet.iterator()).thenReturn(Collections.emptyIterator()); - boolean exists = template.exists("myid", Person.class); + boolean exists = template.exists("myid", User.class); assertThat(exists).isFalse(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-292 @@ -183,11 +182,11 @@ public class CassandraTemplateUnitTests { when(row.getLong(0)).thenReturn(42L); when(columnDefinitions.size()).thenReturn(1); - long count = template.count(Person.class); + long count = template.count(User.class); assertThat(count).isEqualTo(42L); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM person;"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM users;"); } @Test // DATACASS-292 @@ -195,14 +194,14 @@ public class CassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - Person inserted = template.insert(person); + User inserted = template.insert(user); - assertThat(inserted).isEqualTo(person); + assertThat(inserted).isEqualTo(user); verify(session).execute(statementCaptor.capture()); assertThat(statementCaptor.getValue().toString()) - .isEqualTo("INSERT INTO person (firstname,id,lastname) VALUES ('Walter','heisenberg','White');"); + .isEqualTo("INSERT INTO users (firstname,id,lastname) VALUES ('Walter','heisenberg','White');"); } @Test // DATACASS-292 @@ -212,7 +211,7 @@ public class CassandraTemplateUnitTests { when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap())); try { - template.insert(new Person("heisenberg", "Walter", "White")); + template.insert(new User("heisenberg", "Walter", "White")); fail("Missing CassandraConnectionFailureException"); } catch (CassandraConnectionFailureException e) { @@ -225,9 +224,9 @@ public class CassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - Person inserted = template.insert(person); + User inserted = template.insert(user); assertThat(inserted).isNull(); } @@ -237,14 +236,14 @@ public class CassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - Person updated = template.update(person); + User updated = template.update(user); - assertThat(updated).isEqualTo(person); + assertThat(updated).isEqualTo(user); verify(session).execute(statementCaptor.capture()); assertThat(statementCaptor.getValue().toString()) - .isEqualTo("UPDATE person SET firstname='Walter',lastname='White' WHERE id='heisenberg';"); + .isEqualTo("UPDATE users SET firstname='Walter',lastname='White' WHERE id='heisenberg';"); } @Test // DATACASS-292 @@ -254,7 +253,7 @@ public class CassandraTemplateUnitTests { when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap())); try { - template.update(new Person("heisenberg", "Walter", "White")); + template.update(new User("heisenberg", "Walter", "White")); fail("Missing CassandraConnectionFailureException"); } catch (CassandraConnectionFailureException e) { @@ -267,9 +266,9 @@ public class CassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - Person updated = template.update(person); + User updated = template.update(user); assertThat(updated).isNull(); } @@ -279,13 +278,13 @@ public class CassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - boolean deleted = template.deleteById(person.getId(), Person.class); + boolean deleted = template.deleteById(user.getId(), User.class); assertThat(deleted).isTrue(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM users WHERE id='heisenberg';"); } @Test // DATACASS-292 @@ -293,13 +292,13 @@ public class CassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - Person deleted = template.delete(person); + User deleted = template.delete(user); - assertThat(deleted).isEqualTo(person); + assertThat(deleted).isEqualTo(user); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM users WHERE id='heisenberg';"); } @Test // DATACASS-292 @@ -309,7 +308,7 @@ public class CassandraTemplateUnitTests { when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap())); try { - template.delete(new Person("heisenberg", "Walter", "White")); + template.delete(new User("heisenberg", "Walter", "White")); fail("Missing CassandraConnectionFailureException"); } catch (CassandraConnectionFailureException e) { @@ -322,9 +321,9 @@ public class CassandraTemplateUnitTests { when(resultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - Person deleted = template.delete(person); + User deleted = template.delete(user); assertThat(deleted).isNull(); } @@ -332,17 +331,17 @@ public class CassandraTemplateUnitTests { @Test // DATACASS-292 public void truncateShouldRemoveEntities() { - template.truncate(Person.class); + template.truncate(User.class); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("TRUNCATE person;"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("TRUNCATE users;"); } @Test // DATACASS-292 @Ignore public void batchOperationsShouldCallSession() { - template.batchOps().insert(new Book()).execute(); + template.batchOps().insert(new User()).execute(); verify(session).execute(Mockito.any(Batch.class)); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java index a17a44eee..25fadb7af 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java @@ -23,17 +23,17 @@ import reactor.test.StepVerifier; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.ReactiveCqlTemplate; import org.springframework.cassandra.core.session.DefaultBridgedReactiveSession; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.query.Columns; import org.springframework.data.cassandra.core.query.Criteria; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.core.query.Update; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.domain.UserToken; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.domain.Sort; import com.datastax.driver.core.utils.UUIDs; @@ -56,87 +56,87 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC template = new ReactiveCassandraTemplate(new ReactiveCqlTemplate(session), converter); - SchemaTestUtils.potentiallyCreateTableFor(Person.class, cassandraTemplate); + SchemaTestUtils.potentiallyCreateTableFor(User.class, cassandraTemplate); SchemaTestUtils.potentiallyCreateTableFor(UserToken.class, cassandraTemplate); - SchemaTestUtils.truncate(Person.class, cassandraTemplate); + SchemaTestUtils.truncate(User.class, cassandraTemplate); SchemaTestUtils.truncate(UserToken.class, cassandraTemplate); } @Test // DATACASS-335 public void insertShouldInsertEntity() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - Mono insert = template.insert(person); - StepVerifier.create(template.selectOneById(person.getId(), Person.class)).verifyComplete(); + Mono insert = template.insert(user); + StepVerifier.create(template.selectOneById(user.getId(), User.class)).verifyComplete(); - StepVerifier.create(insert).expectNext(person).verifyComplete(); + StepVerifier.create(insert).expectNext(user).verifyComplete(); - StepVerifier.create(template.selectOneById(person.getId(), Person.class)).expectNext(person).verifyComplete(); + StepVerifier.create(template.selectOneById(user.getId(), User.class)).expectNext(user).verifyComplete(); } @Test // DATACASS-335 public void shouldInsertAndCountEntities() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.insert(person)).expectNextCount(1).verifyComplete(); + StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete(); - StepVerifier.create(template.count(Person.class)).expectNext(1L).verifyComplete(); + StepVerifier.create(template.count(User.class)).expectNext(1L).verifyComplete(); } @Test // DATACASS-335 public void updateShouldUpdateEntity() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.insert(person)).expectNextCount(1).verifyComplete(); + StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete(); - person.setFirstname("Walter Hartwell"); + user.setFirstname("Walter Hartwell"); - StepVerifier.create(template.insert(person)).expectNextCount(1).verifyComplete(); + StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete(); - StepVerifier.create(template.selectOneById(person.getId(), Person.class)).expectNext(person).verifyComplete(); + StepVerifier.create(template.selectOneById(user.getId(), User.class)).expectNext(user).verifyComplete(); } @Test // DATACASS-343 public void updateShouldUpdateEntityByQuery() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - template.insert(person).block(); + template.insert(user).block(); Query query = Query.query(Criteria.where("id").is("heisenberg")); - boolean result = template.update(query, Update.empty().set("firstname", "Walter Hartwell"), Person.class).block(); + boolean result = template.update(query, Update.empty().set("firstname", "Walter Hartwell"), User.class).block(); assertThat(result).isTrue(); - assertThat(template.selectOneById(person.getId(), Person.class).block().getFirstname()) + assertThat(template.selectOneById(user.getId(), User.class).block().getFirstname()) .isEqualTo("Walter Hartwell"); } @Test // DATACASS-343 public void deleteByQueryShouldRemoveEntity() { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person).block(); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user).block(); Query query = Query.query(Criteria.where("id").is("heisenberg")); - assertThat(template.delete(query, Person.class).block()).isTrue(); + assertThat(template.delete(query, User.class).block()).isTrue(); - assertThat(template.selectOneById(person.getId(), Person.class).block()).isNull(); + assertThat(template.selectOneById(user.getId(), User.class).block()).isNull(); } @Test // DATACASS-343 public void deleteColumnsByQueryShouldRemoveColumn() { - Person person = new Person("heisenberg", "Walter", "White"); - template.insert(person).block(); + User user = new User("heisenberg", "Walter", "White"); + template.insert(user).block(); Query query = Query.query(Criteria.where("id").is("heisenberg")).columns(Columns.from("lastname")); - assertThat(template.delete(query, Person.class).block()).isTrue(); + assertThat(template.delete(query, User.class).block()).isTrue(); - Person loaded = template.selectOneById(person.getId(), Person.class).block(); + User loaded = template.selectOneById(user.getId(), User.class).block(); assertThat(loaded.getFirstname()).isEqualTo("Walter"); assertThat(loaded.getLastname()).isNull(); } @@ -144,25 +144,25 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC @Test // DATACASS-335 public void deleteShouldRemoveEntity() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.insert(person)).expectNextCount(1).verifyComplete(); + StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete(); - StepVerifier.create(template.delete(person)).expectNext(person).verifyComplete(); + StepVerifier.create(template.delete(user)).expectNext(user).verifyComplete(); - StepVerifier.create(template.selectOneById(person.getId(), Person.class)).verifyComplete(); + StepVerifier.create(template.selectOneById(user.getId(), User.class)).verifyComplete(); } @Test // DATACASS-335 public void deleteByIdShouldRemoveEntity() { - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.insert(person)).expectNextCount(1).verifyComplete(); + StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete(); - StepVerifier.create(template.deleteById(person.getId(), Person.class)).expectNext(true).verifyComplete(); + StepVerifier.create(template.deleteById(user.getId(), User.class)).expectNext(true).verifyComplete(); - StepVerifier.create(template.selectOneById(person.getId(), Person.class)).verifyComplete(); + StepVerifier.create(template.selectOneById(user.getId(), User.class)).verifyComplete(); } @Test // DATACASS-343 diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java index 86021502e..15121bad3 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java @@ -36,7 +36,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.cassandra.core.session.ReactiveResultSet; import org.springframework.cassandra.core.session.ReactiveSession; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; import com.datastax.driver.core.ColumnDefinitions; import com.datastax.driver.core.DataType; @@ -85,12 +85,12 @@ public class ReactiveCassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - StepVerifier.create(template.select("SELECT * FROM person", Person.class)) // - .expectNext(new Person("myid", "Walter", "White")) // + StepVerifier.create(template.select("SELECT * FROM users", User.class)) // + .expectNext(new User("myid", "Walter", "White")) // .verifyComplete(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users"); } @Test // DATACASS-335 @@ -98,7 +98,7 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.rows()).thenThrow(new NoHostAvailableException(Collections.emptyMap())); - StepVerifier.create(template.select("SELECT * FROM person", Person.class)) // + StepVerifier.create(template.select("SELECT * FROM users", User.class)) // .consumeErrorWith(e -> { assertThat(e).hasRootCauseInstanceOf(NoHostAvailableException.class); }).verify(); @@ -119,12 +119,12 @@ public class ReactiveCassandraTemplateUnitTests { when(row.getObject(1)).thenReturn("Walter"); when(row.getObject(2)).thenReturn("White"); - StepVerifier.create(template.selectOneById("myid", Person.class)) // - .expectNext(new Person("myid", "Walter", "White")) // + StepVerifier.create(template.selectOneById("myid", User.class)) // + .expectNext(new User("myid", "Walter", "White")) // .verifyComplete(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-335 @@ -132,10 +132,10 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); - StepVerifier.create(template.exists("myid", Person.class)).expectNext(true).verifyComplete(); + StepVerifier.create(template.exists("myid", User.class)).expectNext(true).verifyComplete(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-335 @@ -143,10 +143,10 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.rows()).thenReturn(Flux.empty()); - StepVerifier.create(template.exists("myid", Person.class)).expectNext(false).verifyComplete(); + StepVerifier.create(template.exists("myid", User.class)).expectNext(false).verifyComplete(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';"); } @Test // DATACASS-335 @@ -156,10 +156,10 @@ public class ReactiveCassandraTemplateUnitTests { when(row.getLong(0)).thenReturn(42L); when(columnDefinitions.size()).thenReturn(1); - StepVerifier.create(template.count(Person.class)).expectNext(42L).verifyComplete(); + StepVerifier.create(template.count(User.class)).expectNext(42L).verifyComplete(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM person;"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM users;"); } @Test // DATACASS-335 @@ -167,12 +167,12 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); - StepVerifier.create(template.insert(person)).expectNext(person).verifyComplete(); + User user = new User("heisenberg", "Walter", "White"); + StepVerifier.create(template.insert(user)).expectNext(user).verifyComplete(); verify(session).execute(statementCaptor.capture()); assertThat(statementCaptor.getValue().toString()) - .isEqualTo("INSERT INTO person (firstname,id,lastname) VALUES ('Walter','heisenberg','White');"); + .isEqualTo("INSERT INTO users (firstname,id,lastname) VALUES ('Walter','heisenberg','White');"); } @Test // DATACASS-335 @@ -182,7 +182,7 @@ public class ReactiveCassandraTemplateUnitTests { when(session.execute(any(Statement.class))) .thenReturn(Mono.error(new NoHostAvailableException(Collections.emptyMap()))); - StepVerifier.create(template.insert(new Person("heisenberg", "Walter", "White"))) // + StepVerifier.create(template.insert(new User("heisenberg", "Walter", "White"))) // .consumeErrorWith(e -> { assertThat(e).hasRootCauseInstanceOf(NoHostAvailableException.class); @@ -194,9 +194,9 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.insert(person)).verifyComplete(); + StepVerifier.create(template.insert(user)).verifyComplete(); } @Test // DATACASS-335 @@ -204,13 +204,13 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.update(person)).expectNext(person).verifyComplete(); + StepVerifier.create(template.update(user)).expectNext(user).verifyComplete(); verify(session).execute(statementCaptor.capture()); assertThat(statementCaptor.getValue().toString()) - .isEqualTo("UPDATE person SET firstname='Walter',lastname='White' WHERE id='heisenberg';"); + .isEqualTo("UPDATE users SET firstname='Walter',lastname='White' WHERE id='heisenberg';"); } @Test // DATACASS-335 @@ -218,9 +218,9 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.update(person)).verifyComplete(); + StepVerifier.create(template.update(user)).verifyComplete(); } @Test // DATACASS-335 @@ -228,12 +228,12 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.wasApplied()).thenReturn(true); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.delete(person)).expectNext(person).verifyComplete(); + StepVerifier.create(template.delete(user)).expectNext(user).verifyComplete(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM users WHERE id='heisenberg';"); } @Test // DATACASS-335 @@ -241,17 +241,17 @@ public class ReactiveCassandraTemplateUnitTests { when(reactiveResultSet.wasApplied()).thenReturn(false); - Person person = new Person("heisenberg", "Walter", "White"); + User user = new User("heisenberg", "Walter", "White"); - StepVerifier.create(template.delete(person)).verifyComplete(); + StepVerifier.create(template.delete(user)).verifyComplete(); } @Test // DATACASS-335 public void truncateShouldRemoveEntities() { - StepVerifier.create(template.truncate(Person.class)).verifyComplete(); + StepVerifier.create(template.truncate(User.class)).verifyComplete(); verify(session).execute(statementCaptor.capture()); - assertThat(statementCaptor.getValue().toString()).isEqualTo("TRUNCATE person;"); + assertThat(statementCaptor.getValue().toString()).isEqualTo("TRUNCATE users;"); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/AddressType.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AddressType.java similarity index 77% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/AddressType.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AddressType.java index ced192b3d..fa3fa861f 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/AddressType.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AddressType.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.simple; +package org.springframework.data.cassandra.domain; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import org.springframework.data.cassandra.mapping.UserDefinedType; @@ -24,8 +26,10 @@ import org.springframework.data.cassandra.mapping.UserDefinedType; */ @UserDefinedType("address") @Data +@AllArgsConstructor +@NoArgsConstructor public class AddressType { - String street; String city; + String country; } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/Book.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/BookReference.java similarity index 61% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/Book.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/BookReference.java index 3c5e35fc5..9708ce038 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/Book.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/BookReference.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors + * Copyright 2017 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,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.simpletons; +package org.springframework.data.cassandra.domain; import lombok.Data; -import lombok.NoArgsConstructor; -import java.util.Date; +import java.util.List; +import java.util.Set; import org.springframework.data.cassandra.mapping.PrimaryKey; import org.springframework.data.cassandra.mapping.Table; @@ -27,23 +27,14 @@ import org.springframework.data.cassandra.mapping.Table; * Test POJO * * @author David Webb - * @author Mark Paluch */ -@Table("book") +@Table("bookReference") @Data -@NoArgsConstructor -public class Book { +public class BookReference { @PrimaryKey private String isbn; private String title; - private String author; - private int pages; - private Date saleDate; - private boolean isInStock; - private BookCondition condition; - - public Book(String isbn) { - this.isbn = isbn; - } + private Set references; + private List bookmarks; } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Person.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Person.java index 7e2106570..6a0fcd2ca 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Person.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Person.java @@ -19,7 +19,13 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import org.springframework.data.annotation.Id; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Date; +import java.util.List; + +import org.springframework.cassandra.core.PrimaryKeyType; +import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.mapping.Table; /** @@ -31,7 +37,24 @@ import org.springframework.data.cassandra.mapping.Table; @NoArgsConstructor public class Person { - @Id String id; - String firstname; - String lastname; + @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0) private String lastname; + + @PrimaryKeyColumn(type = PrimaryKeyType.CLUSTERED, ordinal = 1) private String firstname; + + private String nickname; + private Date birthDate; + private int numberOfChildren; + private boolean cool; + + private LocalDate createdDate; + private ZoneId zoneId; + + private AddressType mainAddress; + private List alternativeAddresses; + + public Person(String firstname, String lastname) { + + this.firstname = firstname; + this.lastname = lastname; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/Address.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/User.java similarity index 52% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/Address.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/User.java index 56e48c920..1856f7ebe 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/Address.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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,23 +13,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.querymethods.declared; +package org.springframework.data.cassandra.domain; -import lombok.AllArgsConstructor; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.springframework.data.cassandra.mapping.UserDefinedType; +import org.springframework.data.annotation.Id; +import org.springframework.data.cassandra.mapping.Table; /** + * @author Alex Shvid * @author Mark Paluch */ -@UserDefinedType -@AllArgsConstructor -@NoArgsConstructor +@Table("users") @Data -public class Address { +@NoArgsConstructor +@EqualsAndHashCode(of = "id") +public class User { - String city; - String country; + /* + * Primary Row ID + */ + @Id private String id; + + /* + * Public information + */ + private String firstname; + private String lastname; + + public User(String id, String firstname, String lastname) { + + this.id = id; + this.firstname = firstname; + this.lastname = lastname; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CreateUserTypeIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CreateUserTypeIntegrationTests.java index cf4c28f47..6b24bed2a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CreateUserTypeIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/CreateUserTypeIntegrationTests.java @@ -31,8 +31,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.annotation.Id; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.data.convert.CustomConversions; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigIntParamIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/BigIntParamIntegrationTests.java similarity index 58% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigIntParamIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/BigIntParamIntegrationTests.java index ff574264c..e9d85bdb2 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigIntParamIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/BigIntParamIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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. @@ -14,20 +14,31 @@ * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.querymethods.bigintparam; +package org.springframework.data.cassandra.repository; import static org.assertj.core.api.Assertions.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + import java.math.BigInteger; +import java.util.Collections; +import java.util.Set; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cassandra.core.PrimaryKeyType; +import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; import org.springframework.data.cassandra.config.SchemaAction; +import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; +import org.springframework.data.cassandra.mapping.Table; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -41,11 +52,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; public class BigIntParamIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { @Configuration - @EnableCassandraRepositories(basePackageClasses = BigThingRepo.class) + @EnableCassandraRepositories(basePackageClasses = BigThingRepo.class, considerNestedRepositories = true, + includeFilters = @Filter(pattern = ".*BigThingRepo", type = FilterType.REGEX)) public static class Config extends IntegrationTestConfig { + @Override - public String[] getEntityBasePackages() { - return new String[] { BigThing.class.getPackage().getName() }; + protected Set> getInitialEntitySet() { + return Collections.singleton(BigThing.class); } @Override @@ -65,4 +78,25 @@ public class BigIntParamIntegrationTests extends AbstractSpringDataEmbeddedCassa BigThing found = repo.findThingByBigInteger(new BigInteger("42")); assertThat(found).isNotNull(); } + + /** + * @author Pete Cable + */ + @Table + @Data + @AllArgsConstructor + @NoArgsConstructor + static class BigThing { + + @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private BigInteger number; + } + + /** + * @author Pete Cable + */ + 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/repository/ConvertingReactiveCassandraRepositoryTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/ConvertingReactiveCassandraRepositoryTests.java index 310119005..718752b12 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/ConvertingReactiveCassandraRepositoryTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/ConvertingReactiveCassandraRepositoryTests.java @@ -33,13 +33,13 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.reactivestreams.Publisher; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.core.ReactiveCassandraTemplate; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.data.repository.reactive.RxJava1CrudRepository; import org.springframework.data.repository.reactive.RxJava2CrudRepository; @@ -68,18 +68,18 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Override public String[] getEntityBasePackages() { - return new String[] { Person.class.getPackage().getName() }; + return new String[] { User.class.getPackage().getName() }; } } @Autowired Session session; @Autowired ReactiveCassandraTemplate template; - @Autowired MixedPersonRepository reactiveRepository; - @Autowired PersonRepostitory reactivePersonRepostitory; - @Autowired RxJava1PersonRepostitory rxJava1PersonRepostitory; - @Autowired RxJava2PersonRepostitory rxJava2PersonRepostitory; + @Autowired MixedUserRepository reactiveRepository; + @Autowired UserRepostitory reactiveUserRepostitory; + @Autowired RxJava1UserRepostitory rxJava1UserRepostitory; + @Autowired RxJava2UserRepostitory rxJava2UserRepostitory; - Person dave, oliver, carter, boyd; + User dave, oliver, carter, boyd; @Before public void setUp() throws Exception { @@ -94,10 +94,10 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace StepVerifier.create(reactiveRepository.deleteAll()).verifyComplete(); - dave = new Person("42", "Dave", "Matthews"); - oliver = new Person("4", "Oliver August", "Matthews"); - carter = new Person("49", "Carter", "Beauford"); - boyd = new Person("45", "Boyd", "Tinsley"); + dave = new User("42", "Dave", "Matthews"); + oliver = new User("4", "Oliver August", "Matthews"); + carter = new User("49", "Carter", "Beauford"); + boyd = new User("45", "Boyd", "Tinsley"); StepVerifier.create(reactiveRepository.saveAll(Arrays.asList(oliver, dave, carter, boyd))).expectNextCount(4) .verifyComplete(); @@ -105,18 +105,18 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-335 public void reactiveStreamsMethodsShouldWork() { - StepVerifier.create(reactivePersonRepostitory.existsById(dave.getId())).expectNext(true).verifyComplete(); + StepVerifier.create(reactiveUserRepostitory.existsById(dave.getId())).expectNext(true).verifyComplete(); } @Test // DATACASS-335 public void reactiveStreamsQueryMethodsShouldWork() { - StepVerifier.create(reactivePersonRepostitory.findByLastname(boyd.getLastname())).expectNext(boyd).verifyComplete(); + StepVerifier.create(reactiveUserRepostitory.findByLastname(boyd.getLastname())).expectNext(boyd).verifyComplete(); } @Test // DATACASS-360 public void dtoProjectionShouldWork() { - StepVerifier.create(reactivePersonRepostitory.findProjectedByLastname(boyd.getLastname())) + StepVerifier.create(reactiveUserRepostitory.findProjectedByLastname(boyd.getLastname())) .consumeNextWith(actual -> { assertThat(actual.firstname).isEqualTo(boyd.getFirstname()); @@ -127,7 +127,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-335 public void simpleRxJava1MethodsShouldWork() { - rxJava1PersonRepostitory.existsById(dave.getId()) // + rxJava1UserRepostitory.existsById(dave.getId()) // .test() // .awaitTerminalEvent() // .assertResult(true) // @@ -138,7 +138,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-335 public void existsWithSingleRxJava1IdMethodsShouldWork() { - rxJava1PersonRepostitory.existsById(Single.just(dave.getId())) // + rxJava1UserRepostitory.existsById(Single.just(dave.getId())) // .test() // .awaitTerminalEvent() // .assertResult(true) // @@ -149,7 +149,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-335 public void singleRxJava1QueryMethodShouldWork() { - rxJava1PersonRepostitory.findManyByLastname(dave.getLastname()) // + rxJava1UserRepostitory.findManyByLastname(dave.getLastname()) // .test() // .awaitTerminalEvent() // .assertValueCount(2) // @@ -160,7 +160,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-335 public void singleProjectedRxJava1QueryMethodShouldWork() { - List values = rxJava1PersonRepostitory.findProjectedByLastname(carter.getLastname()) // + List values = rxJava1UserRepostitory.findProjectedByLastname(carter.getLastname()) // .test() // .awaitTerminalEvent() // .assertValueCount(1) // @@ -168,14 +168,14 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace .assertNoErrors() // .getOnNextEvents(); - ProjectedPerson projectedPerson = values.get(0); - assertThat(projectedPerson.getFirstname()).isEqualTo(carter.getFirstname()); + ProjectedUser projectedUser = values.get(0); + assertThat(projectedUser.getFirstname()).isEqualTo(carter.getFirstname()); } @Test // DATACASS-335 public void observableRxJava1QueryMethodShouldWork() { - rxJava1PersonRepostitory.findByLastname(boyd.getLastname()) // + rxJava1UserRepostitory.findByLastname(boyd.getLastname()) // .test() // .awaitTerminalEvent() // .assertValue(boyd) // @@ -186,7 +186,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-398 public void simpleRxJava2MethodsShouldWork() { - rxJava2PersonRepostitory.existsById(dave.getId()) // + rxJava2UserRepostitory.existsById(dave.getId()) // .test()// .assertValue(true) // .assertNoErrors() // @@ -197,7 +197,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-398 public void existsWithSingleRxJava2IdMethodsShouldWork() { - rxJava2PersonRepostitory.existsById(io.reactivex.Single.just(dave.getId())).test() // + rxJava2UserRepostitory.existsById(io.reactivex.Single.just(dave.getId())).test() // .assertValue(true) // .assertNoErrors() // .assertComplete() // @@ -207,7 +207,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-398 public void flowableRxJava2QueryMethodShouldWork() { - rxJava2PersonRepostitory.findManyByLastname(dave.getLastname()) // + rxJava2UserRepostitory.findManyByLastname(dave.getLastname()) // .test() // .assertValueCount(2) // .assertNoErrors() // @@ -218,7 +218,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-398 public void singleProjectedRxJava2QueryMethodShouldWork() { - rxJava2PersonRepostitory.findProjectedByLastname(Maybe.just(carter.getLastname())) // + rxJava2UserRepostitory.findProjectedByLastname(Maybe.just(carter.getLastname())) // .test() // .assertValue(actual -> { assertThat(actual.getFirstname()).isEqualTo(carter.getFirstname()); @@ -232,7 +232,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-398 public void observableProjectedRxJava2QueryMethodShouldWork() { - rxJava2PersonRepostitory.findProjectedByLastname(Single.just(carter.getLastname())) // + rxJava2UserRepostitory.findProjectedByLastname(Single.just(carter.getLastname())) // .test() // .assertValue(actual -> { assertThat(actual.getFirstname()).isEqualTo(carter.getFirstname()); @@ -246,7 +246,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace @Test // DATACASS-398 public void maybeRxJava2QueryMethodShouldWork() { - rxJava2PersonRepostitory.findByLastname(boyd.getLastname()) // + rxJava2UserRepostitory.findByLastname(boyd.getLastname()) // .test() // .assertValue(boyd) // .assertNoErrors() // @@ -274,55 +274,55 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace } @Repository - interface PersonRepostitory extends ReactiveCrudRepository { + interface UserRepostitory extends ReactiveCrudRepository { - Publisher findByLastname(String lastname); + Publisher findByLastname(String lastname); - Flux findProjectedByLastname(String lastname); + Flux findProjectedByLastname(String lastname); } @Repository - interface RxJava1PersonRepostitory extends RxJava1CrudRepository { + interface RxJava1UserRepostitory extends RxJava1CrudRepository { - Observable findManyByLastname(String lastname); + Observable findManyByLastname(String lastname); - Single findByLastname(String lastname); + Single findByLastname(String lastname); - Single findProjectedByLastname(String lastname); + Single findProjectedByLastname(String lastname); } @Repository - interface RxJava2PersonRepostitory extends RxJava2CrudRepository { + interface RxJava2UserRepostitory extends RxJava2CrudRepository { - Flowable findManyByLastname(String lastname); + Flowable findManyByLastname(String lastname); - Maybe findByLastname(String lastname); + Maybe findByLastname(String lastname); - io.reactivex.Single findProjectedByLastname(Maybe lastname); + io.reactivex.Single findProjectedByLastname(Maybe lastname); - io.reactivex.Observable findProjectedByLastname(Single lastname); + io.reactivex.Observable findProjectedByLastname(Single lastname); } @Repository - interface MixedPersonRepository extends ReactiveCassandraRepository { + interface MixedUserRepository extends ReactiveCassandraRepository { - Single findByLastname(String lastname); + Single findByLastname(String lastname); - Mono findByLastname(Single lastname); + Mono findByLastname(Single lastname); } - interface ProjectedPerson { + interface ProjectedUser { String getId(); String getFirstname(); } - static class PersonDto { + static class UserDto { public String firstname, lastname; - public PersonDto(String firstname, String lastname) { + public UserDto(String firstname, String lastname) { this.firstname = firstname; this.lastname = lastname; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateKeyIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/DateKeyIntegrationTests.java similarity index 56% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateKeyIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/DateKeyIntegrationTests.java index 19e7d95e1..aa7a4e8a4 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateKeyIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/DateKeyIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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,20 +13,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.querymethods.datekey; +package org.springframework.data.cassandra.repository; import static org.assertj.core.api.Assertions.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collections; import java.util.Date; +import java.util.Set; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cassandra.core.PrimaryKeyType; +import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; import org.springframework.data.cassandra.config.SchemaAction; +import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; +import org.springframework.data.cassandra.mapping.Table; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -40,11 +51,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; public class DateKeyIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { @Configuration - @EnableCassandraRepositories(basePackageClasses = DateThingRepo.class) + @EnableCassandraRepositories(basePackageClasses = DateThingRepo.class, considerNestedRepositories = true, + includeFilters = @Filter(pattern = ".*DateThingRepo", type = FilterType.REGEX)) public static class Config extends IntegrationTestConfig { + @Override - public String[] getEntityBasePackages() { - return new String[] { DateThing.class.getPackage().getName() }; + protected Set> getInitialEntitySet() { + return Collections.singleton(DateThing.class); } @Override @@ -57,6 +70,7 @@ public class DateKeyIntegrationTests extends AbstractSpringDataEmbeddedCassandra @Test public void testQueryWithDate() { + Date date = new Date(); DateThing saved = new DateThing(date); repo.save(saved); @@ -64,4 +78,27 @@ public class DateKeyIntegrationTests extends AbstractSpringDataEmbeddedCassandra DateThing found = repo.findThingByDate(date); assertThat(found).isNotNull(); } + + /** + * @author Matthew T. Adams + */ + @Table + @Data + @AllArgsConstructor + @NoArgsConstructor + static class DateThing { + + @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private Date date; + } + + /** + * Integration tests for {@link Date} usage in repositories. + * + * @author Matthew T. Adams + */ + 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/repository/querymethods/intparam/IntParamIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/IntParamIntegrationTests.java similarity index 57% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/intparam/IntParamIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/IntParamIntegrationTests.java index ec624ded0..5b69c37b7 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/intparam/IntParamIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/IntParamIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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,18 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.querymethods.intparam; +package org.springframework.data.cassandra.repository; import static org.assertj.core.api.Assertions.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collections; +import java.util.Set; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cassandra.core.PrimaryKeyType; +import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; import org.springframework.data.cassandra.config.SchemaAction; +import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; +import org.springframework.data.cassandra.mapping.Table; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -36,11 +48,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; public class IntParamIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { @Configuration - @EnableCassandraRepositories(basePackageClasses = IntThingRepo.class) + @EnableCassandraRepositories(basePackageClasses = IntThingRepo.class, considerNestedRepositories = true, + includeFilters = @Filter(pattern = ".*IntThingRepo", type = FilterType.REGEX)) public static class Config extends IntegrationTestConfig { + @Override - public String[] getEntityBasePackages() { - return new String[] { IntThing.class.getPackage().getName() }; + protected Set> getInitialEntitySet() { + return Collections.singleton(IntThing.class); } @Override @@ -53,6 +67,7 @@ public class IntParamIntegrationTests extends AbstractSpringDataEmbeddedCassandr @Test public void testQueryWithIntPrimitiveAndReference() { + int number = 42; IntThing saved = new IntThing(42); repo.save(saved); @@ -63,4 +78,22 @@ public class IntParamIntegrationTests extends AbstractSpringDataEmbeddedCassandr found = repo.findThingByIntReference(new Integer(number)); assertThat(found).isNotNull(); } + + @Table + @Data + @AllArgsConstructor + @NoArgsConstructor + static class IntThing { + + @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private int number; + } + + interface IntThingRepo extends CassandraRepository { + + @Query("SELECT * from intthing where number = ?0") + IntThing findThingByIntPrimitive(int number); + + @Query("SELECT * from intthing where number = ?0") + IntThing findThingByIntReference(Integer number); + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/NamedQueryIntegrationTests.java similarity index 77% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/NamedQueryIntegrationTests.java index 4a8425bc1..eac184f4a 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/NamedQueryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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,44 +13,57 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.querymethods.declared; +package org.springframework.data.cassandra.repository; import static org.assertj.core.api.Assertions.*; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.stream.Stream; 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.ComponentScan.Filter; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; import org.springframework.data.cassandra.config.SchemaAction; -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.data.cassandra.core.CassandraOperations; +import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.datastax.driver.core.Session; +import com.datastax.driver.core.ResultSet; /** - * Integration tests for use with {@link PersonRepository}. + * Integration tests for use with {@link PersonRepositoryWithNamedQueries}. * * @author Matthew T. Adams * @author Mark Paluch * @soundtrack Mary Jane Kelly - Volbeat */ @RunWith(SpringJUnit4ClassRunner.class) -public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { +public class NamedQueryIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { + @Configuration + @EnableCassandraRepositories(basePackageClasses = PersonRepositoryWithNamedQueries.class, + namedQueriesLocation = "classpath:META-INF/PersonRepositoryWithNamedQueries.properties", + considerNestedRepositories = true, + includeFilters = @Filter(pattern = ".*PersonRepositoryWithNamedQueries", type = FilterType.REGEX)) public static class Config extends IntegrationTestConfig { @Override - public String[] getEntityBasePackages() { - return new String[] { Person.class.getPackage().getName() }; + protected Set> getInitialEntitySet() { + return Collections.singleton(Person.class); } @Override @@ -59,12 +72,12 @@ public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCa } } - @Autowired PersonRepository personRepository; - @Autowired Session session; + @Autowired PersonRepositoryWithNamedQueries personRepository; + @Autowired CassandraOperations cassandraOperations; @Before public void before() { - deleteAllEntities(); + SchemaTestUtils.truncate(Person.class, cassandraOperations); } @Test @@ -319,10 +332,35 @@ public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCa personRepository.save(person); } - Stream allPeople = personRepository.findAllPeople(); + Stream allPeople = personRepository.findPeopleBy(); long count = allPeople.peek(person -> assertThat(person).isInstanceOf(Person.class)).count(); assertThat(count).isEqualTo(before + 100L); } + + public interface PersonRepositoryWithNamedQueries extends CassandraRepository { + + List findFolksWithLastnameAsList(String lastname); + + ResultSet findFolksWithLastnameAsResultSet(String last); + + Person[] findFolksWithLastnameAsArray(String lastname); + + Person findSingle(String last, String first); + + List> findFolksWithLastnameAsListOfMapOfStringToObject(String last); + + String findSingleNickname(String last, String first); + + Date findSingleBirthdate(String last, String first); + + boolean findSingleCool(String last, String first); + + int findSingleNumberOfChildren(String last, String first); + + Optional findOptionalWithLastnameAndFirstname(String last, String first); + + Stream findPeopleBy(); + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/derived/QueryDerivationIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/QueryDerivationIntegrationTests.java similarity index 68% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/derived/QueryDerivationIntegrationTests.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/QueryDerivationIntegrationTests.java index 64b7c9e90..25baf4753 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/derived/QueryDerivationIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/QueryDerivationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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.repository.querymethods.derived; +package org.springframework.data.cassandra.repository; import static org.assertj.core.api.Assertions.*; import static org.junit.Assume.*; @@ -21,24 +21,29 @@ import static org.junit.Assume.*; import java.time.LocalDate; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Set; +import org.assertj.core.api.Assertions; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.support.CassandraVersion; +import org.springframework.cassandra.support.CassandraVersion; +import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; import org.springframework.data.cassandra.config.SchemaAction; import org.springframework.data.cassandra.core.CassandraOperations; +import org.springframework.data.cassandra.domain.AddressType; +import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.repository.QueryDerivationIntegrationTests.PersonRepository.NumberOfChildren; +import org.springframework.data.cassandra.repository.QueryDerivationIntegrationTests.PersonRepository.PersonDto; +import org.springframework.data.cassandra.repository.QueryDerivationIntegrationTests.PersonRepository.PersonProjection; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Address; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; -import org.springframework.data.cassandra.test.integration.repository.querymethods.derived.PersonRepository.NumberOfChildren; -import org.springframework.data.cassandra.test.integration.repository.querymethods.derived.PersonRepository.PersonDto; -import org.springframework.data.cassandra.test.integration.repository.querymethods.derived.PersonRepository.PersonProjection; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.data.domain.Sort; import org.springframework.data.util.Version; import org.springframework.test.context.ContextConfiguration; @@ -57,12 +62,13 @@ import com.datastax.driver.core.Session; public class QueryDerivationIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { @Configuration - @EnableCassandraRepositories + @EnableCassandraRepositories(considerNestedRepositories = true, + includeFilters = @Filter(pattern = ".*PersonRepository", type = FilterType.REGEX)) public static class Config extends IntegrationTestConfig { @Override - public String[] getEntityBasePackages() { - return new String[] { Person.class.getPackage().getName() }; + protected Set> getInitialEntitySet() { + return Collections.singleton(Person.class); } @Override @@ -83,14 +89,15 @@ public class QueryDerivationIntegrationTests extends AbstractSpringDataEmbeddedC @Before public void before() { + deleteAllEntities(); Person person = new Person("Walter", "White"); person.setNumberOfChildren(2); - person.setMainAddress(new Address("Albuquerque", "USA")); - person.setAlternativeAddresses(Arrays.asList(new Address("Albuquerque", "USA"), new Address("New Hampshire", "USA"), - new Address("Grocery Store", "Mexico"))); + person.setMainAddress(new AddressType("Albuquerque", "USA")); + person.setAlternativeAddresses(Arrays.asList(new AddressType("Albuquerque", "USA"), + new AddressType("New Hampshire", "USA"), new AddressType("Grocery Store", "Mexico"))); walter = personRepository.save(person); skyler = personRepository.save(new Person("Skyler", "White")); @@ -161,8 +168,8 @@ public class QueryDerivationIntegrationTests extends AbstractSpringDataEmbeddedC Collection collection = personRepository.findPersonProjectedBy(); - assertThat(collection).hasSize(3).extracting("firstname").contains(flynn.getFirstname(), skyler.getFirstname(), - walter.getFirstname()); + Assertions.assertThat(collection).hasSize(3).extracting("firstname").contains(flynn.getFirstname(), + skyler.getFirstname(), walter.getFirstname()); } @Test // DATACASS-359 @@ -170,8 +177,8 @@ public class QueryDerivationIntegrationTests extends AbstractSpringDataEmbeddedC Collection collection = personRepository.findPersonDtoBy(); - assertThat(collection).hasSize(3).extracting("firstname").contains(flynn.getFirstname(), skyler.getFirstname(), - walter.getFirstname()); + Assertions.assertThat(collection).hasSize(3).extracting("firstname").contains(flynn.getFirstname(), + skyler.getFirstname(), walter.getFirstname()); } @Test // DATACASS-359 @@ -190,8 +197,8 @@ public class QueryDerivationIntegrationTests extends AbstractSpringDataEmbeddedC PersonDto heisenberg = personRepository.findDtoByNicknameStartsWith("Heisen", PersonDto.class); - assertThat(heisenberg.firstname).isEqualTo("Walter"); - assertThat(heisenberg.lastname).isEqualTo("White"); + Assertions.assertThat(heisenberg.firstname).isEqualTo("Walter"); + Assertions.assertThat(heisenberg.lastname).isEqualTo("White"); } @Test // DATACASS-7 @@ -270,4 +277,61 @@ public class QueryDerivationIntegrationTests extends AbstractSpringDataEmbeddedC assertThat(personRepository.findByNicknameContains("eisenber")).isEqualTo(walter); } + + /** + * @author Mark Paluch + */ + static interface PersonRepository extends CassandraRepository { + + List findByLastname(String lastname); + + List findByLastname(String lastname, Sort sort); + + List findByLastnameOrderByFirstnameAsc(String lastname); + + Person findByFirstnameAndLastname(String firstname, String lastname); + + Person findByMainAddress(AddressType address); + + @Query("select * from person where mainaddress = ?0") + Person findByAddress(AddressType address); + + Person findByCreatedDate(LocalDate createdDate); + + Person findByNicknameStartsWith(String prefix); + + Person findByNicknameContains(String contains); + + Person findByNumberOfChildren(NumberOfChildren numberOfChildren); + + Collection findPersonProjectedBy(); + + Collection findPersonDtoBy(); + + T findDtoByNicknameStartsWith(String prefix, Class projectionType); + + @Query("select * from person where firstname = ?0 and lastname = 'White'") + List findByFirstname(String firstname); + + enum NumberOfChildren { + ZERO, ONE, TWO, + } + + interface PersonProjection { + + String getFirstname(); + + String getLastname(); + } + + class PersonDto { + + public String firstname, lastname; + + public PersonDto(String firstname, String lastname) { + this.firstname = firstname; + this.lastname = lastname; + } + } + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/ReactiveCassandraRepositoryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/ReactiveCassandraRepositoryIntegrationTests.java index 9b774b959..d0d8f1e28 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/ReactiveCassandraRepositoryIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/ReactiveCassandraRepositoryIntegrationTests.java @@ -20,6 +20,8 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import org.junit.Before; import org.junit.Test; @@ -30,15 +32,15 @@ import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.core.ReactiveCassandraOperations; import org.springframework.data.cassandra.domain.Group; import org.springframework.data.cassandra.domain.GroupKey; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.data.cassandra.repository.support.ReactiveCassandraRepositoryFactory; import org.springframework.data.cassandra.repository.support.SimpleReactiveCassandraRepository; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.repository.query.DefaultEvaluationContextProvider; @@ -63,8 +65,8 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac public static class Config extends IntegrationTestConfig { @Override - public String[] getEntityBasePackages() { - return new String[] { Person.class.getPackage().getName() }; + protected Set> getInitialEntitySet() { + return new HashSet<>(Arrays.asList(Group.class, User.class)); } } @@ -74,10 +76,10 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac ReactiveCassandraRepositoryFactory factory; ClassLoader classLoader; BeanFactory beanFactory; - PersonRepository repository; + UserRepository repository; GroupRepository groupRepostitory; - Person dave, oliver, carter, boyd; + User dave, oliver, carter, boyd; @Override public void setBeanClassLoader(ClassLoader classLoader) { @@ -93,10 +95,10 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac public void setUp() throws Exception { KeyspaceMetadata keyspace = session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace()); - TableMetadata person = keyspace.getTable("person"); + TableMetadata users = keyspace.getTable("users"); - if (person.getIndex("IX_lastname") == null) { - session.execute("CREATE INDEX IX_lastname ON person (lastname);"); + if (users.getIndex("IX_lastname") == null) { + session.execute("CREATE INDEX IX_lastname ON users (lastname);"); Thread.sleep(500); } @@ -106,15 +108,15 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac factory.setBeanFactory(beanFactory); factory.setEvaluationContextProvider(DefaultEvaluationContextProvider.INSTANCE); - repository = factory.getRepository(PersonRepository.class); + repository = factory.getRepository(UserRepository.class); groupRepostitory = factory.getRepository(GroupRepository.class); StepVerifier.create(repository.deleteAll().concatWith(groupRepostitory.deleteAll())).verifyComplete(); - dave = new Person("42", "Dave", "Matthews"); - oliver = new Person("4", "Oliver August", "Matthews"); - carter = new Person("49", "Carter", "Beauford"); - boyd = new Person("45", "Boyd", "Tinsley"); + dave = new User("42", "Dave", "Matthews"); + oliver = new User("4", "Oliver August", "Matthews"); + carter = new User("49", "Carter", "Beauford"); + boyd = new User("45", "Boyd", "Tinsley"); StepVerifier.create(repository.saveAll(Arrays.asList(oliver, dave, carter, boyd))).expectNextCount(4) .verifyComplete(); @@ -162,16 +164,16 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac .verifyComplete(); } - interface PersonRepository extends ReactiveCassandraRepository { + interface UserRepository extends ReactiveCassandraRepository { - Flux findByLastname(String lastname); + Flux findByLastname(String lastname); - Mono findOneByLastname(String lastname); + Mono findOneByLastname(String lastname); - Mono findByLastname(Publisher lastname); + Mono findByLastname(Publisher lastname); - @Query("SELECT * FROM person WHERE lastname = ?0") - Flux findStringQuery(Mono lastname); + @Query("SELECT * FROM users WHERE lastname = ?0") + Flux findStringQuery(Mono lastname); } interface GroupRepository extends ReactiveCassandraRepository { 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/repository/cdi/CassandraOperationsProducer.java similarity index 94% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CassandraOperationsProducer.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/CassandraOperationsProducer.java index e31b6958f..21bc82510 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/repository/cdi/CassandraOperationsProducer.java @@ -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.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; import java.util.Collections; import java.util.Set; @@ -27,17 +27,17 @@ import org.springframework.cassandra.core.cql.generator.CreateKeyspaceCqlGenerat import org.springframework.cassandra.core.cql.generator.DropKeyspaceCqlGenerator; import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification; import org.springframework.cassandra.core.keyspace.DropKeyspaceSpecification; +import org.springframework.cassandra.support.CassandraConnectionProperties; 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.core.CassandraPersistentEntitySchemaCreator; import org.springframework.data.cassandra.core.CassandraPersistentEntitySchemaDropper; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; import org.springframework.data.cassandra.mapping.SimpleUserTypeResolver; -import org.springframework.data.cassandra.test.integration.repository.simple.User; import com.datastax.driver.core.Cluster; import com.google.common.collect.Sets; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiRepositoryClient.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/CdiRepositoryClient.java similarity index 95% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiRepositoryClient.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/CdiRepositoryClient.java index f034200ee..015bce9d9 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiRepositoryClient.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/CdiRepositoryClient.java @@ -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.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; import javax.inject.Inject; 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/repository/cdi/CdiRepositoryTests.java similarity index 74% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiRepositoryTests.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/CdiRepositoryTests.java index c90acf0db..5608bb022 100755 --- 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/repository/cdi/CdiRepositoryTests.java @@ -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.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; import static org.assertj.core.api.Assertions.*; @@ -25,8 +25,8 @@ import org.junit.AfterClass; 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.simple.User; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.domain.User; /** * @author Mohsin Husen @@ -75,29 +75,29 @@ public class CdiRepositoryTests extends AbstractEmbeddedCassandraIntegrationTest repository.deleteAll(); User bean = new User(); - bean.setUsername("username"); - bean.setFirstName("first"); - bean.setLastName("last"); + bean.setId("username"); + bean.setFirstname("first"); + bean.setLastname("last"); repository.save(bean); - assertThat(repository.existsById(bean.getUsername())).isTrue(); + assertThat(repository.existsById(bean.getId())).isTrue(); - Optional retrieved = repository.findById(bean.getUsername()); + Optional retrieved = repository.findById(bean.getId()); assertThat(retrieved).hasValueSatisfying(actual -> { - assertThat(actual.getUsername()).isEqualTo(bean.getUsername()); - assertThat(actual.getFirstName()).isEqualTo(bean.getFirstName()); - assertThat(actual.getLastName()).isEqualTo(bean.getLastName()); + assertThat(actual.getId()).isEqualTo(bean.getId()); + assertThat(actual.getFirstname()).isEqualTo(bean.getFirstname()); + assertThat(actual.getLastname()).isEqualTo(bean.getLastname()); }); assertThat(repository.count()).isEqualTo(1); - assertThat(repository.existsById(bean.getUsername())).isTrue(); + assertThat(repository.existsById(bean.getId())).isTrue(); repository.delete(bean); assertThat(repository.count()).isEqualTo(0); - assertThat(repository.findById(bean.getUsername())).isNotPresent(); + assertThat(repository.findById(bean.getId())).isNotPresent(); } @Test // DATACASS-249 @@ -107,13 +107,13 @@ public class CdiRepositoryTests extends AbstractEmbeddedCassandraIntegrationTest qualifiedUserRepository.deleteAll(); User bean = new User(); - bean.setUsername("username"); - bean.setFirstName("first"); - bean.setLastName("last"); + bean.setId("username"); + bean.setFirstname("first"); + bean.setLastname("last"); qualifiedUserRepository.save(bean); - assertThat(qualifiedUserRepository.existsById(bean.getUsername())).isTrue(); + assertThat(qualifiedUserRepository.existsById(bean.getId())).isTrue(); } @Test // DATACASS-149 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/repository/cdi/CdiUserRepository.java similarity index 85% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/CdiUserRepository.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/CdiUserRepository.java index e8ebc3212..f892b8b49 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/repository/cdi/CdiUserRepository.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; import java.util.Optional; -import org.springframework.data.cassandra.test.integration.repository.simple.User; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.repository.CrudRepository; /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/OtherQualifier.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/OtherQualifier.java similarity index 93% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/OtherQualifier.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/OtherQualifier.java index e0a84c97c..b2ebb0cd2 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/OtherQualifier.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/OtherQualifier.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/QualifiedUserRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/QualifiedUserRepository.java similarity index 83% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/QualifiedUserRepository.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/QualifiedUserRepository.java index 6b9276292..b2d9db3d6 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/QualifiedUserRepository.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/QualifiedUserRepository.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; -import org.springframework.data.cassandra.test.integration.repository.simple.User; +import org.springframework.data.cassandra.domain.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/repository/cdi/SamplePersonRepository.java similarity index 82% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepository.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/SamplePersonRepository.java index b262291ca..6de2fab65 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/repository/cdi/SamplePersonRepository.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; +import org.springframework.data.cassandra.domain.Person; import org.springframework.data.repository.Repository; /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepositoryCustom.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/SamplePersonRepositoryCustom.java similarity index 90% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepositoryCustom.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/SamplePersonRepositoryCustom.java index ff0847f7a..0c81c5ab8 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepositoryCustom.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/SamplePersonRepositoryCustom.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; /** * @author Mark Paluch diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepositoryImpl.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/SamplePersonRepositoryImpl.java similarity index 91% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepositoryImpl.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/SamplePersonRepositoryImpl.java index bbbbdb0e4..e1872ebf7 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/SamplePersonRepositoryImpl.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/SamplePersonRepositoryImpl.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; /** * @author Mark Paluch diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/UserDB.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/UserDB.java similarity index 93% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/UserDB.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/UserDB.java index 306280e72..3d8e38a9a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/cdi/UserDB.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/cdi/UserDB.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.repository.cdi; +package org.springframework.data.cassandra.repository.cdi; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/ReactiveCassandraRepositoriesRegistrarUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/ReactiveCassandraRepositoriesRegistrarUnitTests.java index 6ddf5c317..d30a73ae2 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/ReactiveCassandraRepositoriesRegistrarUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/config/ReactiveCassandraRepositoriesRegistrarUnitTests.java @@ -29,6 +29,8 @@ import org.springframework.context.annotation.FilterType; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.ReactiveCassandraTemplate; import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; +import org.springframework.data.cassandra.mapping.UserTypeResolver; import org.springframework.data.cassandra.repository.ReactiveCassandraRepository; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -50,7 +52,12 @@ public class ReactiveCassandraRepositoriesRegistrarUnitTests { @Bean public ReactiveCassandraTemplate reactiveCassandraTemplate() throws Exception { - return new ReactiveCassandraTemplate(mock(ReactiveSession.class), new MappingCassandraConverter()); + + BasicCassandraMappingContext mappingContext = new BasicCassandraMappingContext(); + mappingContext.setUserTypeResolver(mock(UserTypeResolver.class)); + MappingCassandraConverter converter = new MappingCassandraConverter(mappingContext); + + return new ReactiveCassandraTemplate(mock(ReactiveSession.class), converter); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/DerivedQueryMethodsParameterConversionIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/DerivedQueryMethodsParameterConversionIntegrationTests.java index 055572451..d1c51ab27 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/DerivedQueryMethodsParameterConversionIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/DerivedQueryMethodsParameterConversionIntegrationTests.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.cassandra.repository.CassandraRepository; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.base.PersonRepository; +import org.springframework.data.cassandra.repository.NamedQueryIntegrationTests.PersonRepositoryWithNamedQueries; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -31,7 +31,7 @@ import com.datastax.driver.core.KeyspaceMetadata; import com.datastax.driver.core.UDTValue; /** - * Integration tests for query argument conversion through {@link PersonRepository}. + * Integration tests for query argument conversion through {@link PersonRepositoryWithNamedQueries}. * * @author Mark Paluch */ diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/ParameterConversionTestSupport.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/ParameterConversionTestSupport.java index 17c33ce86..760ecc52e 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/ParameterConversionTestSupport.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/ParameterConversionTestSupport.java @@ -32,8 +32,8 @@ import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.mapping.SimpleUserTypeResolver; import org.springframework.data.cassandra.mapping.UserTypeResolver; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.data.convert.CustomConversions; import org.springframework.util.StringUtils; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/StringQueryMethodsParameterConversionIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/StringQueryMethodsParameterConversionIntegrationTests.java index bd7e75892..a6678e968 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/StringQueryMethodsParameterConversionIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/StringQueryMethodsParameterConversionIntegrationTests.java @@ -23,8 +23,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.data.cassandra.repository.NamedQueryIntegrationTests.PersonRepositoryWithNamedQueries; import org.springframework.data.cassandra.repository.Query; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.base.PersonRepository; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -32,7 +32,7 @@ import com.datastax.driver.core.KeyspaceMetadata; import com.datastax.driver.core.UDTValue; /** - * Integration tests for query argument conversion through {@link PersonRepository}. + * Integration tests for query argument conversion through {@link PersonRepositoryWithNamedQueries}. * * @author Mark Paluch */ diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryQueryMethodParameterTypesIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryQueryMethodParameterTypesIntegrationTests.java index 14ca160c8..da0746df3 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryQueryMethodParameterTypesIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryQueryMethodParameterTypesIntegrationTests.java @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Optional; +import java.util.Set; import org.junit.Before; import org.junit.Test; @@ -42,8 +43,8 @@ import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.CassandraType; import org.springframework.data.cassandra.repository.Query; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.data.convert.CustomConversions; import org.springframework.data.repository.CrudRepository; import org.springframework.test.context.ContextConfiguration; @@ -69,8 +70,8 @@ public class RepositoryQueryMethodParameterTypesIntegrationTests public static class Config extends IntegrationTestConfig { @Override - public String[] getEntityBasePackages() { - return new String[] { AllPossibleTypes.class.getPackage().getName() }; + protected Set> getInitialEntitySet() { + return Collections.singleton(AllPossibleTypes.class); } @Override diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryReturnTypesIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryReturnTypesIntegrationTests.java index 871135ec1..697312079 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryReturnTypesIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryReturnTypesIntegrationTests.java @@ -21,10 +21,12 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import org.junit.Before; import org.junit.Test; @@ -35,8 +37,8 @@ import org.springframework.data.cassandra.config.SchemaAction; import org.springframework.data.cassandra.domain.AllPossibleTypes; import org.springframework.data.cassandra.repository.Query; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.data.repository.CrudRepository; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -59,8 +61,8 @@ public class RepositoryReturnTypesIntegrationTests extends AbstractSpringDataEmb public static class Config extends IntegrationTestConfig { @Override - public String[] getEntityBasePackages() { - return new String[] { AllPossibleTypes.class.getPackage().getName() }; + protected Set> getInitialEntitySet() { + return Collections.singleton(AllPossibleTypes.class); } @Override diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraQueryCreatorUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraQueryCreatorUnitTests.java index e91f1505f..17ed68588 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraQueryCreatorUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraQueryCreatorUnitTests.java @@ -16,6 +16,7 @@ package org.springframework.data.cassandra.repository.query; import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; import static org.springframework.data.cassandra.repository.query.StubParameterAccessor.*; import java.io.Serializable; @@ -38,13 +39,13 @@ import org.springframework.data.cassandra.core.StatementFactory; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.domain.Person; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; -import org.springframework.data.cassandra.mapping.CassandraMappingContext; import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; 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.cassandra.mapping.UserTypeResolver; import org.springframework.data.cassandra.repository.support.MappingCassandraEntityInformation; import org.springframework.data.repository.query.parser.PartTree; @@ -57,14 +58,17 @@ import com.datastax.driver.core.RegularStatement; */ public class CassandraQueryCreatorUnitTests { - CassandraMappingContext context; + BasicCassandraMappingContext context; CassandraConverter converter; @Rule public ExpectedException exception = ExpectedException.none(); @Before public void setUp() throws SecurityException, NoSuchMethodException { + context = new BasicCassandraMappingContext(); + context.setUserTypeResolver(mock(UserTypeResolver.class)); + converter = new MappingCassandraConverter(context); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraQueryMethodUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraQueryMethodUnitTests.java index ae85a7072..53d5943bb 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraQueryMethodUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraQueryMethodUnitTests.java @@ -22,7 +22,7 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.CassandraMappingContext; import org.springframework.data.projection.ProjectionFactory; @@ -50,8 +50,8 @@ public class CassandraQueryMethodUnitTests { CassandraQueryMethod queryMethod = queryMethod(SampleRepository.class, "method"); CassandraEntityMetadata metadata = queryMethod.getEntityInformation(); - assertThat(metadata.getJavaType()).isAssignableFrom(Person.class); - assertThat(metadata.getTableName().toCql()).isEqualTo("person"); + assertThat(metadata.getJavaType()).isAssignableFrom(User.class); + assertThat(metadata.getTableName().toCql()).isEqualTo("users"); } @Test(expected = IllegalArgumentException.class) // DATACASS-7 @@ -79,9 +79,9 @@ public class CassandraQueryMethodUnitTests { } @SuppressWarnings("unused") - interface SampleRepository extends Repository { + interface SampleRepository extends Repository { - List method(); + List method(); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/PartTreeCassandraQueryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/PartTreeCassandraQueryUnitTests.java index 6a13c8cda..1187a452a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/PartTreeCassandraQueryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/PartTreeCassandraQueryUnitTests.java @@ -34,13 +34,13 @@ import org.springframework.cassandra.core.cql.CqlIdentifier; import org.springframework.data.cassandra.convert.CassandraConverter; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.CassandraOperations; +import org.springframework.data.cassandra.domain.AddressType; import org.springframework.data.cassandra.domain.Group; +import org.springframework.data.cassandra.domain.Person; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.UserTypeResolver; import org.springframework.data.cassandra.repository.CassandraRepository; import org.springframework.data.cassandra.repository.Query; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Address; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.SpelAwareProxyProjectionFactory; import org.springframework.data.repository.core.support.DefaultRepositoryMetadata; @@ -124,7 +124,7 @@ public class PartTreeCassandraQueryUnitTests { when(userTypeResolverMock.resolveType(CqlIdentifier.cqlId("address"))).thenReturn(userTypeMock); when(userTypeMock.newValue()).thenReturn(udtValueMock); - String query = deriveQueryFromMethod("findByMainAddress", new Address()); + String query = deriveQueryFromMethod("findByMainAddress", new AddressType()); assertThat(query).isEqualTo("SELECT * FROM person WHERE mainaddress={};"); } @@ -177,7 +177,9 @@ public class PartTreeCassandraQueryUnitTests { return partTreeQuery.createQuery(new ConvertingParameterAccessor(mockCassandraOperations.getConverter(), accessor)); } - private PartTreeCassandraQuery createQueryForMethod(Class repositoryInterface,String methodName, Class... paramTypes) {Class[] userTypes = Arrays.stream(paramTypes)// + private PartTreeCassandraQuery createQueryForMethod(Class repositoryInterface, String methodName, + Class... paramTypes) { + Class[] userTypes = Arrays.stream(paramTypes)// .map(it -> it.getName().contains("Mockito") ? it.getSuperclass() : it)// .toArray(size -> new Class[size]); try { @@ -214,11 +216,11 @@ public class PartTreeCassandraQueryUnitTests { Person findPersonBy(); - Person findByMainAddress(Address address); + Person findByMainAddress(AddressType address); Person findByMainAddress(UDTValue udtValue); - Person findByMainAddressIn(Collection
address); + Person findByMainAddressIn(Collection address); Person findByFirstnameIn(Collection firstname); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactivePartTreeCassandraQueryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactivePartTreeCassandraQueryUnitTests.java index cc15f435f..04aab9d8d 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactivePartTreeCassandraQueryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactivePartTreeCassandraQueryUnitTests.java @@ -31,12 +31,11 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.data.cassandra.convert.CassandraConverter; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.ReactiveCassandraOperations; import org.springframework.data.cassandra.domain.Person; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; -import org.springframework.data.cassandra.mapping.CassandraMappingContext; +import org.springframework.data.cassandra.mapping.UserTypeResolver; import org.springframework.data.cassandra.repository.CassandraRepository; import org.springframework.data.cassandra.repository.Query; import org.springframework.data.projection.ProjectionFactory; @@ -54,16 +53,17 @@ public class ReactivePartTreeCassandraQueryUnitTests { @Rule public ExpectedException exception = ExpectedException.none(); @Mock ReactiveCassandraOperations mockCassandraOperations; + @Mock UserTypeResolver userTypeResolver; - private CassandraMappingContext mappingContext; - private CassandraConverter converter; + private BasicCassandraMappingContext mappingContext; @Before public void setUp() { - mappingContext = new BasicCassandraMappingContext(); - converter = new MappingCassandraConverter(mappingContext); - when(mockCassandraOperations.getConverter()).thenReturn(converter); + mappingContext = new BasicCassandraMappingContext(); + mappingContext.setUserTypeResolver(userTypeResolver); + + when(mockCassandraOperations.getConverter()).thenReturn(new MappingCassandraConverter(mappingContext)); } @Test // DATACASS-335 diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactiveStringBasedCassandraQueryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactiveStringBasedCassandraQueryUnitTests.java index 24fac6d18..a148515f9 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactiveStringBasedCassandraQueryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/ReactiveStringBasedCassandraQueryUnitTests.java @@ -28,9 +28,9 @@ import org.springframework.cassandra.core.ReactiveCqlOperations; import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.ReactiveCassandraOperations; +import org.springframework.data.cassandra.domain.Person; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.repository.Query; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.SpelAwareProxyProjectionFactory; import org.springframework.data.repository.Repository; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/StringBasedCassandraQueryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/StringBasedCassandraQueryUnitTests.java index 1f08bfd8b..a69579c85 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/StringBasedCassandraQueryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/StringBasedCassandraQueryUnitTests.java @@ -35,12 +35,12 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.cassandra.core.cql.CqlIdentifier; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.CassandraOperations; +import org.springframework.data.cassandra.domain.AddressType; +import org.springframework.data.cassandra.domain.Person; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.UserTypeResolver; import org.springframework.data.cassandra.repository.Query; import org.springframework.data.cassandra.support.UserTypeBuilder; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Address; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.SpelAwareProxyProjectionFactory; import org.springframework.data.repository.Repository; @@ -312,9 +312,9 @@ public class StringBasedCassandraQueryUnitTests { when(userTypeResolver.resolveType(CqlIdentifier.cqlId("address"))).thenReturn(addressType); - StringBasedCassandraQuery cassandraQuery = getQueryMethod("findByMainAddress", Address.class); + StringBasedCassandraQuery cassandraQuery = getQueryMethod("findByMainAddress", AddressType.class); CassandraParameterAccessor accessor = new ConvertingParameterAccessor(converter, - new CassandraParametersParameterAccessor(cassandraQuery.getQueryMethod(), new Address())); + new CassandraParametersParameterAccessor(cassandraQuery.getQueryMethod(), new AddressType())); SimpleStatement stringQuery = cassandraQuery.createQuery(accessor); @@ -383,7 +383,7 @@ public class StringBasedCassandraQueryUnitTests { Person findByCreatedDate(LocalDate createdDate); @Query("SELECT * FROM person WHERE address=?0;") - Person findByMainAddress(Address address); + Person findByMainAddress(AddressType address); @Query("SELECT * FROM person WHERE address=?0;") Person findByMainAddress(UDTValue udtValue); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/AbstractSpringDataEmbeddedCassandraIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/AbstractSpringDataEmbeddedCassandraIntegrationTest.java similarity index 78% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/AbstractSpringDataEmbeddedCassandraIntegrationTest.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/AbstractSpringDataEmbeddedCassandraIntegrationTest.java index e2538191c..c0740cda8 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/AbstractSpringDataEmbeddedCassandraIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/AbstractSpringDataEmbeddedCassandraIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors + * Copyright 2017 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,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.cassandra.test.integration.support; +package org.springframework.data.cassandra.repository.support; import java.util.stream.Stream; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.cassandra.AbstractEmbeddedCassandraIntegrationTest; import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; @@ -32,8 +30,6 @@ import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; public abstract class AbstractSpringDataEmbeddedCassandraIntegrationTest extends AbstractEmbeddedCassandraIntegrationTest { - public final Logger log = LoggerFactory.getLogger(getClass()); - @Autowired private CassandraOperations template; /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/IntegrationTestConfig.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/IntegrationTestConfig.java similarity index 87% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/IntegrationTestConfig.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/IntegrationTestConfig.java index fc44f3013..2be92c82a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/IntegrationTestConfig.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/IntegrationTestConfig.java @@ -1,11 +1,11 @@ /* - * Copyright 2013-2017 the original author or authors + * Copyright 2017 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.support; +package org.springframework.data.cassandra.repository.support; import static org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification.*; @@ -22,9 +22,9 @@ import java.util.List; import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification; import org.springframework.cassandra.core.keyspace.DropKeyspaceSpecification; +import org.springframework.cassandra.support.CassandraConnectionProperties; +import org.springframework.cassandra.support.IntegrationTestNettyOptions; import org.springframework.cassandra.support.RandomKeySpaceName; -import org.springframework.cassandra.test.integration.support.CassandraConnectionProperties; -import org.springframework.cassandra.test.integration.support.IntegrationTestNettyOptions; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.config.SchemaAction; import org.springframework.data.cassandra.config.java.AbstractReactiveCassandraConfiguration; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/SchemaTestUtils.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SchemaTestUtils.java similarity index 95% rename from spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/SchemaTestUtils.java rename to spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SchemaTestUtils.java index 95c2a1985..8efc0d63b 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/SchemaTestUtils.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SchemaTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2017 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.support; +package org.springframework.data.cassandra.repository.support; import org.springframework.cassandra.core.SessionCallback; import org.springframework.cassandra.core.cql.generator.CreateTableCqlGenerator; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryIntegrationTests.java index e24bb26d1..61d1a66bc 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryIntegrationTests.java @@ -29,12 +29,11 @@ import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.core.CassandraOperations; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.repository.TypedIdCassandraRepository; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; import org.springframework.data.repository.query.DefaultEvaluationContextProvider; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -54,7 +53,7 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC @Override public String[] getEntityBasePackages() { - return new String[] { Person.class.getPackage().getName() }; + return new String[] { User.class.getPackage().getName() }; } } @@ -63,9 +62,9 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC CassandraRepositoryFactory factory; ClassLoader classLoader; BeanFactory beanFactory; - PersonRepostitory repository; + UserRepostitory repository; - Person dave, oliver, carter, boyd; + User dave, oliver, carter, boyd; @Override public void setBeanClassLoader(ClassLoader classLoader) { @@ -86,14 +85,14 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC factory.setBeanFactory(beanFactory); factory.setEvaluationContextProvider(DefaultEvaluationContextProvider.INSTANCE); - repository = factory.getRepository(PersonRepostitory.class); + repository = factory.getRepository(UserRepostitory.class); repository.deleteAll(); - dave = new Person("42", "Dave", "Matthews"); - oliver = new Person("4", "Oliver August", "Matthews"); - carter = new Person("49", "Carter", "Beauford"); - boyd = new Person("45", "Boyd", "Tinsley"); + dave = new User("42", "Dave", "Matthews"); + oliver = new User("4", "Oliver August", "Matthews"); + carter = new User("49", "Carter", "Beauford"); + boyd = new User("45", "Boyd", "Tinsley"); repository.saveAll(Arrays.asList(oliver, dave, carter, boyd)); } @@ -125,33 +124,33 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC @Test // DATACASS-396 public void findByIdShouldReturnObject() { - Optional person = repository.findById(dave.getId()); + Optional User = repository.findById(dave.getId()); - assertThat(person).contains(dave); + assertThat(User).contains(dave); } @Test // DATACASS-396 public void findByIdShouldCompleteWithoutValueForAbsentObject() { - Optional person = repository.findById("unknown"); + Optional User = repository.findById("unknown"); - assertThat(person).isEmpty(); + assertThat(User).isEmpty(); } @Test // DATACASS-396, DATACASS-416 public void findAllShouldReturnAllResults() { - List persons = repository.findAll(); + List Users = repository.findAll(); - assertThat(persons).hasSize(4); + assertThat(Users).hasSize(4); } @Test // DATACASS-396, DATACASS-416 public void findAllByIterableOfIdShouldReturnResults() { - List persons = repository.findAllById(Arrays.asList(dave.getId(), boyd.getId())); + List Users = repository.findAllById(Arrays.asList(dave.getId(), boyd.getId())); - assertThat(persons).hasSize(2); + assertThat(Users).hasSize(2); } @Test // DATACASS-396 @@ -167,9 +166,9 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC repository.deleteAll(); - Person person = new Person("36", "Homer", "Simpson"); + User User = new User("36", "Homer", "Simpson"); - repository.insert(person); + repository.insert(User); assertThat(repository.count()).isEqualTo(1); } @@ -190,11 +189,11 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC dave.setFirstname("Hello, Dave"); dave.setLastname("Bowman"); - Person saved = repository.save(dave); + User saved = repository.save(dave); assertThat(saved).isEqualTo(saved); - Optional loaded = repository.findById(dave.getId()); + Optional loaded = repository.findById(dave.getId()); assertThat(loaded).isPresent(); @@ -207,15 +206,15 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC @Test // DATACASS-396 public void saveEntityShouldInsertNewEntity() { - Person person = new Person("36", "Homer", "Simpson"); + User User = new User("36", "Homer", "Simpson"); - Person saved = repository.save(person); + User saved = repository.save(User); - assertThat(saved).isEqualTo(person); + assertThat(saved).isEqualTo(User); - Optional loaded = repository.findById(person.getId()); + Optional loaded = repository.findById(User.getId()); - assertThat(loaded).contains(person); + assertThat(loaded).contains(User); } @Test // DATACASS-396, DATACASS-416 @@ -223,7 +222,7 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC repository.deleteAll(); - List saved = repository.saveAll(Arrays.asList(dave, oliver, boyd)); + List saved = repository.saveAll(Arrays.asList(dave, oliver, boyd)); assertThat(saved).hasSize(3); @@ -233,20 +232,20 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC @Test // DATACASS-396, DATACASS-416 public void saveIterableOfMixedEntitiesShouldInsertEntity() { - Person person = new Person("36", "Homer", "Simpson"); + User User = new User("36", "Homer", "Simpson"); dave.setFirstname("Hello, Dave"); dave.setLastname("Bowman"); - List saved = repository.saveAll(Arrays.asList(person, dave)); + List saved = repository.saveAll(Arrays.asList(User, dave)); assertThat(saved).hasSize(2); - Optional persistentDave = repository.findById(dave.getId()); + Optional persistentDave = repository.findById(dave.getId()); assertThat(persistentDave).contains(dave); - Optional persistentHomer = repository.findById(person.getId()); - assertThat(persistentHomer).contains(person); + Optional persistentHomer = repository.findById(User.getId()); + assertThat(persistentHomer).contains(User); } @Test // DATACASS-396, DATACASS-416 @@ -254,7 +253,7 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC repository.deleteAll(); - List result = repository.findAll(); + List result = repository.findAll(); assertThat(result).isEmpty(); } @@ -264,7 +263,7 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC repository.deleteById(dave.getId()); - Optional loaded = repository.findById(dave.getId()); + Optional loaded = repository.findById(dave.getId()); assertThat(loaded).isEmpty(); } @@ -274,7 +273,7 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC repository.delete(dave); - Optional loaded = repository.findById(dave.getId()); + Optional loaded = repository.findById(dave.getId()); assertThat(loaded).isEmpty(); } @@ -284,10 +283,10 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC repository.deleteAll(Arrays.asList(dave, boyd)); - Optional loaded = repository.findById(boyd.getId()); + Optional loaded = repository.findById(boyd.getId()); assertThat(loaded).isEmpty(); } - interface PersonRepostitory extends TypedIdCassandraRepository {} + interface UserRepostitory extends TypedIdCassandraRepository {} } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryUnitTests.java index 746779e02..95f140c1c 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryUnitTests.java @@ -30,10 +30,10 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.data.annotation.Id; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.CassandraOperations; +import org.springframework.data.cassandra.domain.Person; import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; import org.springframework.data.cassandra.mapping.UserTypeResolver; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; /** * Unit tests for {@link SimpleCassandraRepository}. diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleReactiveCassandraRepositoryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleReactiveCassandraRepositoryIntegrationTests.java index f21a9400d..a5319b7ec 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleReactiveCassandraRepositoryIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleReactiveCassandraRepositoryIntegrationTests.java @@ -31,12 +31,11 @@ import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.core.ReactiveCassandraOperations; -import org.springframework.data.cassandra.domain.Person; +import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.repository.ReactiveCassandraRepository; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; import org.springframework.data.repository.query.DefaultEvaluationContextProvider; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -56,7 +55,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK @Override public String[] getEntityBasePackages() { - return new String[] { Person.class.getPackage().getName() }; + return new String[] { User.class.getPackage().getName() }; } } @@ -65,9 +64,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK ReactiveCassandraRepositoryFactory factory; ClassLoader classLoader; BeanFactory beanFactory; - PersonRepostitory repository; + UserRepostitory repository; - Person dave, oliver, carter, boyd; + User dave, oliver, carter, boyd; @Override public void setBeanClassLoader(ClassLoader classLoader) { @@ -88,14 +87,14 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK factory.setBeanFactory(beanFactory); factory.setEvaluationContextProvider(DefaultEvaluationContextProvider.INSTANCE); - repository = factory.getRepository(PersonRepostitory.class); + repository = factory.getRepository(UserRepostitory.class); deleteAll(); - dave = new Person("42", "Dave", "Matthews"); - oliver = new Person("4", "Oliver August", "Matthews"); - carter = new Person("49", "Carter", "Beauford"); - boyd = new Person("45", "Boyd", "Tinsley"); + dave = new User("42", "Dave", "Matthews"); + oliver = new User("4", "Oliver August", "Matthews"); + carter = new User("49", "Carter", "Beauford"); + boyd = new User("45", "Boyd", "Tinsley"); } private void insertTestData() { @@ -203,7 +202,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK @Test // DATACASS-335 public void insertEntityShouldInsertEntity() { - Person person = new Person("36", "Homer", "Simpson"); + User person = new User("36", "Homer", "Simpson"); StepVerifier.create(repository.insert(person)).expectNext(person).verifyComplete(); @@ -213,7 +212,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK @Test // DATACASS-335 public void insertShouldDeferredWrite() { - Person person = new Person("36", "Homer", "Simpson"); + User person = new User("36", "Homer", "Simpson"); repository.insert(person); @@ -254,7 +253,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK @Test // DATACASS-335 public void saveEntityShouldInsertNewEntity() { - Person person = new Person("36", "Homer", "Simpson"); + User person = new User("36", "Homer", "Simpson"); StepVerifier.create(repository.save(person)).expectNextCount(1).verifyComplete(); @@ -272,7 +271,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK @Test // DATACASS-335 public void saveIterableOfMixedEntitiesShouldInsertEntity() { - Person person = new Person("36", "Homer", "Simpson"); + User person = new User("36", "Homer", "Simpson"); dave.setFirstname("Hello, Dave"); dave.setLastname("Bowman"); @@ -334,5 +333,5 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK StepVerifier.create(repository.findById(boyd.getId())).expectNextCount(0).verifyComplete(); } - interface PersonRepostitory extends ReactiveCassandraRepository {} + interface UserRepostitory extends ReactiveCassandraRepository {} } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderIntegrationTests.java deleted file mode 100755 index b77479a52..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/collections/CollectionsRowValueProviderIntegrationTests.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2011-2017 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.collections; - -import static org.assertj.core.api.Assertions.*; - -import java.io.IOException; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; -import org.springframework.data.cassandra.core.CassandraOperations; -import org.springframework.data.cassandra.core.CassandraTemplate; -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; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; - -import com.datastax.driver.core.querybuilder.QueryBuilder; -import com.datastax.driver.core.querybuilder.Select; - -/** - * @author dwebb - * @author Mark Paluch - */ -public class CollectionsRowValueProviderIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { - - CassandraOperations operations; - - @Before - public void before() throws IOException { - - operations = new CassandraTemplate(session); - - SchemaTestUtils.potentiallyCreateTableFor(Book.class, operations); - SchemaTestUtils.potentiallyCreateTableFor(BookHistory.class, operations); - SchemaTestUtils.potentiallyCreateTableFor(BookReference.class, operations); - - SchemaTestUtils.truncate(Book.class, operations); - SchemaTestUtils.truncate(BookHistory.class, operations); - SchemaTestUtils.truncate(BookReference.class, operations); - } - - @Test - public void mapTest() { - - BookHistory b1 = new BookHistory(); - b1.setIsbn("123456-1"); - b1.setTitle("Spring Data Cassandra Guide"); - b1.setAuthor("Cassandra Guru"); - b1.setPages(521); - b1.setSaleDate(new Date()); - b1.setInStock(true); - - Map checkOutMap = new HashMap<>(); - checkOutMap.put("dwebb", 50); - checkOutMap.put("madams", 100); - checkOutMap.put("jmcpeek", 150); - - b1.setCheckOuts(checkOutMap); - - operations.insert(b1); - - Select select = QueryBuilder.select().all().from("bookHistory"); - select.where(QueryBuilder.eq("isbn", "123456-1")); - - BookHistory result = operations.selectOne(select, BookHistory.class); - - assertThat(result.getCheckOuts()).isNotNull(); - assertThat(result.getTitle()).isEqualTo("Spring Data Cassandra Guide"); - assertThat(result.getAuthor()).isEqualTo("Cassandra Guru"); - } - - @Test - public void listSetTest() { - - BookReference b1 = new BookReference(); - b1.setIsbn("123456-1"); - b1.setTitle("Spring Data Cassandra Guide"); - b1.setAuthor("Cassandra Guru"); - b1.setPages(521); - b1.setSaleDate(new Date()); - b1.setInStock(true); - - Set refs = new HashSet<>(); - refs.add("Spring Data by O'Reilly"); - refs.add("Spring by Example"); - refs.add("Spring Recipies"); - b1.setReferences(refs); - - List marks = new LinkedList<>(); - marks.add(13); - marks.add(52); - marks.add(144); - b1.setBookmarks(marks); - - operations.insert(b1); - - Select select = QueryBuilder.select().all().from("bookReference"); - select.where(QueryBuilder.eq("isbn", "123456-1")); - - BookReference result = operations.selectOne(select, BookReference.class); - - assertThat(result.getReferences()).isNotNull(); - assertThat(result.getBookmarks()).isNotNull(); - assertThat(result.getTitle()).isEqualTo("Spring Data Cassandra Guide"); - assertThat(result.getAuthor()).isEqualTo("Cassandra Guru"); - - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudIntegrationTests.java index 6ee20562a..95f3c738a 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/forcequote/compositeprimarykey/CompositeKeyCrudIntegrationTests.java @@ -24,12 +24,12 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.QueryOptions; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.core.CassandraTemplate; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey.entity.CorrelationEntity; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; import com.datastax.driver.core.ConsistencyLevel; import com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy; 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 f9c844a3f..c115369c8 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 @@ -20,7 +20,7 @@ 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.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** 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 cf62e360c..93b8084f4 100755 --- 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 @@ -18,7 +18,7 @@ package org.springframework.data.cassandra.test.integration.forcequote.composite import org.junit.Test; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.test.context.ContextConfiguration; /** 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 688b6d438..fc59b9059 100755 --- 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 @@ -20,7 +20,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.cassandra.core.CassandraOperations; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** 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 1ecaaa8f6..3438a31bf 100755 --- 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 @@ -18,7 +18,7 @@ package org.springframework.data.cassandra.test.integration.forcequote.config; import org.junit.Test; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.test.context.ContextConfiguration; /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTests.java index 8f8a4a3ca..248ecfc8d 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/proxy/CassandraTemplateMapIdProxyDelegateIntegrationTests.java @@ -20,15 +20,15 @@ import static org.springframework.data.cassandra.repository.support.MapIdFactory import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.PrimaryKeyType; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.core.CassandraTemplate; import org.springframework.data.cassandra.mapping.Column; import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.mapping.Table; import org.springframework.data.cassandra.repository.MapId; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; /** * Integration tests for {@link org.springframework.data.cassandra.core.CassandraTemplate} using {@link MapId}. diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTests.java index a6906b1cf..cb4fb8773 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/mapping/mapid/repo/RepositoryMapIdIntegrationTests.java @@ -26,8 +26,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.repository.MapId; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; +import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 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 fea8ae405..fa47e5e99 100755 --- 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 @@ -21,15 +21,15 @@ import static org.springframework.data.cassandra.repository.support.BasicMapId.* import org.junit.Before; import org.junit.Test; +import org.springframework.cassandra.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.cassandra.core.PrimaryKeyType; -import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest; import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.core.CassandraTemplate; import org.springframework.data.cassandra.mapping.Column; import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.mapping.Table; import org.springframework.data.cassandra.repository.MapId; -import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils; +import org.springframework.data.cassandra.repository.support.SchemaTestUtils; /** * Integration tests for {@link org.springframework.data.cassandra.core.CassandraTemplate} with {@link MapId}. diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTests.java deleted file mode 100755 index 6ab8dc89b..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/AbsoluteMinimumXmlConfigIntegrationTests.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2017 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.minimal.config; - -import static org.assertj.core.api.Assertions.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.cassandra.mapping.CassandraMappingContext; -import org.springframework.data.cassandra.test.integration.minimal.config.entities.AbsMin; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -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 AbsoluteMinimumXmlConfigIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { - - @Autowired CassandraMappingContext context; - - @Test - public void test() { - - assertThat(context).isNotNull(); - 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 deleted file mode 100644 index e9c20d860..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMin.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013-2017 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.minimal.config.entities; - -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; - -} 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 deleted file mode 100644 index 2d0a4679a..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/minimal/config/entities/AbsMinRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2017 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.minimal.config.entities; - -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/repository/querymethods/bigintparam/BigThing.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThing.java deleted file mode 100644 index b0dfac936..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThing.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2016-2017 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 deleted file mode 100644 index 2205bff32..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/bigintparam/BigThingRepo.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2016-2017 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/repository/querymethods/datekey/DateThing.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThing.java deleted file mode 100644 index ad8a455bf..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThing.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2016-2017 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, "Date must not be null"); - 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 deleted file mode 100644 index 7ab5dd1fa..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/datekey/DateThingRepo.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2016-2017 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/repository/querymethods/declared/Person.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/Person.java deleted file mode 100644 index 574e38351..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/Person.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2016-2017 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 lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDate; -import java.time.ZoneId; -import java.util.Date; -import java.util.List; - -import org.springframework.cassandra.core.PrimaryKeyType; -import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; -import org.springframework.data.cassandra.mapping.Table; - -/** - * Sample domain class. - * - * @author Mark Paluch - */ -@Table -@Data -@NoArgsConstructor -public class Person { - - @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0) private String lastname; - - @PrimaryKeyColumn(type = PrimaryKeyType.CLUSTERED, ordinal = 1) private String firstname; - - private String nickname; - private Date birthDate; - private int numberOfChildren; - private boolean cool; - - private LocalDate createdDate; - private ZoneId zoneId; - - private Address mainAddress; - private List
alternativeAddresses; - - public Person(String firstname, String lastname) { - - this.firstname = firstname; - this.lastname = lastname; - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/anno/PersonRepositoryWithQueryAnnotations.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/anno/PersonRepositoryWithQueryAnnotations.java deleted file mode 100644 index fa92daae1..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/anno/PersonRepositoryWithQueryAnnotations.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2016-2017 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.anno; - -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Stream; - -import org.springframework.data.cassandra.repository.Query; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.base.PersonRepository; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.named.PersonRepositoryWithNamedQueries; -import org.springframework.data.repository.query.Param; - -import com.datastax.driver.core.ResultSet; - -/** - * we extend {@link PersonRepositoryWithNamedQueries} here just to keep the test codebase in sync. - * - * @author Matthew T. Adams - */ -public interface PersonRepositoryWithQueryAnnotations extends PersonRepository { - - @Override - @Query("select * from person where lastname = ?0") - List findFolksWithLastnameAsList(String lastname); - - @Override - @Query("select * from person where lastname = ?0") - ResultSet findFolksWithLastnameAsResultSet(String last); - - @Override - @Query("select * from person where lastname = ?0") - Person[] findFolksWithLastnameAsArray(String lastname); - - @Override - @Query("select * from person where lastname = ?#{[0]} and firstname = ?1") - Person findSingle(String last, String first); - - @Override - @Query("select * from person where lastname = :last") - List> findFolksWithLastnameAsListOfMapOfStringToObject(@Param("last") String last); - - @Override - @Query("select nickname from person where lastname = :#{#last} and firstname = ?1") - String findSingleNickname(@Param("last") String last, @Param("first") String first); - - @Override - @Query("select birthdate from person where lastname = ?0 and firstname = ?1") - Date findSingleBirthdate(String last, String first); - - @Override - @Query("select cool from person where lastname = ?0 and firstname = ?1") - boolean findSingleCool(String last, String first); - - @Override - @Query("select numberofchildren from person where lastname = ?0 and firstname = ?1") - int findSingleNumberOfChildren(String last, String first); - - @Override - @Query("select * from person where lastname = ?0 and firstname = ?1") - Optional findOptionalWithLastnameAndFirstname(String last, String first); - - @Override - @Query("select * from person") - Stream findAllPeople(); - -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/anno/QueryAnnotationIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/anno/QueryAnnotationIntegrationTests.java deleted file mode 100755 index 1d8e80870..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/anno/QueryAnnotationIntegrationTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2016-2017 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.anno; - -import org.springframework.context.annotation.Configuration; -import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.QueryIntegrationTests; -import org.springframework.test.context.ContextConfiguration; - -/** - * @author Matthew T. Adams - */ -@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/repository/querymethods/declared/base/PersonRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/base/PersonRepository.java deleted file mode 100644 index 91540e5ff..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/base/PersonRepository.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2016-2017 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.base; - -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Stream; - -import org.springframework.data.cassandra.repository.CassandraRepository; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; -import org.springframework.data.repository.NoRepositoryBean; - -import com.datastax.driver.core.ResultSet; - -/** - * @author Matthew T. Adams - * @author Mark Paluch - */ -@NoRepositoryBean -public interface PersonRepository extends CassandraRepository { - - List findFolksWithLastnameAsList(String lastname); - - ResultSet findFolksWithLastnameAsResultSet(String last); - - Person[] findFolksWithLastnameAsArray(String lastname); - - Person findSingle(String last, String first); - - List> findFolksWithLastnameAsListOfMapOfStringToObject(String last); - - String findSingleNickname(String last, String first); - - Date findSingleBirthdate(String last, String first); - - boolean findSingleCool(String last, String first); - - int findSingleNumberOfChildren(String last, String first); - - Optional findOptionalWithLastnameAndFirstname(String last, String first); - - Stream findAllPeople(); -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/named/NamedQueryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/named/NamedQueryIntegrationTests.java deleted file mode 100755 index ba23f518d..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/named/NamedQueryIntegrationTests.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2016-2017 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.named; - -import org.springframework.context.annotation.Configuration; -import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.repository.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/repository/querymethods/declared/named/PersonRepositoryWithNamedQueries.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/named/PersonRepositoryWithNamedQueries.java deleted file mode 100644 index d420b2899..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/named/PersonRepositoryWithNamedQueries.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2016-2017 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.named; - -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.base.PersonRepository; - -public interface PersonRepositoryWithNamedQueries extends PersonRepository {} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/derived/PersonRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/derived/PersonRepository.java deleted file mode 100644 index 90a40f9e8..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/derived/PersonRepository.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2016-2017 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.derived; - -import java.time.LocalDate; -import java.util.Collection; -import java.util.List; - -import org.springframework.data.cassandra.repository.CassandraRepository; -import org.springframework.data.cassandra.repository.Query; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Address; -import org.springframework.data.cassandra.test.integration.repository.querymethods.declared.Person; -import org.springframework.data.domain.Sort; - -/** - * @author Mark Paluch - */ -interface PersonRepository extends CassandraRepository { - - List findByLastname(String lastname); - - List findByLastname(String lastname, Sort sort); - - List findByLastnameOrderByFirstnameAsc(String lastname); - - Person findByFirstnameAndLastname(String firstname, String lastname); - - Person findByMainAddress(Address address); - - @Query("select * from person where mainaddress = ?0") - Person findByAddress(Address address); - - Person findByCreatedDate(LocalDate createdDate); - - Person findByNicknameStartsWith(String prefix); - - Person findByNicknameContains(String contains); - - Person findByNumberOfChildren(NumberOfChildren numberOfChildren); - - Collection findPersonProjectedBy(); - - Collection findPersonDtoBy(); - - T findDtoByNicknameStartsWith(String prefix, Class projectionType); - - @Query("select * from person where firstname = ?0 and lastname = 'White'") - List findByFirstname(String firstname); - - enum NumberOfChildren { - ZERO, ONE, TWO, - } - - interface PersonProjection { - - String getFirstname(); - - String getLastname(); - } - - class PersonDto { - - public String firstname, lastname; - - public PersonDto(String firstname, String lastname) { - this.firstname = firstname; - this.lastname = lastname; - } - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/intparam/IntThing.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/intparam/IntThing.java deleted file mode 100644 index 12c30e853..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/intparam/IntThing.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2016-2017 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.intparam; - -import org.springframework.cassandra.core.PrimaryKeyType; -import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; -import org.springframework.data.cassandra.mapping.Table; - -/** - * @author Matthew T. Adams - */ -@Table -public class IntThing { - - @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private int number; - - public IntThing() {} - - public IntThing(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/repository/querymethods/intparam/IntThingRepo.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/intparam/IntThingRepo.java deleted file mode 100644 index ff7d73178..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/intparam/IntThingRepo.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2016-2017 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.intparam; - -import org.springframework.data.cassandra.repository.CassandraRepository; -import org.springframework.data.cassandra.repository.Query; - -/** - * @author Matthew T. Adams - */ -public interface IntThingRepo extends CassandraRepository { - - @Query("SELECT * from intthing where number = ?0") - IntThing findThingByIntPrimitive(int number); - - @Query("SELECT * from intthing where number = ?0") - IntThing findThingByIntReference(Integer number); -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/User.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/User.java deleted file mode 100644 index 6598a6613..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/User.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2016-2017 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.simple; - -import java.util.Set; - -import org.springframework.data.annotation.Id; -import org.springframework.data.cassandra.mapping.Indexed; -import org.springframework.data.cassandra.mapping.Table; - -/** - * This is an example of the Users status table, where all fields are columns in Cassandra row. Some fields can be - * Set,List,Map like emails. User contains base information related for separate user, like names, additional - * information, emails, following users, friends. - * - * @author Alex Shvid - * @author Mark Paluch - */ -@Table("users") -public class User { - - /* - * Primary Row ID - */ - @Id private String username; - - /* - * Public information - */ - private String firstName; - private String lastName; - - /* - * Secondary index, used only on fields with common information, - * not effective on email, username - */ - @Indexed private String place; - - /* - * User emails - */ - private Set emails; - - /* - * Password - */ - private String password; - - /* - * Birth Year - */ - private int birthYear; - - /* - * Following other users in userline - */ - private Set following; - - /* - * Friends of the user - */ - private Set friends; - - private AddressType address; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getPlace() { - return place; - } - - public void setPlace(String place) { - this.place = place; - } - - public Set getEmails() { - return emails; - } - - public void setEmails(Set emails) { - this.emails = emails; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Set getFollowing() { - return following; - } - - public void setFollowing(Set following) { - this.following = following; - } - - public Set getFriends() { - return friends; - } - - public void setFriends(Set friends) { - this.friends = friends; - } - - /** - * @return Returns the birthYear. - */ - public int getBirthYear() { - return birthYear; - } - - /** - * @param birthYear The birthYear to set. - */ - public void setBirthYear(int birthYear) { - this.birthYear = birthYear; - } - - public AddressType getAddress() { - return address; - } - - public void setAddress(AddressType address) { - this.address = address; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((username == null) ? 0 : username.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - User other = (User) obj; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; - return true; - } - -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepository.java deleted file mode 100644 index cf0e759cd..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepository.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2016-2017 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.simple; - -import org.springframework.data.cassandra.repository.TypedIdCassandraRepository; - -/** - * Sample repository managing {@link User} entities. - * - * @author Alex Shvid - * @author Matthew T. Adams - */ -public interface UserRepository extends TypedIdCassandraRepository { - - String findByNamedQuery(String username); - - User findByAddress(AddressType addressType); -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryIntegrationTests.java deleted file mode 100755 index a244e729a..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryIntegrationTests.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2016-2017 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.simple; - -import static org.assertj.core.api.Assertions.*; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.springframework.data.cassandra.core.CassandraOperations; - -import com.google.common.collect.Lists; - -/** - * Tests for {@link UserRepository}. - * - * @author Alex Shvid - * @author Matthew T. Adams - * @author David Webb - * @author Mark Paluch - */ -public class UserRepositoryIntegrationTests { - - UserRepository repository; - - CassandraOperations template; - - User tom, bob, alice, scott; - - List all; - - public UserRepositoryIntegrationTests(UserRepository repository, CassandraOperations template) { - this.repository = repository; - this.template = template; - } - - public void setUp() { - - template.getCqlOperations().execute("CREATE INDEX IF NOT EXISTS users_address ON users (address);"); - - repository.deleteAll(); - - tom = new User(); - tom.setUsername("tom"); - tom.setFirstName("Tom"); - tom.setLastName("Ron"); - tom.setPassword("123"); - tom.setPlace("SF"); - - AddressType address = new AddressType(); - address.setCity("San Francisco"); - address.setStreet("Golden Gate Way 1"); - - tom.setAddress(address); - - bob = new User(); - bob.setUsername("bob"); - bob.setFirstName("Bob"); - bob.setLastName("White"); - bob.setPassword("555"); - bob.setPlace("NY"); - - alice = new User(); - alice.setUsername("alice"); - alice.setFirstName("Alice"); - alice.setLastName("Red"); - alice.setPassword("777"); - alice.setPlace("LA"); - - scott = new User(); - scott.setUsername("scott"); - scott.setFirstName("Scott"); - scott.setLastName("Van"); - scott.setPassword("444"); - scott.setPlace("Boston"); - - all = Arrays.asList(tom, bob, alice, scott); - template.batchOps().insert(all).execute(); - } - - public void before() { - repository.deleteAll(); - setUp(); - } - - public void findByNamedQuery() { - String name = repository.findByNamedQuery("bob"); - assertThat(name).isNotNull(); - assertThat(name).isEqualTo("Bob"); - } - - public void findByDerivedQuery() { - - User user = repository.findByAddress(tom.getAddress()); - - assertThat(user).isNotNull().isEqualTo(tom); - } - - public void findsUserById() throws Exception { - - Optional user = repository.findById(tom.getUsername()); - assertThat(user).isNotNull().contains(tom); - - } - - public void findsAll() throws Exception { - - List result = Lists.newArrayList(repository.findAll()); - - assertThat(result).hasSize(all.size()); - assertThat(result.containsAll(all)).isTrue(); - } - - public void findsAllWithGivenIds() { - - Iterable result = repository.findAllById(Arrays.asList(bob.getUsername(), tom.getUsername())); - - assertThat(result).contains(bob, tom); - assertThat(result).doesNotContain(alice, scott); - } - - public void deletesUserCorrectly() throws Exception { - - repository.delete(tom); - - List result = Lists.newArrayList(repository.findAll()); - - assertThat(result).hasSize(all.size() - 1); - assertThat(result).doesNotContain(tom); - } - - public void deletesUserByIdCorrectly() { - - repository.deleteById(tom.getUsername()); - - List result = Lists.newArrayList(repository.findAll()); - - assertThat(result).hasSize(all.size() - 1); - assertThat(result).doesNotContain(tom); - } - - public void exists() { - - String id = "tom"; - - assertThat(repository.existsById(id)).isTrue(); - - repository.deleteById(id); - - assertThat(repository.existsById(id)).isFalse(); - } - - // DATACASS-182 - public void save() { - - tom.setPassword(null); - tom.setFriends(Collections.emptySet()); - - repository.save(tom); - - Optional loadedTom = repository.findById(tom.getUsername()); - - assertThat(loadedTom).hasValueSatisfying(actual -> { - - assertThat(actual.getPassword()).isNull(); - assertThat(actual.getFriends()).isNull(); - }); - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryIntegrationTestsDelegator.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryIntegrationTestsDelegator.java deleted file mode 100644 index be7db52e4..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryIntegrationTestsDelegator.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2016-2017 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.simple; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.cassandra.core.CassandraOperations; -import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; - -/** - * Base class for Java config tests for {@link UserRepository}. - * - * @author Matthew T. Adams - * @author David Webb - * @author Mark Paluch - */ -public abstract class UserRepositoryIntegrationTestsDelegator - extends AbstractSpringDataEmbeddedCassandraIntegrationTest { - - @Autowired CassandraOperations template; - - @Autowired UserRepository repository; - - UserRepositoryIntegrationTests tests; - - @Before - public void before() { - tests = new UserRepositoryIntegrationTests(repository, template); - tests.before(); - } - - @Test - public void findByNamedQuery() { - tests.findByNamedQuery(); - } - - @Test - public void findByDerivedQuery() { - tests.findByDerivedQuery(); - } - - @Test - public void findsUserById() throws Exception { - tests.findsUserById(); - } - - @Test - public void findsAll() throws Exception { - tests.findsAll(); - } - - @Test - public void findsAllWithGivenIds() { - tests.findsAllWithGivenIds(); - } - - @Test - public void deletesUserCorrectly() throws Exception { - tests.deletesUserCorrectly(); - } - - @Test - public void deletesUserByIdCorrectly() { - tests.deletesUserByIdCorrectly(); - } - - @Test - public void exists() { - tests.exists(); - } - - @Test // DATACASS-182 - public void save() { - tests.save(); - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryJavaConfigCustomRepositoryBaseClassIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryJavaConfigCustomRepositoryBaseClassIntegrationTests.java deleted file mode 100755 index 3c10fd606..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryJavaConfigCustomRepositoryBaseClassIntegrationTests.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2016-2017 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.simple; - -import static org.assertj.core.api.Assertions.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.aop.framework.Advised; -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.repository.query.CassandraEntityInformation; -import org.springframework.data.cassandra.repository.support.SimpleCassandraRepository; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * Java config tests for {@link UserRepository}. - * - * @author Thomas Darimont - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class UserRepositoryJavaConfigCustomRepositoryBaseClassIntegrationTests - extends UserRepositoryIntegrationTestsDelegator { - - @Configuration - @EnableCassandraRepositories(basePackageClasses = UserRepository.class, - repositoryBaseClass = CustomCassandraRepository.class) - public static class Config extends IntegrationTestConfig { - - @Override - public String[] getEntityBasePackages() { - return new String[] { User.class.getPackage().getName() }; - } - } - - @Test // DATACASS-211 - public void targetRepositoryClassShouldBeConfiguredCustomBaseRepositoryClass() throws Exception { - assertThat(((Advised) repository).getTargetSource().getTarget()).isInstanceOf(CustomCassandraRepository.class); - } - - public static class CustomCassandraRepository extends SimpleCassandraRepository { - - public CustomCassandraRepository(CassandraEntityInformation metadata, CassandraOperations operations) { - super(metadata, operations); - } - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryJavaConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryJavaConfigIntegrationTests.java deleted file mode 100755 index ba2ab85d6..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryJavaConfigIntegrationTests.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2016-2017 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.simple; - -import org.junit.runner.RunWith; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; -import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * Java config tests for {@link UserRepository}. - * - * @author Matthew T. Adams - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class UserRepositoryJavaConfigIntegrationTests extends UserRepositoryIntegrationTestsDelegator { - - @Configuration - @EnableCassandraRepositories(basePackageClasses = UserRepository.class) - public static class Config extends IntegrationTestConfig { - - @Override - public String[] getEntityBasePackages() { - return new String[] { User.class.getPackage().getName() }; - } - } - -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryXmlConfigIntegrationTests.java deleted file mode 100755 index 6bda784e5..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryXmlConfigIntegrationTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016-2017 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.simple; - -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * xml config tests for {@link UserRepository}. - * - * @author Matthew T. Adams - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class UserRepositoryXmlConfigIntegrationTests extends UserRepositoryIntegrationTestsDelegator {} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookCondition.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookCondition.java deleted file mode 100644 index b86101b4c..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookCondition.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2016-2017 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.simpletons; - -/** - * @author Mark Paluch - */ -public enum BookCondition { - NEW, USED -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookHistory.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookHistory.java deleted file mode 100644 index 375941be8..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookHistory.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2013-2017 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.simpletons; - -import java.util.Date; -import java.util.Map; - -import org.springframework.data.cassandra.mapping.PrimaryKey; -import org.springframework.data.cassandra.mapping.Table; - -/** - * Test POJO - * - * @author David Webb - */ -@Table("bookHistory") -public class BookHistory { - - @PrimaryKey private String isbn; - - private String title; - private String author; - private int pages; - private Date saleDate; - private boolean isInStock; - private Map checkOuts; - - /** - * @return Returns the isbn. - */ - public String getIsbn() { - return isbn; - } - - /** - * @return Returns the saleDate. - */ - public Date getSaleDate() { - return saleDate; - } - - /** - * @param saleDate The saleDate to set. - */ - public void setSaleDate(Date saleDate) { - this.saleDate = saleDate; - } - - /** - * @return Returns the isInStock. - */ - public boolean isInStock() { - return isInStock; - } - - /** - * @param isInStock The isInStock to set. - */ - public void setInStock(boolean isInStock) { - this.isInStock = isInStock; - } - - /** - * @param isbn The isbn to set. - */ - public void setIsbn(String isbn) { - this.isbn = isbn; - } - - /** - * @return Returns the title. - */ - public String getTitle() { - return title; - } - - /** - * @param title The title to set. - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * @return Returns the author. - */ - public String getAuthor() { - return author; - } - - /** - * @param author The author to set. - */ - public void setAuthor(String author) { - this.author = author; - } - - /** - * @return Returns the pages. - */ - public int getPages() { - return pages; - } - - /** - * @param pages The pages to set. - */ - public void setPages(int pages) { - this.pages = pages; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("isbn -> " + isbn).append("\n"); - sb.append("tile -> " + title).append("\n"); - sb.append("author -> " + author).append("\n"); - sb.append("pages -> " + pages).append("\n"); - return sb.toString(); - } - - /** - * @return Returns the checkOuts. - */ - public Map getCheckOuts() { - return checkOuts; - } - - /** - * @param checkOuts The checkOuts to set. - */ - public void setCheckOuts(Map checkOuts) { - this.checkOuts = checkOuts; - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookReference.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookReference.java deleted file mode 100644 index 0886a62f7..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/BookReference.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2013-2017 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.simpletons; - -import java.util.Date; -import java.util.List; -import java.util.Set; - -import org.springframework.data.cassandra.mapping.PrimaryKey; -import org.springframework.data.cassandra.mapping.Table; - -/** - * Test POJO - * - * @author David Webb - */ -@Table("bookReference") -public class BookReference { - - @PrimaryKey private String isbn; - - private String title; - private String author; - private int pages; - private Date saleDate; - private boolean isInStock; - private Set references; - private List bookmarks; - - /** - * @return Returns the isbn. - */ - public String getIsbn() { - return isbn; - } - - /** - * @return Returns the saleDate. - */ - public Date getSaleDate() { - return saleDate; - } - - /** - * @param saleDate The saleDate to set. - */ - public void setSaleDate(Date saleDate) { - this.saleDate = saleDate; - } - - /** - * @return Returns the isInStock. - */ - public boolean isInStock() { - return isInStock; - } - - /** - * @param isInStock The isInStock to set. - */ - public void setInStock(boolean isInStock) { - this.isInStock = isInStock; - } - - /** - * @param isbn The isbn to set. - */ - public void setIsbn(String isbn) { - this.isbn = isbn; - } - - /** - * @return Returns the title. - */ - public String getTitle() { - return title; - } - - /** - * @param title The title to set. - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * @return Returns the author. - */ - public String getAuthor() { - return author; - } - - /** - * @param author The author to set. - */ - public void setAuthor(String author) { - this.author = author; - } - - /** - * @return Returns the pages. - */ - public int getPages() { - return pages; - } - - /** - * @param pages The pages to set. - */ - public void setPages(int pages) { - this.pages = pages; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("isbn -> " + isbn).append("\n"); - sb.append("tile -> " + title).append("\n"); - sb.append("author -> " + author).append("\n"); - sb.append("pages -> " + pages).append("\n"); - return sb.toString(); - } - - /** - * @return Returns the references. - */ - public Set getReferences() { - return references; - } - - /** - * @param references The references to set. - */ - public void setReferences(Set references) { - this.references = references; - } - - /** - * @return Returns the bookmarks. - */ - public List getBookmarks() { - return bookmarks; - } - - /** - * @param bookmarks The bookmarks to set. - */ - public void setBookmarks(List bookmarks) { - this.bookmarks = bookmarks; - } - -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/LogEntry.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/LogEntry.java deleted file mode 100644 index d5737724c..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/simpletons/LogEntry.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2013-2017 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.simpletons; - -import java.util.Date; - -import org.springframework.data.cassandra.mapping.PrimaryKey; -import org.springframework.data.cassandra.mapping.Table; - -/** - * This is an example of the LogEntry static table, where all fields are columns in Cassandra row. - * - * @author Alex Shvid - */ -@Table("log_entry") -public class LogEntry { - - /* - * Primary Key - */ - @PrimaryKey private Date logDate; - - private String hostname; - - private String logData; - - /** - * @return Returns the logDate. - */ - public Date getLogDate() { - return logDate; - } - - /** - * @param logDate The logDate to set. - */ - public void setLogDate(Date logDate) { - this.logDate = logDate; - } - - /** - * @return Returns the hostname. - */ - public String getHostname() { - return hostname; - } - - /** - * @param hostname The hostname to set. - */ - public void setHostname(String hostname) { - this.hostname = hostname; - } - - /** - * @return Returns the logData. - */ - public String getLogData() { - return logData; - } - - /** - * @param logData The logData to set. - */ - public void setLogData(String logData) { - this.logData = logData; - } - -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/TestListener.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/TestListener.java deleted file mode 100644 index aeb8b2ec3..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/support/TestListener.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.springframework.data.cassandra.test.integration.support; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * Convenient listener base class that includes a {@link CountDownLatch} in order to test asynchronous behavior. - * - * @author Matthew T. Adams - */ -public class TestListener { - - protected CountDownLatch latch; - - public TestListener() { - this(1); - } - - public TestListener(int latchCount) { - latch = new CountDownLatch(latchCount); - } - - public void await() throws InterruptedException { - latch.await(); - } - - public void await(long ms) throws InterruptedException { - latch.await(ms, TimeUnit.MILLISECONDS); - } - - public void countDown() { - latch.countDown(); - } -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/AnotherScannedEntity.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/AnotherScannedEntity.java deleted file mode 100644 index 5cb8a4117..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/AnotherScannedEntity.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2013-2017 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.xmlentityscanning; - -import org.springframework.data.annotation.Id; -import org.springframework.data.cassandra.mapping.Table; - -/** - * @author Matthew T. Adams - */ -@Table -public class AnotherScannedEntity { - - /* - * Primary Row ID - */ - @Id private String name; - - @SuppressWarnings("unused") - private AnotherScannedEntity() {} - - public AnotherScannedEntity(String name) { - setName(name); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - AnotherScannedEntity other = (AnotherScannedEntity) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/AnotherScannedEntityRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/AnotherScannedEntityRepository.java deleted file mode 100644 index b1900e7fc..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/AnotherScannedEntityRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2017 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.xmlentityscanning; - -import org.springframework.data.cassandra.repository.TypedIdCassandraRepository; - -/** - * @author Matthew T. Adams - */ -public interface AnotherScannedEntityRepository extends TypedIdCassandraRepository {} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/ScannedEntity.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/ScannedEntity.java deleted file mode 100644 index c5809705c..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/ScannedEntity.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2013-2017 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.xmlentityscanning; - -import org.springframework.data.annotation.Id; -import org.springframework.data.cassandra.mapping.Table; - -/** - * @author Matthew T. Adams - */ -@Table -public class ScannedEntity { - - /* - * Primary Row ID - */ - @Id private String name; - - @SuppressWarnings("unused") - private ScannedEntity() {} - - public ScannedEntity(String name) { - setName(name); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ScannedEntity other = (ScannedEntity) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - -} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/ScannedEntityRepository.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/ScannedEntityRepository.java deleted file mode 100644 index 78693cf17..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/ScannedEntityRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2017 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.xmlentityscanning; - -import org.springframework.data.cassandra.repository.TypedIdCassandraRepository; - -/** - * @author Matthew T. Adams - */ -public interface ScannedEntityRepository extends TypedIdCassandraRepository {} diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/XmlEntityScanningIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/XmlEntityScanningIntegrationTests.java deleted file mode 100755 index 4269098d7..000000000 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/xmlentityscanning/XmlEntityScanningIntegrationTests.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2017 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.xmlentityscanning; - -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.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Matthew T. Adams - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -public class XmlEntityScanningIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { - - @Autowired ScannedEntityRepository repository; - @Autowired AnotherScannedEntityRepository anotherRepository; - @Autowired CassandraOperations template; - - @Test - public void testInsertScannedEntity() { - repository.save(new ScannedEntity("one")); - } - - @Test - public void testInsertAnotherScannedEntity() { - anotherRepository.save(new AnotherScannedEntity("another")); - } -} diff --git a/spring-data-cassandra/src/test/resources/META-INF/PersonRepositoryWithNamedQueries.properties b/spring-data-cassandra/src/test/resources/META-INF/PersonRepositoryWithNamedQueries.properties index c7dc7fc52..02132c870 100644 --- a/spring-data-cassandra/src/test/resources/META-INF/PersonRepositoryWithNamedQueries.properties +++ b/spring-data-cassandra/src/test/resources/META-INF/PersonRepositoryWithNamedQueries.properties @@ -8,8 +8,5 @@ Person.findSingleBirthdate=select birthdate from person where lastname = ?0 and Person.findSingleCool=select cool from person where lastname = ?0 and firstname = ?1 Person.findSingleNumberOfChildren=select numberofchildren from person where lastname = ?0 and firstname = ?1 Person.findOptionalWithLastnameAndFirstname=select * from person where lastname = ?0 and firstname = ?1 -Person.findAllPeople=select * from person Person.findPeopleWithCreatedDate=select * from person where createddate = ?0 Person.findPeopleWithZoneId=select * from person where zoneid = ?0 - - diff --git a/spring-data-cassandra/src/test/resources/config/spring-data-cassandra-basic.xml b/spring-data-cassandra/src/test/resources/config/spring-data-cassandra-basic.xml index e82a7f217..81a77fb18 100644 --- a/spring-data-cassandra/src/test/resources/config/spring-data-cassandra-basic.xml +++ b/spring-data-cassandra/src/test/resources/config/spring-data-cassandra-basic.xml @@ -13,7 +13,7 @@ - + diff --git a/spring-data-cassandra/src/test/resources/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests-context.xml b/spring-data-cassandra/src/test/resources/org/springframework/cassandra/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests-context.xml similarity index 88% rename from spring-data-cassandra/src/test/resources/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests-context.xml rename to spring-data-cassandra/src/test/resources/org/springframework/cassandra/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests-context.xml index bbdb43aee..cb2472fa1 100644 --- a/spring-data-cassandra/src/test/resources/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests-context.xml +++ b/spring-data-cassandra/src/test/resources/org/springframework/cassandra/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests-context.xml @@ -8,9 +8,9 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + location="classpath:/config/cassandra-connection.properties,classpath:/org/springframework/cassandra/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.properties" /> - + + location="classpath:/org/springframework/cassandra/config/xml/ppncxct.properties"/> - + @@ -29,10 +29,10 @@ class="com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy"/> + class="org.springframework.cassandra.config.xml.TestHostStateListener"/> + class="org.springframework.cassandra.config.xml.TestLatencyTracker"/> - + - + - + diff --git a/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryXmlConfigIntegrationTests-context.xml b/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryXmlConfigIntegrationTests-context.xml index 945160c7a..c9e8b75d8 100644 --- a/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryXmlConfigIntegrationTests-context.xml +++ b/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/simple/UserRepositoryXmlConfigIntegrationTests-context.xml @@ -17,7 +17,7 @@ entity-base-packages="org.springframework.data.cassandra.test.integration.repository.simple" user-type-resolver-ref="userTypeResolver"> + class="org.springframework.data.cassandra.domain.User"> diff --git a/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/xmlentityscanning/XmlEntityScanningIntegrationTests-context.xml b/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/xmlentityscanning/XmlEntityScanningIntegrationTests-context.xml deleted file mode 100644 index d06609e90..000000000 --- a/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/xmlentityscanning/XmlEntityScanningIntegrationTests-context.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - -