diff --git a/spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.5.xsd b/spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.5.xsd index 9b225e6a4..68524f8f8 100644 --- a/spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.5.xsd +++ b/spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.5.xsd @@ -212,11 +212,11 @@ The base package in which to scan for entities annotated with @Document - + Enables abbreviating the field names for domain class properties to the - first character of their camel case names, e.g. fooBar -> fb. + first character of their camel case names, e.g. fooBar -> fb. Defaults to false. @@ -226,7 +226,7 @@ The base package in which to scan for entities annotated with @Document - The reference to a MappingContext. Will default to 'mappingContext'. + The reference to a FieldNamingStrategy. @@ -654,4 +654,4 @@ The GridFs bucket string.]]> - \ No newline at end of file + diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/MappingMongoConverterParserIntegrationTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/MappingMongoConverterParserIntegrationTests.java index bdf7c54f6..f001a0026 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/MappingMongoConverterParserIntegrationTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/MappingMongoConverterParserIntegrationTests.java @@ -25,6 +25,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.BeanReference; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -49,6 +50,7 @@ import com.mongodb.DBObject; * @author Oliver Gierke * @author Thomas Darimont * @author Christoph Strobl + * @author Ryan Tenney */ public class MappingMongoConverterParserIntegrationTests { @@ -134,6 +136,25 @@ public class MappingMongoConverterParserIntegrationTests { loadNestedBeanConfiguration(); } + /** + * @see DATAMONGO-925, DATAMONGO-928 + */ + @Test + public void shouldSupportCustomFieldNamingStrategy() { + + BeanDefinitionRegistry factory = new DefaultListableBeanFactory(); + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory); + reader.loadBeanDefinitions(new ClassPathResource("namespace/converter-custom-fieldnamingstrategy.xml")); + + BeanDefinition definition = reader.getRegistry().getBeanDefinition( + "mappingConverterWithCustomFieldNamingStrategy.mongoMappingContext"); + + BeanReference value = (BeanReference) definition.getPropertyValues().getPropertyValue("fieldNamingStrategy") + .getValue(); + + assertThat(value.getBeanName(), is("customFieldNamingStrategy")); + } + private void loadValidConfiguration() { this.loadConfiguration("namespace/converter.xml"); } diff --git a/spring-data-mongodb/src/test/resources/namespace/converter-custom-fieldnamingstrategy.xml b/spring-data-mongodb/src/test/resources/namespace/converter-custom-fieldnamingstrategy.xml new file mode 100644 index 000000000..35e04bce8 --- /dev/null +++ b/spring-data-mongodb/src/test/resources/namespace/converter-custom-fieldnamingstrategy.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file