Index: F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/AbstractTypeCreator.java =================================================================== --- F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/AbstractTypeCreator.java (revision 1349) +++ F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/AbstractTypeCreator.java (working copy) @@ -27,7 +27,7 @@ protected AbstractTypeCreator nextCreator; - private Configuration typeConfiguration; + private Configuration typeConfiguration = new Configuration(); public TypeMapping getTypeMapping() { Index: F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/basic/BeanTypeInfo.java =================================================================== --- F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/basic/BeanTypeInfo.java (revision 1349) +++ F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/basic/BeanTypeInfo.java (working copy) @@ -40,6 +40,8 @@ private int minOccurs = 0; + private boolean nillable = true; + /** * extensibleElements means adding xs:any to WSDL Complex Type Definition */ @@ -390,8 +392,8 @@ public boolean isNillable(QName name) { Type type = getType(name); - - return type.isNillable(); + if ( !type.isNillable() ) return false; + return nillable; } public int getMinOccurs(QName name) @@ -403,6 +405,11 @@ { this.minOccurs = minOccurs; } + + public void setDefaultNillable (boolean nillable) + { + this.nillable = nillable; + } private String getPropertyNameFromMappedName(QName name) { Index: F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/XMLTypeCreator.java =================================================================== --- F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/XMLTypeCreator.java (revision 1349) +++ F:/work/xfire/xfire-aegis/src/main/org/codehaus/xfire/aegis/type/XMLTypeCreator.java (working copy) @@ -273,6 +273,7 @@ defaultNS); btinfo.setTypeMapping(getTypeMapping()); btinfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs()); + btinfo.setDefaultNillable( getConfiguration().isDefaultNillable() ); if ( extensibleElements != null ) btinfo.setExtensibleElements( Boolean.valueOf( extensibleElements ).booleanValue() ); else btinfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements()); Index: F:/work/xfire/xfire-aegis/src/test/org/codehaus/xfire/aegis/type/basic/ConfigurationTest.java =================================================================== --- F:/work/xfire/xfire-aegis/src/test/org/codehaus/xfire/aegis/type/basic/ConfigurationTest.java (revision 0) +++ F:/work/xfire/xfire-aegis/src/test/org/codehaus/xfire/aegis/type/basic/ConfigurationTest.java (revision 0) @@ -0,0 +1,112 @@ +/** + * + */ +package org.codehaus.xfire.aegis.type.basic; + +import javax.xml.namespace.QName; + +import org.codehaus.xfire.aegis.AbstractXFireAegisTest; +import org.codehaus.xfire.aegis.type.Configuration; +import org.codehaus.xfire.aegis.type.CustomTypeMapping; +import org.codehaus.xfire.aegis.type.DefaultTypeCreator; +import org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry; +import org.codehaus.xfire.aegis.type.Type; +import org.codehaus.xfire.aegis.type.XMLTypeCreator; + +/** + * Test cases to test the changing of the Configuration Object + * + * @author adam + * + */ +public class ConfigurationTest + extends AbstractXFireAegisTest +{ + + CustomTypeMapping tm; + Configuration config = null; + + protected void setUp() + throws Exception + { + super.setUp(); + + DefaultTypeMappingRegistry reg = new DefaultTypeMappingRegistry(); + config = reg.getConfiguration(); + XMLTypeCreator creator = new XMLTypeCreator(); + creator.setConfiguration(reg.getConfiguration()); + DefaultTypeCreator next = new DefaultTypeCreator(); + next.setConfiguration(reg.getConfiguration()); + creator.setNextCreator(next); + reg.createDefaultMappings(); + tm = (CustomTypeMapping) reg.getDefaultTypeMapping(); + tm.setTypeCreator(creator); + } + + public void testNillableDefaultTrue() throws Exception + { + config.setDefaultNillable( true ); + tm.setEncodingStyleURI("urn:xfire:bean-nillable"); + + Type type = tm.getTypeCreator().createType(MyBean.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + + assertTrue(info.isNillable(new QName(info.getDefaultNamespace(), "prop2"))); + } + + public void testNillableDefaultFalse() throws Exception + { + config.setDefaultNillable( false ); + tm.setEncodingStyleURI("urn:xfire:bean-nillable"); + + Type type = tm.getTypeCreator().createType(MyBean.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + + assertFalse(info.isNillable(new QName(info.getDefaultNamespace(), "prop2"))); + } + + public void testMinOccursDefault0() throws Exception + { + config.setDefaultMinOccurs( 0 ); + tm.setEncodingStyleURI("urn:xfire:bean-minoccurs"); + + Type type = tm.getTypeCreator().createType(MyBean.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + + assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "prop2")), 0); + } + + public void testMinOccursDefault1() throws Exception + { + config.setDefaultMinOccurs( 1 ); + tm.setEncodingStyleURI("urn:xfire:bean-minoccurs"); + + Type type = tm.getTypeCreator().createType(MyBean.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + + assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "prop2")), 1); + } + + public void testExtensibleDefaultTrue() throws Exception + { + config.setDefaultExtensibleElements( true ); + config.setDefaultExtensibleAttributes( true ); + tm.setEncodingStyleURI("urn:xfire:bean-extensible"); + Type type = tm.getTypeCreator().createType(MyBean.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + assertTrue(info.isExtensibleElements()); + assertTrue(info.isExtensibleAttributes()); + } + + public void testExtensibleDefaultFalse() throws Exception + { + config.setDefaultExtensibleElements( false ); + config.setDefaultExtensibleAttributes( false ); + tm.setEncodingStyleURI("urn:xfire:bean-extensible"); + Type type = tm.getTypeCreator().createType(MyBean.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + assertFalse(info.isExtensibleElements()); + assertFalse(info.isExtensibleAttributes()); + } + +} Index: F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/Java5TypeCreator.java =================================================================== --- F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/Java5TypeCreator.java (revision 1349) +++ F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/Java5TypeCreator.java (working copy) @@ -205,6 +205,9 @@ typeInfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements()); typeInfo.setExtensibleAttributes(getConfiguration().isDefaultExtensibleAttributes()); } + + typeInfo.setDefaultMinOccurs( getConfiguration().getDefaultMinOccurs() ); + typeInfo.setDefaultNillable( getConfiguration().isDefaultNillable() ); BeanType type = new BeanType(typeInfo); type.setTypeMapping(getTypeMapping()); Index: F:/work/xfire/xfire-java5/src/test/org/codehaus/xfire/aegis/type/java5/ConfigurationTest.java =================================================================== --- F:/work/xfire/xfire-java5/src/test/org/codehaus/xfire/aegis/type/java5/ConfigurationTest.java (revision 0) +++ F:/work/xfire/xfire-java5/src/test/org/codehaus/xfire/aegis/type/java5/ConfigurationTest.java (revision 0) @@ -0,0 +1,103 @@ +/** + * + */ +package org.codehaus.xfire.aegis.type.java5; + +import javax.xml.namespace.QName; + +import org.codehaus.xfire.aegis.AbstractXFireAegisTest; +import org.codehaus.xfire.aegis.type.Configuration; +import org.codehaus.xfire.aegis.type.CustomTypeMapping; +import org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry; +import org.codehaus.xfire.aegis.type.Type; +import org.codehaus.xfire.aegis.type.XMLTypeCreator; +import org.codehaus.xfire.aegis.type.basic.BeanType; +import org.codehaus.xfire.aegis.type.basic.BeanTypeInfo; + +/** + * @author adam + * + */ +public class ConfigurationTest + extends AbstractXFireAegisTest +{ + + CustomTypeMapping tm; + + Configuration config = null; + + protected void setUp() + throws Exception + { + super.setUp(); + + DefaultTypeMappingRegistry reg = new DefaultTypeMappingRegistry(); + config = reg.getConfiguration(); + XMLTypeCreator creator = new XMLTypeCreator(); + creator.setConfiguration(reg.getConfiguration()); + Java5TypeCreator next = new Java5TypeCreator(); + next.setConfiguration(reg.getConfiguration()); + creator.setNextCreator(next); + reg.createDefaultMappings(); + tm = (CustomTypeMapping) reg.getDefaultTypeMapping(); + tm.setTypeCreator(creator); + } + + public void testNillableDefaultTrue() throws Exception + { + config.setDefaultNillable( true ); + + Type type = tm.getTypeCreator().createType(AnnotatedBean1.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + + assertTrue(info.isNillable(new QName(info.getDefaultNamespace(), "bogusProperty"))); + } + + public void testNillableDefaultFalse() throws Exception + { + config.setDefaultNillable( false ); + Type type = tm.getTypeCreator().createType(AnnotatedBean1.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + + assertFalse(info.isNillable(new QName(info.getDefaultNamespace(), "bogusProperty"))); + } + + public void testMinOccursDefault0() throws Exception + { + config.setDefaultMinOccurs( 0 ); + Type type = tm.getTypeCreator().createType(AnnotatedBean1.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + + assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "bogusProperty")), 0); + } + + public void testMinOccursDefault1() throws Exception + { + config.setDefaultMinOccurs( 1 ); + Type type = tm.getTypeCreator().createType(AnnotatedBean1.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + + assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "bogusProperty")), 1); + } + + public void testExtensibleDefaultTrue() throws Exception + { + config.setDefaultExtensibleElements( true ); + config.setDefaultExtensibleAttributes( true ); + Type type = tm.getTypeCreator().createType(AnnotatedBean1.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + assertTrue(info.isExtensibleElements()); + assertTrue(info.isExtensibleAttributes()); + } + + public void testExtensibleDefaultFalse() throws Exception + { + config.setDefaultExtensibleElements( false ); + config.setDefaultExtensibleAttributes( false ); + Type type = tm.getTypeCreator().createType(AnnotatedBean1.class); + BeanTypeInfo info = ((BeanType) type).getTypeInfo(); + assertFalse(info.isExtensibleElements()); + assertFalse(info.isExtensibleAttributes()); + } + +}