diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/xml/CassandraDataNamespaceHandler.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/xml/CassandraDataNamespaceHandler.java
index db0e2b79f..fdd7fc80c 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/xml/CassandraDataNamespaceHandler.java
+++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/xml/CassandraDataNamespaceHandler.java
@@ -16,6 +16,8 @@
package org.springframework.data.cassandra.config.xml;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+import org.springframework.data.cassandra.repository.config.CassandraRepositoryConfigurationExtension;
+import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
/**
* Namespace handler for spring-data-cassandra.
@@ -28,6 +30,9 @@ public class CassandraDataNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
+ registerBeanDefinitionParser("repositories", new RepositoryBeanDefinitionParser(
+ new CassandraRepositoryConfigurationExtension()));
+
registerBeanDefinitionParser("cluster", new CassandraDataClusterParser());
registerBeanDefinitionParser("session", new CassandraDataSessionParser());
registerBeanDefinitionParser("template", new CassandraDataTemplateParser());
diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/config/CassandraRepositoryConfigurationExtension.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/config/CassandraRepositoryConfigurationExtension.java
index a687457e8..91b2fc35a 100644
--- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/config/CassandraRepositoryConfigurationExtension.java
+++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/config/CassandraRepositoryConfigurationExtension.java
@@ -16,9 +16,9 @@
package org.springframework.data.cassandra.repository.config;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.cassandra.config.xml.ParsingUtils;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.data.cassandra.repository.support.CassandraRepositoryFactoryBean;
-import org.springframework.data.config.ParsingUtils;
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport;
@@ -51,7 +51,8 @@ public class CassandraRepositoryConfigurationExtension extends RepositoryConfigu
Element element = config.getElement();
- ParsingUtils.setPropertyReference(builder, element, CASSANDRA_TEMPLATE_REF, "cassandraTemplate");
+ ParsingUtils.addOptionalPropertyReference(builder, "cassandraTemplate", element, CASSANDRA_TEMPLATE_REF,
+ "cassandra-template");
}
@Override
@@ -64,5 +65,4 @@ public class CassandraRepositoryConfigurationExtension extends RepositoryConfigu
builder.addPropertyReference("cassandraTemplate", cassandraTemplateRef);
}
}
-
}
diff --git a/spring-data-cassandra/src/main/resources/org/springframework/data/cassandra/config/spring-cassandra-1.0.xsd b/spring-data-cassandra/src/main/resources/org/springframework/data/cassandra/config/spring-cassandra-1.0.xsd
index f3980cbb5..bed6fd896 100644
--- a/spring-data-cassandra/src/main/resources/org/springframework/data/cassandra/config/spring-cassandra-1.0.xsd
+++ b/spring-data-cassandra/src/main/resources/org/springframework/data/cassandra/config/spring-cassandra-1.0.xsd
@@ -2,12 +2,20 @@
+
+
+
-
+
@@ -653,4 +662,38 @@ Table name override.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTests.java
index 09554ceaf..6c28f6d35 100644
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTests.java
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTests.java
@@ -24,40 +24,35 @@ import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.List;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.cassandra.core.CassandraOperations;
-import org.springframework.data.cassandra.test.integration.AbstractSpringDataEmbeddedCassandraIntegrationTest;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.google.common.collect.Lists;
/**
- * Base class for tests for {@link UserRepository}.
+ * Tests for {@link UserRepository}.
*
* @author Alex Shvid
* @author Matthew T. Adams
*/
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = UserRepositoryIntegrationTestsConfig.class)
-public class UserRepositoryIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+public class UserRepositoryIntegrationTests {
- @Autowired
- protected UserRepository repository;
+ UserRepository repository;
- @Autowired
- protected CassandraOperations template;
+ CassandraOperations template;
User tom, bob, alice, scott;
List all;
- @Before
+ public UserRepositoryIntegrationTests() {
+ }
+
+ public UserRepositoryIntegrationTests(UserRepository repository, CassandraOperations template) {
+ this.repository = repository;
+ this.template = template;
+ }
+
public void setUp() throws InterruptedException {
repository.deleteAll();
@@ -93,12 +88,10 @@ public class UserRepositoryIntegrationTests extends AbstractSpringDataEmbeddedCa
all = template.insert(Arrays.asList(tom, bob, alice, scott));
}
- @After
public void after() {
repository.deleteAll();
}
- @Test
public void findsUserById() throws Exception {
User user = repository.findOne(bob.getUsername());
@@ -107,7 +100,6 @@ public class UserRepositoryIntegrationTests extends AbstractSpringDataEmbeddedCa
}
- @Test
public void findsAll() throws Exception {
List result = Lists.newArrayList(repository.findAll());
assertThat(result.size(), is(all.size()));
@@ -115,7 +107,6 @@ public class UserRepositoryIntegrationTests extends AbstractSpringDataEmbeddedCa
}
- @Test
public void findsAllWithGivenIds() {
Iterable result = repository.findAll(Arrays.asList(bob.getUsername(), tom.getUsername()));
@@ -123,7 +114,6 @@ public class UserRepositoryIntegrationTests extends AbstractSpringDataEmbeddedCa
assertThat(result, not(hasItems(alice, scott)));
}
- @Test
public void deletesUserCorrectly() throws Exception {
repository.delete(tom);
@@ -134,7 +124,6 @@ public class UserRepositoryIntegrationTests extends AbstractSpringDataEmbeddedCa
assertThat(result, not(hasItem(tom)));
}
- @Test
public void deletesUserByIdCorrectly() {
repository.delete(tom.getUsername().toString());
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTestsConfig.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTestsConfig.java
deleted file mode 100644
index 5477d5507..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTestsConfig.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.springframework.data.cassandra.test.integration.repository;
-
-import static org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification.createKeyspace;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.cassandra.config.SchemaAction;
-import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
-import org.springframework.data.cassandra.test.integration.support.AbstractDataTestJavaConfig;
-
-@Configuration
-@EnableCassandraRepositories(basePackageClasses = UserRepository.class)
-public class UserRepositoryIntegrationTestsConfig extends AbstractDataTestJavaConfig {
-
- @Override
- protected String getKeyspaceName() {
- return UserRepositoryIntegrationTests.class.getSimpleName();
- }
-
- @Override
- protected List getKeyspaceCreations() {
- List creates = new ArrayList();
-
- creates.add(createKeyspace().name(getKeyspaceName()).withSimpleReplication());
-
- return creates;
- }
-
- @Override
- public SchemaAction getSchemaAction() {
- return SchemaAction.RECREATE;
- }
-
- @Override
- public String getMappingBasePackage() {
- return User.class.getPackage().getName();
- }
-}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryJavaConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryJavaConfigIntegrationTests.java
new file mode 100644
index 000000000..8820a6608
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryJavaConfigIntegrationTests.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2011-2013 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;
+
+import static org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification.createKeyspace;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.cassandra.config.SchemaAction;
+import org.springframework.data.cassandra.core.CassandraOperations;
+import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
+import org.springframework.data.cassandra.test.integration.AbstractSpringDataEmbeddedCassandraIntegrationTest;
+import org.springframework.data.cassandra.test.integration.support.AbstractDataTestJavaConfig;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Base class for Java config tests for {@link UserRepository}.
+ *
+ * @author Matthew T. Adams
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class UserRepositoryJavaConfigIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+
+ @Configuration
+ @EnableCassandraRepositories(basePackageClasses = UserRepository.class)
+ public static class Config extends AbstractDataTestJavaConfig {
+
+ @Override
+ protected String getKeyspaceName() {
+ return UserRepositoryJavaConfigIntegrationTests.class.getSimpleName();
+ }
+
+ @Override
+ protected List getKeyspaceCreations() {
+ List creates = new ArrayList();
+
+ creates.add(createKeyspace().name(getKeyspaceName()).withSimpleReplication());
+
+ return creates;
+ }
+
+ @Override
+ public SchemaAction getSchemaAction() {
+ return SchemaAction.RECREATE;
+ }
+
+ @Override
+ public String getMappingBasePackage() {
+ return User.class.getPackage().getName();
+ }
+ }
+
+ @Autowired
+ protected UserRepository repository;
+
+ @Autowired
+ protected CassandraOperations template;
+
+ UserRepositoryIntegrationTests tests;
+
+ @Before
+ public void setUp() throws InterruptedException {
+ tests = new UserRepositoryIntegrationTests(repository, template);
+ tests.setUp();
+ }
+
+ @After
+ public void after() {
+ tests.after();
+ }
+
+ @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();
+ }
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryXmlConfigIntegrationTests.java
new file mode 100644
index 000000000..05a9e8431
--- /dev/null
+++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/UserRepositoryXmlConfigIntegrationTests.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2011-2013 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;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.cassandra.core.CassandraOperations;
+import org.springframework.data.cassandra.test.integration.AbstractSpringDataEmbeddedCassandraIntegrationTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Base class for xml config tests for {@link UserRepository}.
+ *
+ * @author Matthew T. Adams
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class UserRepositoryXmlConfigIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
+
+ @Autowired
+ protected UserRepository repository;
+
+ @Autowired
+ protected CassandraOperations template;
+
+ UserRepositoryIntegrationTests tests;
+
+ @Before
+ public void setUp() throws InterruptedException {
+ tests = new UserRepositoryIntegrationTests(repository, template);
+ tests.setUp();
+ }
+
+ @After
+ public void after() {
+ tests.after();
+ }
+
+ @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();
+ }
+}
diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/table/Domain.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/table/Domain.java
deleted file mode 100644
index d0ea555d7..000000000
--- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/table/Domain.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.springframework.data.cassandra.test.integration.table;
-
-import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
-
-/**
- * Spring Data Cassandra marker interface for use with {@link EnableCassandraRepositories#basePackageClasses()}
- *
- * @author Matthew T. Adams
- */
-public interface Domain {
-}
diff --git a/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTests-context.xml b/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/UserRepositoryXmlConfigIntegrationTests-context.xml
similarity index 82%
rename from spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTests-context.xml
rename to spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/UserRepositoryXmlConfigIntegrationTests-context.xml
index c20c961d4..c9b35cf56 100644
--- a/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/UserRepositoryIntegrationTests-context.xml
+++ b/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/UserRepositoryXmlConfigIntegrationTests-context.xml
@@ -11,7 +11,7 @@
location="classpath:/org/springframework/data/cassandra/test/integration/repository/cassandra.properties" />
+ contact-points="${cassandra.contactPoints}" port="${cassandra.native_transport_port}">
@@ -49,14 +49,9 @@
-
-
-
+
-
-
-
-
-
+
diff --git a/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/cassandra.properties b/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/cassandra.properties
index 7c56bbb5b..2dda9f04e 100644
--- a/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/cassandra.properties
+++ b/spring-data-cassandra/src/test/resources/org/springframework/data/cassandra/test/integration/repository/cassandra.properties
@@ -1,3 +1,3 @@
cassandra.contactPoints=localhost
cassandra.native_transport_port=@build.cassandra.native_transport_port@
-cassandra.keyspace=UserRepositoryIntegrationTests
+cassandra.keyspace=UserRepositoryXmlConfigIntegrationTests