[EMAIL PROTECTED] wrote:
Harold,Hi Martin,I have written two test cases reproducing the explained bugs (see attachments). The test case "TestSAXBeanWriter" requires Xerces to be in the classpath. I used the "PersonBean" in the test directory for the test cases.
Okay, I finally got around to looking at this for you. In TestSAXBeanReader, you are not using BeanReader to parse the XML. Change the following bit of code, adding the middle line:
//parser.getXMLReader().parse(source);
PersonBean result = (PersonBean)reader.parse(source);
//PersonBean result = reader.getRoot();
Now, BeanReader will parse the XML and return the root object.
In contrast, your TestSAXBeanWriter class is very interesting. I assume that you are getting the same error as me. Here is what I get (with logging set to "trace") [below]
The cause wasn't shallow for me, I'll defer to others on this list to hopefully provide insight.
By the way, would you be willing to release your testcases under the Apache Software License v1.1 and permit them to be added to betwixt?
--
Michael
---->%----
Testsuite: org.apache.commons.betwixt.TestSAXBeanWriter
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 2.113 sec
------------- Standard Error -----------------
[DEBUG] AbstractBeanWriter - -Writing bean graph...
[DEBUG] AbstractBeanWriter - -[PersonBean] age=35 name=John Smith
[TRACE] AbstractBeanWriter - -Writing bean graph (qualified name 'null'
[DEBUG] XMLIntrospector - -Introspecting...
[DEBUG] XMLIntrospector - -[PersonBean] age=35 name=John Smith
[DEBUG] XMLIntrospector - -Attempting to lookup an XML descriptor for class: class org.apache.commons.betwixt.PersonBean
[TRACE] XMLIntrospector - -ElementDescriptor[qname=PersonBean,class=class org.apache.commons.betwixt.PersonBean,singular=class org.apache.commons.betwixt.PersonBean]
[TRACE] XMLIntrospectorHelper - -Creating descriptor for property: name=age type=int
[TRACE] XMLIntrospectorHelper - -Read method=getAge
[TRACE] XMLIntrospectorHelper - -Primitive type: age
[TRACE] XMLIntrospectorHelper - -Adding property as element: age
[TRACE] XMLIntrospectorHelper - -Creating descriptor for property: name=class type=class java.lang.Class
[TRACE] XMLIntrospectorHelper - -Read method=getClass
[TRACE] XMLIntrospectorHelper - -Ignoring class property
[TRACE] XMLIntrospectorHelper - -Creating descriptor for property: name=name type=class java.lang.String
[TRACE] XMLIntrospectorHelper - -Read method=getName
[TRACE] XMLIntrospectorHelper - -Primitive type: name
[TRACE] XMLIntrospectorHelper - -Adding property as element: name
[TRACE] XMLIntrospector - -[ElementDescriptor[qname=age,class=int,singular=int], ElementDescriptor[qname=name,class=class java.lang.String,singular=class java.lang.String]]
[TRACE] XMLIntrospector - -[]
[TRACE] XMLIntrospector - -XMLBeanInfo [class=class org.apache.commons.betwixt.PersonBean, descriptor=ElementDescriptor[qname=PersonBean,class=class org.apache.commons.betwixt.PersonBean,singular=class org.apache.commons.betwixt.PersonBean]]
------------- ---------------- ---------------
Testcase: testWrite took 0.418 sec
Caused an ERROR
null
java.lang.ArrayIndexOutOfBoundsException
at org.apache.xerces.util.NamespaceSupport.popContext(NamespaceSupport.java:218)
at org.apache.xml.serialize.XMLSerializer.endElementIO(XMLSerializer.java:400)
at org.apache.xml.serialize.XMLSerializer.endElement(XMLSerializer.java:387)
at org.apache.commons.betwixt.io.SAXBeanWriter.expressElementEnd(SAXBeanWriter.java:162)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeRestOfElement(AbstractBeanWriter.java:437)
at org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWriter.java:418)
at org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWriter.java:220)
at org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWriter.java:134)
at org.apache.commons.betwixt.TestSAXBeanWriter.testWrite(TestSAXBeanWriter.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Testcase: testWrite
---->%----
smime.p7s
Description: S/MIME Cryptographic Signature