[jboss-svn-commits] JBoss Common SVN: r2888 - in jbossxb/trunk/src: main/java/org/jboss/xb/binding/sunday/unmarshalling and 10 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 24 10:12:41 EDT 2008


Author: alex.loubyansky at jboss.com
Date: 2008-07-24 10:12:41 -0400 (Thu, 24 Jul 2008)
New Revision: 2888

Added:
   jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlPreserveWhitespace.java
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/CustomizedSchemaRoot.java
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/DefaultsRoot.java
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/JBossXmlPreserveWhitespaceUnitTestCase.java
   jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/
   jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/
   jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/JBossXmlPreserveWhitespace.xml
Modified:
   jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlSchema.java
   jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeBinding.java
   jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeHandler.java
   jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/ElementBinding.java
   jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SchemaBinding.java
   jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SundayContentHandler.java
   jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBBuilder.java
   jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/support/NonDefaults.java
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/test/AbstractDefaultsTest.java
   jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/test/NonDefaultsUnitTestCase.java
Log:
JBXB-145

Added: jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlPreserveWhitespace.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlPreserveWhitespace.java	                        (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlPreserveWhitespace.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.xb.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A JBossXmlPreserveWhitespace.
+ * This annotation can be used for string properties to signify whether to trim or preserve whitespaces of the values.
+ * The schema default behavior is set with JBossXmlSchema.normalizeSpace().
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Target({ElementType.METHOD, ElementType.FIELD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface JBossXmlPreserveWhitespace
+{
+   boolean preserve() default true;
+}

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlSchema.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlSchema.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlSchema.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -64,4 +64,7 @@
    
    /** Whether the schema is strict */
    boolean strict() default true;
+   
+   /** Whether to trim string values */
+   boolean normalizeSpace() default false;
 }

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeBinding.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeBinding.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeBinding.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -47,6 +47,7 @@
    private boolean mapEntryValue;
    private ValueAdapter valueAdapter;
    private boolean required;
+   protected Boolean normalizeSpace;
 
    public AttributeBinding(SchemaBinding schema, QName qName, TypeBinding type, AttributeHandler handler)
    {
@@ -174,4 +175,16 @@
    {
       return required;
    }
+
+   public void setNormalizeSpace(Boolean value)
+   {
+      this.normalizeSpace = value;
+   }
+   
+   public boolean isNormalizeSpace()
+   {
+      if(normalizeSpace != null)
+         return normalizeSpace.booleanValue();      
+      return schema == null ? true : schema.isNormalizeSpace();
+   }
 }

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeHandler.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributeHandler.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -45,6 +45,9 @@
                            NamespaceContext nsCtx,
                            String value)
    {
+      if(value != null && binding.isNormalizeSpace())
+         value = value.trim();
+      
       TypeBinding type = binding.getType();
       ValueMetaData valueMetaData = binding.getValueMetaData();
       return type == null ? value : type.getCharactersHandler().unmarshal(attrName, type, nsCtx, valueMetaData, value);

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/ElementBinding.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/ElementBinding.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/ElementBinding.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -47,6 +47,7 @@
    protected QName qName;
    protected TypeBinding typeBinding;
    protected boolean nillable;
+   protected Boolean normalizeSpace;
 
    protected XOPUnmarshaller xopUnmarshaller;
 
@@ -195,6 +196,18 @@
       this.xopUnmarshaller = xopUnmarshaller;
    }
 
+   public void setNormalizeSpace(Boolean value)
+   {
+      this.normalizeSpace = value;
+   }
+   
+   public boolean isNormalizeSpace()
+   {
+      if(normalizeSpace != null)
+         return normalizeSpace.booleanValue();      
+      return schema == null ? true : schema.isNormalizeSpace();
+   }
+   
    public String toString()
    {
       return super.toString() + "(" + qName + ", type=" + typeBinding.getQName() + ")";

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SchemaBinding.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SchemaBinding.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SchemaBinding.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -93,6 +93,9 @@
     *  the default is true for the backwards compatibility */
    private boolean ignoreWhitespacesInMixedContent = true;
 
+   /** whether to trim string values */
+   private boolean normalizeSpace;
+   
    /** default XOP unmarshaller */
    private XOPUnmarshaller xopUnmarshaller;
    /** default XOP marshaller */
@@ -483,6 +486,16 @@
       this.ignoreWhitespacesInMixedContent = value;
    }
    
+   public boolean isNormalizeSpace()
+   {
+      return normalizeSpace;
+   }
+   
+   public void setNormalizeSpace(boolean value)
+   {
+      this.normalizeSpace = value;
+   }
+   
    void addElementParticle(ParticleBinding particle)
    {
       ElementBinding element = (ElementBinding)particle.getTerm();

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SundayContentHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SundayContentHandler.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SundayContentHandler.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -1010,6 +1010,9 @@
                {
                   dataContent = StringPropertyReplacer.replaceProperties(dataContent);
                }
+               
+               if(element.isNormalizeSpace())
+                  dataContent = dataContent.trim();
             }
 
             Object unmarshalled;

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBBuilder.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBBuilder.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBBuilder.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -187,6 +187,7 @@
       schemaBinding.setIgnoreLowLine(schema.ignoreLowLine());
       schemaBinding.setReplacePropertyRefs(schema.replacePropertyRefs());
       schemaBinding.setStrictSchema(schema.strict());
+      schemaBinding.setNormalizeSpace(schema.normalizeSpace());
    }
 
    /**

Modified: jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -85,6 +85,7 @@
 import org.jboss.xb.annotations.JBossXmlModelGroup;
 import org.jboss.xb.annotations.JBossXmlNoElements;
 import org.jboss.xb.annotations.JBossXmlNsPrefix;
+import org.jboss.xb.annotations.JBossXmlPreserveWhitespace;
 import org.jboss.xb.annotations.JBossXmlSchema;
 import org.jboss.xb.annotations.JBossXmlType;
 import org.jboss.xb.binding.SimpleTypeBindings;
@@ -852,8 +853,11 @@
                AttributeBinding attribute = new AttributeBinding(schemaBinding, qName, attributeType, attributeHandler);
                attribute.setRequired(xmlAttribute.required());
                typeBinding.addAttribute(attribute);
+               JBossXmlPreserveWhitespace preserveSpace = property.getUnderlyingAnnotation(JBossXmlPreserveWhitespace.class);
+               if(preserveSpace != null)
+                  attribute.setNormalizeSpace(preserveSpace.preserve() ? false : true);
                if (trace)
-                  log.trace("Bound attribute " + qName + " type=" + beanInfo.getName() + " property=" + property.getName() + " propertyType=" + attributeTypeInfo);
+                  log.trace("Bound attribute " + qName + " type=" + beanInfo.getName() + " property=" + property.getName() + " propertyType=" + attributeTypeInfo + ", normalizeSpace=" + attribute.isNormalizeSpace());
             }
 
             // Are we determining the property order?
@@ -1744,6 +1748,14 @@
                ElementBinding elementBinding = createElementBinding(localPropertyType, elementTypeBinding, propertyQName, false);
                elementBinding.setNillable(nillable);
                elementBinding.setValueAdapter(valueAdapter);
+               
+               JBossXmlPreserveWhitespace preserveSpace = property.getUnderlyingAnnotation(JBossXmlPreserveWhitespace.class);
+               if(preserveSpace != null)
+               {
+                  elementBinding.setNormalizeSpace(preserveSpace.preserve() ? false : true);
+                  if(trace)
+                     log.trace("@JBossXmlPreserveWhitespace.preserve=" + preserveSpace.preserve() + " for " + elementBinding.getQName());
+               }
 
                // Bind it to the model
                particle = new ParticleBinding(elementBinding, 1, 1, isCol);

Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/CustomizedSchemaRoot.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/CustomizedSchemaRoot.java	                        (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/CustomizedSchemaRoot.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.xb.builder.object.jbossxmlpreservewhitespace.support;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.xb.annotations.JBossXmlPreserveWhitespace;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * A CustomizedSchemaRoot.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlRootElement(name="root")
+ at JBossXmlSchema(normalizeSpace=true)
+public class CustomizedSchemaRoot
+{
+   private String schemaDefaults;
+   private String preserveTrue;
+   private String preserveFalse;
+   
+   private String schemaDefaultsAttribute;
+   private String preserveTrueAttribute;
+   private String preserveFalseAttribute;
+
+   public String getSchemaDefaults()
+   {
+      return schemaDefaults;
+   }
+   
+   public void setSchemaDefaults(String str)
+   {
+      this.schemaDefaults = str;
+   }
+   
+   @JBossXmlPreserveWhitespace
+   public String getPreserveTrue()
+   {
+      return preserveTrue;
+   }
+   
+   public void setPreserveTrue(String str)
+   {
+      this.preserveTrue = str;
+   }
+
+   @JBossXmlPreserveWhitespace(preserve=false)
+   public String getPreserveFalse()
+   {
+      return preserveFalse;
+   }
+   
+   public void setPreserveFalse(String str)
+   {
+      this.preserveFalse = str;
+   }
+
+   @XmlAttribute()
+   public String getSchemaDefaultsAttribute()
+   {
+      return schemaDefaultsAttribute;
+   }
+   
+   public void setSchemaDefaultsAttribute(String str)
+   {
+      this.schemaDefaultsAttribute = str;
+   }
+   
+   @XmlAttribute()
+   @JBossXmlPreserveWhitespace
+   public String getPreserveTrueAttribute()
+   {
+      return preserveTrueAttribute;
+   }
+   
+   public void setPreserveTrueAttribute(String str)
+   {
+      this.preserveTrueAttribute = str;
+   }
+
+   @XmlAttribute()
+   @JBossXmlPreserveWhitespace(preserve=false)
+   public String getPreserveFalseAttribute()
+   {
+      return preserveFalseAttribute;
+   }
+   
+   public void setPreserveFalseAttribute(String str)
+   {
+      this.preserveFalseAttribute = str;
+   }
+}

Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/DefaultsRoot.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/DefaultsRoot.java	                        (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/support/DefaultsRoot.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.xb.builder.object.jbossxmlpreservewhitespace.support;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.xb.annotations.JBossXmlPreserveWhitespace;
+
+/**
+ * A Root.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlRootElement(name="root")
+public class DefaultsRoot
+{
+   private String schemaDefaults;
+   private String preserveTrue;
+   private String preserveFalse;
+
+   private String schemaDefaultsAttribute;
+   private String preserveTrueAttribute;
+   private String preserveFalseAttribute;
+
+   public String getSchemaDefaults()
+   {
+      return schemaDefaults;
+   }
+   
+   public void setSchemaDefaults(String str)
+   {
+      this.schemaDefaults = str;
+   }
+   
+   @JBossXmlPreserveWhitespace
+   public String getPreserveTrue()
+   {
+      return preserveTrue;
+   }
+   
+   public void setPreserveTrue(String str)
+   {
+      this.preserveTrue = str;
+   }
+
+   @JBossXmlPreserveWhitespace(preserve=false)
+   public String getPreserveFalse()
+   {
+      return preserveFalse;
+   }
+   
+   public void setPreserveFalse(String str)
+   {
+      this.preserveFalse = str;
+   }
+
+   @XmlAttribute()
+   public String getSchemaDefaultsAttribute()
+   {
+      return schemaDefaultsAttribute;
+   }
+   
+   public void setSchemaDefaultsAttribute(String str)
+   {
+      this.schemaDefaultsAttribute = str;
+   }
+   
+   @XmlAttribute()
+   @JBossXmlPreserveWhitespace
+   public String getPreserveTrueAttribute()
+   {
+      return preserveTrueAttribute;
+   }
+   
+   public void setPreserveTrueAttribute(String str)
+   {
+      this.preserveTrueAttribute = str;
+   }
+
+   @XmlAttribute()
+   @JBossXmlPreserveWhitespace(preserve=false)
+   public String getPreserveFalseAttribute()
+   {
+      return preserveFalseAttribute;
+   }
+   
+   public void setPreserveFalseAttribute(String str)
+   {
+      this.preserveFalseAttribute = str;
+   }
+}

Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/JBossXmlPreserveWhitespaceUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/JBossXmlPreserveWhitespaceUnitTestCase.java	                        (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/JBossXmlPreserveWhitespaceUnitTestCase.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.xb.builder.object.jbossxmlpreservewhitespace.test;
+
+import org.jboss.test.xb.builder.AbstractBuilderTest;
+import org.jboss.test.xb.builder.object.jbossxmlpreservewhitespace.support.CustomizedSchemaRoot;
+import org.jboss.test.xb.builder.object.jbossxmlpreservewhitespace.support.DefaultsRoot;
+
+/**
+ * A JBossXmlPreserveWhitespaceUnitTestCase.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossXmlPreserveWhitespaceUnitTestCase extends AbstractBuilderTest
+{
+
+   public JBossXmlPreserveWhitespaceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testDefaults() throws Exception
+   {
+      DefaultsRoot root = unmarshalObject(DefaultsRoot.class);
+      assertEquals("   value   ", root.getSchemaDefaults());
+      assertEquals("   value   ", root.getPreserveTrue());
+      assertEquals("value", root.getPreserveFalse());
+      assertEquals("   value   ", root.getSchemaDefaultsAttribute());
+      assertEquals("   value   ", root.getPreserveTrueAttribute());
+      assertEquals("value", root.getPreserveFalseAttribute());
+   }
+   
+   public void testCustomizedSchema() throws Exception
+   {
+      CustomizedSchemaRoot root = unmarshalObject(CustomizedSchemaRoot.class);
+      assertEquals("value", root.getSchemaDefaults());
+      assertEquals("   value   ", root.getPreserveTrue());
+      assertEquals("value", root.getPreserveFalse());
+      assertEquals("value", root.getSchemaDefaultsAttribute());
+      assertEquals("   value   ", root.getPreserveTrueAttribute());
+      assertEquals("value", root.getPreserveFalseAttribute());
+   }
+}

Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/support/NonDefaults.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/support/NonDefaults.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/support/NonDefaults.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -29,7 +29,7 @@
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
- at JBossXmlSchema(namespace = "testNamespace", ignoreLowLine=false, ignoreUnresolvedFieldOrClass=false, packageName="testPackage", replacePropertyRefs=false)
+ at JBossXmlSchema(namespace = "testNamespace", ignoreLowLine=false, ignoreUnresolvedFieldOrClass=false, packageName="testPackage", replacePropertyRefs=false, normalizeSpace=true)
 public class NonDefaults
 {
 }

Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/test/AbstractDefaultsTest.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/test/AbstractDefaultsTest.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/test/AbstractDefaultsTest.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -67,5 +67,6 @@
       assertTrue(schemaBinding.isIgnoreLowLine());
       assertTrue(schemaBinding.isReplacePropertyRefs());
       assertEquals(root.getPackage().getName(), schemaBinding.getPackageMetaData().getName());
+      assertFalse(schemaBinding.isNormalizeSpace());
    }
 }

Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/test/NonDefaultsUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/test/NonDefaultsUnitTestCase.java	2008-07-24 13:57:35 UTC (rev 2887)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlschema/test/NonDefaultsUnitTestCase.java	2008-07-24 14:12:41 UTC (rev 2888)
@@ -64,5 +64,6 @@
       assertFalse(schemaBinding.isIgnoreLowLine());
       assertFalse(schemaBinding.isReplacePropertyRefs());
       assertEquals("testPackage", schemaBinding.getPackageMetaData().getName());
+      assertTrue(schemaBinding.isNormalizeSpace());
    }
 }

Added: jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/JBossXmlPreserveWhitespace.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/JBossXmlPreserveWhitespace.xml	                        (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlpreservewhitespace/test/JBossXmlPreserveWhitespace.xml	2008-07-24 14:12:41 UTC (rev 2888)
@@ -0,0 +1,5 @@
+<root schema-defaults-attribute="   value   " preserve-true-attribute="   value   " preserve-false-attribute="   value   ">
+   <schema-defaults>   value   </schema-defaults>
+   <preserve-true>   value   </preserve-true>
+   <preserve-false>   value   </preserve-false>
+</root>
\ No newline at end of file




More information about the jboss-svn-commits mailing list