diff --git a/src/integration/java/org/springframework/data/couchbase/repository/xmlconfig/XmlItemRepository.java b/src/integration/java/org/springframework/data/couchbase/repository/xmlconfig/XmlItemRepository.java new file mode 100644 index 00000000..ccfde783 --- /dev/null +++ b/src/integration/java/org/springframework/data/couchbase/repository/xmlconfig/XmlItemRepository.java @@ -0,0 +1,7 @@ +package org.springframework.data.couchbase.repository.xmlconfig; + +import org.springframework.data.couchbase.repository.CouchbaseRepository; +import org.springframework.data.couchbase.repository.Item; + +public interface XmlItemRepository extends CouchbaseRepository { +} diff --git a/src/integration/java/org/springframework/data/couchbase/repository/xmlconfig/XmlRepositoryConfigurationTests.java b/src/integration/java/org/springframework/data/couchbase/repository/xmlconfig/XmlRepositoryConfigurationTests.java new file mode 100644 index 00000000..bae65dd8 --- /dev/null +++ b/src/integration/java/org/springframework/data/couchbase/repository/xmlconfig/XmlRepositoryConfigurationTests.java @@ -0,0 +1,44 @@ +package org.springframework.data.couchbase.repository.xmlconfig; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionReader; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.core.io.ClassPathResource; + +/** + * @author Simon Baslé + */ +public class XmlRepositoryConfigurationTests { + + DefaultListableBeanFactory factory; + BeanDefinitionReader reader; + + @Before + public void setUp() { + factory = new DefaultListableBeanFactory(); + reader = new XmlBeanDefinitionReader(factory); + } + + @Test + public void testInstantiateRepositoryFromXml() { + reader.loadBeanDefinitions(new ClassPathResource("configurations/couchbase-repository-bean.xml")); + + BeanDefinition definition = factory.getBeanDefinition("xmlItemRepository"); + assertEquals("org.springframework.data.couchbase.repository.support.CouchbaseRepositoryFactoryBean", definition.getBeanClassName()); + assertDefinitionProperty(definition, "couchbaseOperations"); + + Object bean = factory.getBean("xmlItemRepository"); + assertTrue(bean instanceof XmlItemRepository); + } + + private void assertDefinitionProperty(BeanDefinition definition, String property) { + assertTrue("bean definition properties don't include " + property, definition.getPropertyValues().contains(property)); + } +} diff --git a/src/integration/resources/configurations/couchbase-repository-bean.xml b/src/integration/resources/configurations/couchbase-repository-bean.xml new file mode 100644 index 00000000..66c49c9c --- /dev/null +++ b/src/integration/resources/configurations/couchbase-repository-bean.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/org/springframework/data/couchbase/config/spring-couchbase-2.0.xsd b/src/main/resources/org/springframework/data/couchbase/config/spring-couchbase-2.0.xsd index aa822f88..4d6d747a 100644 --- a/src/main/resources/org/springframework/data/couchbase/config/spring-couchbase-2.0.xsd +++ b/src/main/resources/org/springframework/data/couchbase/config/spring-couchbase-2.0.xsd @@ -167,6 +167,27 @@ The name of the CouchbaseBucket object that determines what connection to monito + + + + + + + + + + + + + + + + The reference to a CouchbaseTemplate. Will default to 'couchbaseTemplate'. + + + + + @@ -199,5 +220,4 @@ The name of the CouchbaseBucket object that determines what connection to monito - \ No newline at end of file