DATACOUCH-174 - Fix declaration of repositories in xml
This commit is contained in:
@@ -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<Item, String> {
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:couchbase="http://www.springframework.org/schema/data/couchbase"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/data/couchbase http://www.springframework.org/schema/data/couchbase/spring-couchbase.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<couchbase:env/>
|
||||
<couchbase:cluster/>
|
||||
<couchbase:clusterInfo/>
|
||||
<couchbase:bucket/>
|
||||
|
||||
<couchbase:template/>
|
||||
|
||||
<couchbase:repositories base-package="org.springframework.data.couchbase.repository.xmlconfig"/>
|
||||
|
||||
</beans>
|
||||
@@ -167,6 +167,27 @@ The name of the CouchbaseBucket object that determines what connection to monito
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="repositories">
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="repository:repositories">
|
||||
<xsd:attributeGroup ref="couchbase-repository-attributes"/>
|
||||
<xsd:attributeGroup ref="repository:repository-attributes"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:attributeGroup name="couchbase-repository-attributes">
|
||||
<xsd:attribute name="couchbase-template-ref" type="couchbaseTemplateRef" default="couchbaseTemplate">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The reference to a CouchbaseTemplate. Will default to 'couchbaseTemplate'.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:attributeGroup>
|
||||
|
||||
<xsd:simpleType name="converterRef">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -199,5 +220,4 @@ The name of the CouchbaseBucket object that determines what connection to monito
|
||||
</xsd:annotation>
|
||||
<xsd:union memberTypes="xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
|
||||
</xsd:schema>
|
||||
Reference in New Issue
Block a user