You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2004/01/16 00:34:24 UTC
cvs commit: jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/recursion TestRecursion.java
rdonkin 2004/01/15 15:34:24
Modified: betwixt/src/java/org/apache/commons/betwixt Tag:
REFACTORING-BRANCH_2004-01-13
ElementDescriptor.java
betwixt/src/java/org/apache/commons/betwixt/io Tag:
REFACTORING-BRANCH_2004-01-13
AbstractBeanWriter.java SAXBeanWriter.java
betwixt/src/test/org/apache/commons/betwixt Tag:
REFACTORING-BRANCH_2004-01-13 TestBeanReader.java
TestBeanWriter.java TestDynaBeanSupport.java
betwixt/src/test/org/apache/commons/betwixt/digester Tag:
REFACTORING-BRANCH_2004-01-13 TestIDRead.java
betwixt/src/test/org/apache/commons/betwixt/dotbetwixt Tag:
REFACTORING-BRANCH_2004-01-13 TestBeanToXml.java
betwixt/src/test/org/apache/commons/betwixt/introspection
Tag: REFACTORING-BRANCH_2004-01-13
TestXMLIntrospector.java
betwixt/src/test/org/apache/commons/betwixt/io Tag:
REFACTORING-BRANCH_2004-01-13
TestSAXBeanWriter.java
betwixt/src/test/org/apache/commons/betwixt/io/read Tag:
REFACTORING-BRANCH_2004-01-13 TestBeanCreation.java
betwixt/src/test/org/apache/commons/betwixt/recursion Tag:
REFACTORING-BRANCH_2004-01-13 TestRecursion.java
Log:
Fixed bug in ID generation. Based on patch submitted by Brian
Revision Changes Path
No revision
No revision
1.14.2.2 +5 -5 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
Index: ElementDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -u -r1.14.2.1 -r1.14.2.2
--- ElementDescriptor.java 13 Jan 2004 21:49:45 -0000 1.14.2.1
+++ ElementDescriptor.java 15 Jan 2004 23:34:22 -0000 1.14.2.2
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
No revision
No revision
1.22.2.2 +140 -45 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java
Index: AbstractBeanWriter.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java,v
retrieving revision 1.22.2.1
retrieving revision 1.22.2.2
diff -u -r1.22.2.1 -r1.22.2.2
--- AbstractBeanWriter.java 13 Jan 2004 21:49:46 -0000 1.22.2.1
+++ AbstractBeanWriter.java 15 Jan 2004 23:34:22 -0000 1.22.2.2
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -606,7 +606,7 @@
namespaceUri,
localName,
qualifiedName,
- new ElementAttributes(
+ new IDElementAttributes(
elementDescriptor,
context,
idAttribute,
@@ -900,21 +900,16 @@
return true;
}
-
-
-
/**
- * Attributes backed by attribute descriptors
+ * Attributes backed by attribute descriptors.
+ * ID/IDREFs not set.
*/
private class ElementAttributes implements Attributes {
/** Attribute descriptors backing the <code>Attributes</code> */
private AttributeDescriptor[] attributes;
/** Context to be evaluated when finding values */
private Context context;
- /** ID attribute value */
- private String idValue;
- /** ID attribute name */
- private String idAttributeName;
+
/**
@@ -928,25 +923,6 @@
this.context = context;
}
- /**
- * Construct attributes for element and context.
- *
- * @param descriptor the <code>ElementDescriptor</code> describing the element
- * @param context evaluate against this context
- * @param idAttributeName the name of the id attribute
- * @param idValue the ID attribute value
- */
- ElementAttributes(
- ElementDescriptor descriptor,
- Context context,
- String idAttributeName,
- String idValue) {
- attributes = descriptor.getAttributeDescriptors();
- this.context = context;
- this.idValue = idValue;
- this.idAttributeName = idAttributeName;
- }
-
/**
* Gets the index of an attribute by qualified name.
*
@@ -1078,19 +1054,12 @@
*/
public String getValue( int index ) {
if ( indexInRange( index )) {
- if (
- idAttributeName != null
- && idAttributeName.equals(attributes[index].getLocalName())) {
-
- return idValue;
-
- } else {
- Expression expression = attributes[index].getTextExpression();
- if ( expression != null ) {
- Object value = expression.evaluate( context );
- return convertToString( value, attributes[index], context );
- }
+ Expression expression = attributes[index].getTextExpression();
+ if ( expression != null ) {
+ Object value = expression.evaluate( context );
+ return convertToString( value, attributes[index], context );
}
+
return "";
}
return null;
@@ -1130,6 +1099,132 @@
private boolean indexInRange( int index ) {
return ( index >= 0 && index < attributes.length );
}
+ }
+
+ /**
+ * Attributes with generate ID/IDREF attributes
+ * //TODO: refactor the ID/REF generation so that it's fixed at introspection
+ * and the generators are placed into the Context.
+ * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
+ * @version $Revision$
+ */
+ private class IDElementAttributes extends ElementAttributes {
+ /** ID attribute value */
+ private String idValue;
+ /** ID attribute name */
+ private String idAttributeName;
+
+ private boolean matchingAttribute = false;
+ private int length;
+ private int idIndex;
+
+ /**
+ * Construct attributes for element and context.
+ *
+ * @param descriptor the <code>ElementDescriptor</code> describing the element
+ * @param context evaluate against this context
+ * @param idAttributeName the name of the id attribute
+ * @param idValue the ID attribute value
+ */
+ IDElementAttributes(
+ ElementDescriptor descriptor,
+ Context context,
+ String idAttributeName,
+ String idValue) {
+ super(descriptor, context);
+ this.idValue = idValue;
+ this.idAttributeName = idAttributeName;
+
+ // see if we have already have a matching attribute descriptor
+ AttributeDescriptor[] attributeDescriptors = descriptor.getAttributeDescriptors();
+ length = attributeDescriptors.length;
+ for (int i=0; i<length; i++) {
+ if (idAttributeName.equals(attributeDescriptors[i])) {
+ matchingAttribute = true;
+ idIndex = i;
+ break;
+ }
+ }
+ if (!matchingAttribute) {
+ length += 1;
+ idIndex = length-1;
+ }
+ }
+
+ public int getIndex(String uri, String localName) {
+ if (localName.equals(idAttributeName)) {
+ return idIndex;
+ }
+
+ return super.getIndex(uri, localName);
+ }
+
+ public int getIndex(String qName) {
+ if (qName.equals(idAttributeName)) {
+ return idIndex;
+ }
+
+ return super.getIndex(qName);
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public String getLocalName(int index) {
+ if (index == idIndex) {
+ return idAttributeName;
+ }
+ return super.getLocalName(index);
+ }
+
+ public String getQName(int index) {
+ if (index == idIndex) {
+ return idAttributeName;
+ }
+ return super.getQName(index);
+ }
+
+ public String getType(int index) {
+ if (index == idIndex) {
+ return "ID";
+ }
+ return super.getType(index);
+ }
+
+ public String getType(String uri, String localName) {
+ return getType(getIndex(uri, localName));
+ }
+
+ public String getType(String qName) {
+ return getType(getIndex(qName));
+ }
+
+ public String getURI(int index) {
+ //TODO: this is probably wrong
+ // probably need to move ID management into introspection
+ // before we can handle this namespace bit correctly
+ if (index == idIndex) {
+ return "";
+ }
+ return super.getURI(index);
+ }
+
+ public String getValue(int index) {
+ if (index == idIndex) {
+ return idValue;
+ }
+ return super.getValue(index);
+ }
+
+ public String getValue(String uri, String localName) {
+ return getValue(getIndex(uri, localName));
+ }
+
+ public String getValue(String qName) {
+ return getValue(getIndex(qName));
+ }
+
}
1.12.2.2 +5 -4 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/SAXBeanWriter.java
Index: SAXBeanWriter.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/SAXBeanWriter.java,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -u -r1.12.2.1 -r1.12.2.2
--- SAXBeanWriter.java 13 Jan 2004 21:49:46 -0000 1.12.2.1
+++ SAXBeanWriter.java 15 Jan 2004 23:34:22 -0000 1.12.2.2
@@ -192,6 +192,7 @@
* @since 1.0 Alpha 1
*/
protected void bodyText(String text) throws SAXException {
+ //TODO:
// FIX ME
// CHECK UNICODE->CHAR CONVERSION!
// THIS WILL QUITE POSSIBLY BREAK FOR NON-ROMAN
No revision
No revision
1.21.2.2 +4 -1 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanReader.java
Index: TestBeanReader.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanReader.java,v
retrieving revision 1.21.2.1
retrieving revision 1.21.2.2
diff -u -r1.21.2.1 -r1.21.2.2
--- TestBeanReader.java 15 Jan 2004 21:58:44 -0000 1.21.2.1
+++ TestBeanReader.java 15 Jan 2004 23:34:22 -0000 1.21.2.2
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -179,6 +179,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
+ writer.getBindingConfiguration().setMapIDs(false);
writer.enablePrettyPrint();
writer.write( bean );
return out.getBuffer().toString();
@@ -391,6 +392,7 @@
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
+ writer.getBindingConfiguration().setMapIDs(false);
XMLIntrospector introspector = writer.getXMLIntrospector();
introspector.setElementNameMapper(new HyphenatedNameMapper());
introspector.setAttributesForPrimitives(false);
@@ -444,6 +446,7 @@
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
+ writer.getBindingConfiguration().setMapIDs(false);
XMLIntrospector introspector = writer.getXMLIntrospector();
introspector.setElementNameMapper(new HyphenatedNameMapper());
introspector.setAttributesForPrimitives(false);
1.19.2.2 +9 -7 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanWriter.java
Index: TestBeanWriter.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanWriter.java,v
retrieving revision 1.19.2.1
retrieving revision 1.19.2.2
diff -u -r1.19.2.1 -r1.19.2.2
--- TestBeanWriter.java 15 Jan 2004 21:58:29 -0000 1.19.2.1
+++ TestBeanWriter.java 15 Jan 2004 23:34:22 -0000 1.19.2.2
@@ -130,13 +130,14 @@
writer.enablePrettyPrint();
writer.write( LoopBean.createNoLoopExampleBean() );
- String xml ="<?xml version='1.0'?><LoopBean><name>Root</name><friend><name>level1</name>"
- + "<friend><name>level2</name><friend><name>level3</name><friend><name>level4</name>"
- + "<friend><name>level5</name></friend></friend></friend></friend></friend></LoopBean>";
+ String xml ="<?xml version='1.0'?><LoopBean id='1'><name>Root</name><friend id='2'><name>level1</name>"
+ + "<friend id='3'><name>level2</name><friend id='4'><name>level3</name><friend id='5'><name>level4</name>"
+ + "<friend id='6'><name>level5</name></friend></friend></friend></friend></friend></LoopBean>";
+ String xmlOut = out.getBuffer().toString();
xmlAssertIsomorphicContent(
"Test no loop",
- parseString(out.getBuffer().toString()),
+ parseString(xmlOut),
parseString(xml),
true);
@@ -145,9 +146,9 @@
writer = new BeanWriter(out);
writer.setWriteEmptyElements( true );
writer.write( LoopBean.createLoopExampleBean() );
- xml ="<?xml version='1.0'?><LoopBean><name>Root</name><friend><name>level1</name>"
- + "<friend><name>level2</name><friend><name>level3</name><friend><name>level4</name>"
- + "<friend><name>level5</name><friend idref='1'/></friend></friend></friend>"
+ xml ="<?xml version='1.0'?><LoopBean id='1'><name>Root</name><friend id='2'><name>level1</name>"
+ + "<friend id='3'><name>level2</name><friend id='4'><name>level3</name><friend id='5'><name>level4</name>"
+ + "<friend id='6'><name>level5</name><friend idref='1'/></friend></friend></friend>"
+ "</friend></friend></LoopBean>";
xmlAssertIsomorphicContent(
"Test loop",
@@ -216,6 +217,7 @@
ByteArrayOutputStream out = new ByteArrayOutputStream();
BeanWriter writer = new BeanWriter(out);
writer.setWriteEmptyElements( true );
+ writer.getBindingConfiguration().setMapIDs(false);
writer.enablePrettyPrint();
XMLIntrospector introspector = new XMLIntrospector();
introspector.setAttributesForPrimitives(true);
1.4.2.1 +7 -5 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestDynaBeanSupport.java
Index: TestDynaBeanSupport.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestDynaBeanSupport.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- TestDynaBeanSupport.java 19 Oct 2003 14:44:53 -0000 1.4
+++ TestDynaBeanSupport.java 15 Jan 2004 23:34:22 -0000 1.4.2.1
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -135,6 +135,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
+ writer.getBindingConfiguration().setMapIDs(false);
writer.getXMLIntrospector().setElementNameMapper(new DecapitalizeNameMapper());
writer.write(dynasaur);
@@ -153,6 +154,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
+ writer.getBindingConfiguration().setMapIDs(false);
writer.getXMLIntrospector().setElementNameMapper(new DecapitalizeNameMapper());
writer.write("bean", bean);
No revision
No revision
1.8.2.1 +5 -4 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/digester/TestIDRead.java
Index: TestIDRead.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/digester/TestIDRead.java,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- TestIDRead.java 9 Oct 2003 20:52:08 -0000 1.8
+++ TestIDRead.java 15 Jan 2004 23:34:23 -0000 1.8.2.1
@@ -103,6 +103,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
+ writer.getBindingConfiguration().setMapIDs(false);
IDBean bean = new IDBean("alpha","one");
bean.addChild(new IDBean("beta","two"));
bean.addChild(new IDBean("gamma","three"));
No revision
No revision
1.15.2.2 +6 -3 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/dotbetwixt/TestBeanToXml.java
Index: TestBeanToXml.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/dotbetwixt/TestBeanToXml.java,v
retrieving revision 1.15.2.1
retrieving revision 1.15.2.2
diff -u -r1.15.2.1 -r1.15.2.2
--- TestBeanToXml.java 15 Jan 2004 22:01:56 -0000 1.15.2.1
+++ TestBeanToXml.java 15 Jan 2004 23:34:23 -0000 1.15.2.2
@@ -174,6 +174,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0' encoding='UTF-8'?>");
BeanWriter writer = new BeanWriter( out );
+ writer.getBindingConfiguration().setMapIDs(false);
writer.write( new MixedContentBean("First", "Last", "Always") );
String xml = "<?xml version='1.0' encoding='UTF-8'?><foo version='1.0'>"
@@ -189,6 +190,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0' encoding='UTF-8'?>");
BeanWriter writer = new BeanWriter( out );
+ writer.getBindingConfiguration().setMapIDs(false);
writer.write( new MixedContentOne("Life,", "The Universe And Everything", 42) );
String xml = "<?xml version='1.0' encoding='UTF-8'?><deep-thought alpha='Life,' gamma='42'>"
@@ -210,6 +212,7 @@
out.write("<?xml version='1.0' encoding='UTF-8'?>");
BeanWriter writer = new BeanWriter( out );
+ writer.getBindingConfiguration().setMapIDs(false);
writer.getXMLIntrospector().setElementNameMapper(new HyphenatedNameMapper());
writer.getXMLIntrospector().setWrapCollectionsInElement(false);
No revision
No revision
1.10.2.3 +5 -4 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/introspection/TestXMLIntrospector.java
Index: TestXMLIntrospector.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/introspection/TestXMLIntrospector.java,v
retrieving revision 1.10.2.2
retrieving revision 1.10.2.3
diff -u -r1.10.2.2 -r1.10.2.3
--- TestXMLIntrospector.java 15 Jan 2004 21:57:18 -0000 1.10.2.2
+++ TestXMLIntrospector.java 15 Jan 2004 23:34:23 -0000 1.10.2.3
@@ -313,6 +313,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter( out );
+ writer.getBindingConfiguration().setMapIDs(false);
writer.getXMLIntrospector().setClassNormalizer( classNormalizer );
FaceImpl bean = new FaceImpl();
bean.setName("Old Tom Cobbly");
No revision
No revision
1.9.2.1 +5 -4 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/io/TestSAXBeanWriter.java
Index: TestSAXBeanWriter.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/io/TestSAXBeanWriter.java,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- TestSAXBeanWriter.java 19 Oct 2003 14:58:24 -0000 1.9
+++ TestSAXBeanWriter.java 15 Jan 2004 23:34:23 -0000 1.9.2.1
@@ -106,6 +106,7 @@
SAXBeanWriter writer = new SAXBeanWriter(new SAXContentHandler(out));
//writer.setLog(log);
+ writer.getBindingConfiguration().setMapIDs(false);
writer.write(bean);
String beanString = out.getBuffer().toString();
String xml = "<?xml version='1.0'?><PersonBean><age>35</age>"
No revision
No revision
1.4.2.1 +7 -5 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/io/read/TestBeanCreation.java
Index: TestBeanCreation.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/io/read/TestBeanCreation.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- TestBeanCreation.java 19 Oct 2003 14:44:54 -0000 1.4
+++ TestBeanCreation.java 15 Jan 2004 23:34:23 -0000 1.4.2.1
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -105,6 +105,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
+ writer.getBindingConfiguration().setMapIDs(false);
writer.getXMLIntrospector().setAttributesForPrimitives(true);
writer.getXMLIntrospector().setWrapCollectionsInElement(false);
writer.write("houses", houses);
@@ -188,6 +189,7 @@
StringWriter out = new StringWriter();
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
+ writer.getBindingConfiguration().setMapIDs(false);
writer.getXMLIntrospector().setAttributesForPrimitives(true);
writer.getXMLIntrospector().setWrapCollectionsInElement(false);
writer.write("houses", houses);
No revision
No revision
1.13.2.3 +42 -4 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/recursion/TestRecursion.java
Index: TestRecursion.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/recursion/TestRecursion.java,v
retrieving revision 1.13.2.2
retrieving revision 1.13.2.3
diff -u -r1.13.2.2 -r1.13.2.3
--- TestRecursion.java 15 Jan 2004 20:41:29 -0000 1.13.2.2
+++ TestRecursion.java 15 Jan 2004 23:34:23 -0000 1.13.2.3
@@ -61,6 +61,7 @@
package org.apache.commons.betwixt.recursion;
+import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
@@ -378,5 +379,42 @@
fail("Expected registration to succeed");
}
}
+
+ public void testCycleReferences() throws Exception {
+ PersonTest person = new PersonTest();
+ person.setName("John Doe");
+ AddressTest address = new AddressTest();
+ address.setStreetAddress("1221 Washington Street");
+ person.setAddress(address);
+ ReferenceTest reference = new ReferenceTest();
+ reference.setPerson(person);
+ address.setReference(reference);
+
+ StringWriter outputWriter = new StringWriter();
+
+ outputWriter.write("<?xml version='1.0' ?>\n");
+ BeanWriter beanWriter = new BeanWriter(outputWriter);
+ beanWriter.enablePrettyPrint();
+ beanWriter.getBindingConfiguration().setMapIDs(true);
+ beanWriter.write(person);
+
+ BeanReader beanReader = new BeanReader();
+ beanReader.getBindingConfiguration().setMapIDs(true);
+
+ // Configure the reader
+ beanReader.registerBeanClass(PersonTest.class);
+ beanReader.registerBeanClass(AddressTest.class);
+ beanReader.registerBeanClass(ReferenceTest.class);
+
+ String out = outputWriter.toString();
+ StringReader xmlReader = new StringReader(out);
+
+ //Parse the xml
+ PersonTest result = (PersonTest)beanReader.parse(xmlReader);
+ assertSame("Cycle did not result in the same reference", result, result.getAddress().getReference().getPerson());
+
+ }
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org