jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • castor
  • CASTOR-2555

GroupTest fails in schema module

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Critical Critical
  • Resolution: Unresolved
  • Affects Version/s: 1.3 rc1
  • Fix Version/s: 1.3.4
  • Component/s: XML schema support
  • Labels:
    None

Description

Can you please have a look. For some reason I don't understand, there's one test failing now.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Le Duc Bao added a comment - 10/Oct/08 4:51 AM

Werner,

I do update source code and run {mvn clean test} and report no error. Could you please include the error message?

Show
Le Duc Bao added a comment - 10/Oct/08 4:51 AM Werner, I do update source code and run {mvn clean test} and report no error. Could you please include the error message?
Hide
Permalink
Werner Guttmann added a comment - 10/Oct/08 5:15 AM

I have commented out one of the test methods in this test case. Uncomment it, and it should fail.

Show
Werner Guttmann added a comment - 10/Oct/08 5:15 AM I have commented out one of the test methods in this test case. Uncomment it, and it should fail.
Hide
Permalink
Le Duc Bao added a comment - 10/Oct/08 7:25 AM

Did you apply the patch included in CASTOR-2553 which modifies the SchemaWriter.java?

Show
Le Duc Bao added a comment - 10/Oct/08 7:25 AM Did you apply the patch included in CASTOR-2553 which modifies the SchemaWriter.java?
Hide
Permalink
Werner Guttmann added a comment - 10/Oct/08 7:42 AM

To my knowledge, yes. But to be able to do so, I had to move around code in quite many places (and create a new module). It should not happen, but it might have happened that something slipped my attention.

Show
Werner Guttmann added a comment - 10/Oct/08 7:42 AM To my knowledge, yes. But to be able to do so, I had to move around code in quite many places (and create a new module). It should not happen, but it might have happened that something slipped my attention.
Hide
Permalink
Le Duc Bao added a comment - 11/Oct/08 2:53 AM

It works well in my Eclipse, I'm not sure what is the problem. Can you give me the test case that when you commented out, it worked fine?

Show
Le Duc Bao added a comment - 11/Oct/08 2:53 AM It works well in my Eclipse, I'm not sure what is the problem. Can you give me the test case that when you commented out, it worked fine?
Hide
Permalink
Joachim Grüneis added a comment - 11/Oct/08 11:47 AM

Hello

see build results in: http://bamboo.ci.codehaus.org/browse/CASTOR-JDK5SCHEMA-10
there the failed test is listed before it got disabled

Regards
Joachim

Show
Joachim Grüneis added a comment - 11/Oct/08 11:47 AM Hello see build results in: http://bamboo.ci.codehaus.org/browse/CASTOR-JDK5SCHEMA-10 there the failed test is listed before it got disabled Regards Joachim
Hide
Permalink
Werner Guttmann added a comment - 13/Oct/08 3:55 PM

Bao, do you need any more information to replay the problem ?

Show
Werner Guttmann added a comment - 13/Oct/08 3:55 PM Bao, do you need any more information to replay the problem ?
Hide
Permalink
Le Duc Bao added a comment - 13/Oct/08 4:39 PM

I updated the latest source code from svn server and saw that then SchemaWriter and GroupTest was not synchronized.

Please include the patched code in the http://jira.codehaus.org/secure/attachment/37400/patch.c2553-20081006.txt consistently. This patch should be applied both for GroupTest.java and SchemaWriter.java (see source code below).

Furthermore, I am not in the bamboo list so that I can't see what happens with real time Castor build.

--- schema/src/main/java/org/exolab/castor/xml/schema/writer/SchemaWriter.java	(revision 7947)
+++ schema/src/main/java/org/exolab/castor/xml/schema/writer/SchemaWriter.java	(working copy)
@@ -76,6 +76,7 @@
 import org.exolab.castor.xml.schema.IdentitySelector;
 import org.exolab.castor.xml.schema.KeyRef;
 import org.exolab.castor.xml.schema.ModelGroup;
+import org.exolab.castor.xml.schema.Particle;
 import org.exolab.castor.xml.schema.RedefineSchema;
 import org.exolab.castor.xml.schema.Schema;
 import org.exolab.castor.xml.schema.SchemaContext;
@@ -793,7 +794,7 @@
                     break;
                 case Structure.MODELGROUP:
                 case Structure.GROUP:
-                    processGroup((Group)structure, schemaPrefix);
+                    processGroup(contentExactlyOneChild((Group)structure), schemaPrefix);
                     break;
                 case Structure.WILDCARD:
                     processWildcard((Wildcard)structure, schemaPrefix);
@@ -1024,8 +1025,8 @@
             }
         }
         //-- Group
-        else {
-            ELEMENT_NAME += group.getOrder().toString();
+        else{
+        	ELEMENT_NAME += group.getOrder().toString();
         }
 
         _atts.clear();
@@ -1368,7 +1369,7 @@
         	}
         	
         	if (!temp.isRedefined() && !found)
-        	    processGroup(temp, schemaPrefix);
+        	    processGroup(contentExactlyOneChild(temp), schemaPrefix);
         }
 
         //-- process all top level simple types
@@ -1530,7 +1531,7 @@
 	        enumeration = schema.enumerateGroups();
 	        while (enumeration.hasMoreElements()) {
 	        	ModelGroup group= (ModelGroup)enumeration.nextElement();
-	        	processGroup(group, schemaPrefix);
+	        	processGroup(contentExactlyOneChild(group), schemaPrefix);
 	        }
 	    	//--process AttributeGroups
 	        enumeration = schema.enumerateAttributeGroups();
@@ -1794,4 +1795,17 @@
     	}
     	return base;
     }
+    
+    private Group contentExactlyOneChild (Group group) {
+    	ContentModelGroup contentModel = group.getContentModelGroup();
+    	if (contentModel.getParticleCount() == 1) {
+            Particle particle = contentModel.getParticle(0);
+            if (particle.getStructureType() == Structure.GROUP) {
+                if ((group.getMinOccurs() == 1) && (group.getMaxOccurs() == 1)) {
+                	return (Group) particle; 
+                }
+            }
+    	} 
+    	return group;
+    }
 } //-- SchemaWriter
Index: schema/src/test/java/org/castor/xml/schema/ComplexTypeTest.java

Except error from my part, I hope that this will resolve this problem.

Show
Le Duc Bao added a comment - 13/Oct/08 4:39 PM I updated the latest source code from svn server and saw that then SchemaWriter and GroupTest was not synchronized. Please include the patched code in the http://jira.codehaus.org/secure/attachment/37400/patch.c2553-20081006.txt consistently. This patch should be applied both for GroupTest.java and SchemaWriter.java (see source code below). Furthermore, I am not in the bamboo list so that I can't see what happens with real time Castor build.
--- schema/src/main/java/org/exolab/castor/xml/schema/writer/SchemaWriter.java	(revision 7947)
+++ schema/src/main/java/org/exolab/castor/xml/schema/writer/SchemaWriter.java	(working copy)
@@ -76,6 +76,7 @@
 import org.exolab.castor.xml.schema.IdentitySelector;
 import org.exolab.castor.xml.schema.KeyRef;
 import org.exolab.castor.xml.schema.ModelGroup;
+import org.exolab.castor.xml.schema.Particle;
 import org.exolab.castor.xml.schema.RedefineSchema;
 import org.exolab.castor.xml.schema.Schema;
 import org.exolab.castor.xml.schema.SchemaContext;
@@ -793,7 +794,7 @@
                     break;
                 case Structure.MODELGROUP:
                 case Structure.GROUP:
-                    processGroup((Group)structure, schemaPrefix);
+                    processGroup(contentExactlyOneChild((Group)structure), schemaPrefix);
                     break;
                 case Structure.WILDCARD:
                     processWildcard((Wildcard)structure, schemaPrefix);
@@ -1024,8 +1025,8 @@
             }
         }
         //-- Group
-        else {
-            ELEMENT_NAME += group.getOrder().toString();
+        else{
+        	ELEMENT_NAME += group.getOrder().toString();
         }
 
         _atts.clear();
@@ -1368,7 +1369,7 @@
         	}
         	
         	if (!temp.isRedefined() && !found)
-        	    processGroup(temp, schemaPrefix);
+        	    processGroup(contentExactlyOneChild(temp), schemaPrefix);
         }
 
         //-- process all top level simple types
@@ -1530,7 +1531,7 @@
 	        enumeration = schema.enumerateGroups();
 	        while (enumeration.hasMoreElements()) {
 	        	ModelGroup group= (ModelGroup)enumeration.nextElement();
-	        	processGroup(group, schemaPrefix);
+	        	processGroup(contentExactlyOneChild(group), schemaPrefix);
 	        }
 	    	//--process AttributeGroups
 	        enumeration = schema.enumerateAttributeGroups();
@@ -1794,4 +1795,17 @@
     	}
     	return base;
     }
+    
+    private Group contentExactlyOneChild (Group group) {
+    	ContentModelGroup contentModel = group.getContentModelGroup();
+    	if (contentModel.getParticleCount() == 1) {
+            Particle particle = contentModel.getParticle(0);
+            if (particle.getStructureType() == Structure.GROUP) {
+                if ((group.getMinOccurs() == 1) && (group.getMaxOccurs() == 1)) {
+                	return (Group) particle; 
+                }
+            }
+    	} 
+    	return group;
+    }
 } //-- SchemaWriter
Index: schema/src/test/java/org/castor/xml/schema/ComplexTypeTest.java
Except error from my part, I hope that this will resolve this problem.

People

  • Assignee:
    Werner Guttmann
    Reporter:
    Werner Guttmann
Vote (0)
Watch (1)

Dates

  • Created:
    10/Oct/08 3:13 AM
    Updated:
    05/Mar/11 5:32 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.