[jboss-cvs] JBossAS SVN: r97904 - projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/binding.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Dec 16 13:17:03 EST 2009


Author: jaikiran
Date: 2009-12-16 13:17:02 -0500 (Wed, 16 Dec 2009)
New Revision: 97904

Modified:
   projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/binding/SchemaBindingValidationTest.java
Log:
JBMETA-237 Added an option to ignore particle count mismatch.

Modified: projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/binding/SchemaBindingValidationTest.java
===================================================================
--- projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/binding/SchemaBindingValidationTest.java	2009-12-16 18:15:28 UTC (rev 97903)
+++ projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/binding/SchemaBindingValidationTest.java	2009-12-16 18:17:02 UTC (rev 97904)
@@ -92,7 +92,10 @@
    private Set<QName> validatedTypes;
    private Set<QName> validatedElements;
    private Set<QName> ignoredTypes;
-      
+   
+   // ignore mismatch in particle count between xsd and the binding class particles
+   private boolean ignoreParticleCountMisMatch;
+   
    public SchemaBindingValidationTest(String name)
    {
       super(name);
@@ -120,6 +123,27 @@
       ignoredTypes.add(qname);      
    }
    
+   /**
+    * Sets the <code>ignoreParticleCountMisMatch</code> property.
+    * If set to true, then if the xsd contains lesser number of 
+    * particles than the number of particles mapped in the binding 
+    * class, then the mismatch is ignored.
+    * 
+    * @param ignore
+    */
+   protected void setIgnoreParticleCountMisMatch(boolean ignore)
+   {
+      this.ignoreParticleCountMisMatch = ignore;
+   }
+   
+   /**
+    * Returns the <code>ignoreParticleCountMisMatch</code> property
+    */
+   protected boolean isIgnoreParticleCountMisMatch()
+   {
+      return this.ignoreParticleCountMisMatch;
+   }
+   
    public void assertEquivalent(String xsdName, Class<?> cls) throws IOException
    {
       if(trace)
@@ -526,8 +550,22 @@
                   for (Iterator<QName> missingNames = missing.iterator(); missingNames.hasNext();)
                      log.trace("- " + missingNames.next());
                }
-               fail("ModelGroupBinding particles total expected " + xsParticles.getLength() + " but was "
+               int numberOfParticlesInXSD = xsParticles.getLength();
+               int numberOfParticleBindings = particleBindings.size();
+               // if the binding metadata allows for more particles than the xsd, then
+               // we just ignore if the ignore flag is set.
+               if (this.ignoreParticleCountMisMatch && (numberOfParticleBindings > numberOfParticlesInXSD))
+               {
+                  // just ignore
+                  log.info("Ignoring mismatch between ModelGroupBinding particles length= " + numberOfParticlesInXSD
+                        + " and  XSModelGroup particles length= " + numberOfParticlesInXSD);
+                  
+               }
+               else
+               {
+                  fail("ModelGroupBinding particles total expected " + xsParticles.getLength() + " but was "
                      + particleBindings.size());
+               }
             }
          }
       }
@@ -547,6 +585,11 @@
             XSParticle xsParticle = xsElementParticles.get(particleQName);
             if(xsParticle == null)
             {
+               if (this.ignoreParticleCountMisMatch)
+               {
+                  continue;
+               }
+               
                if(particleQName == WILDCARD)
                   fail("WildcardBinding is missing");
                else




More information about the jboss-cvs-commits mailing list