I'm running into an issue performing a round trip serializing then
deserializing an object that contains an empty array of Properties.  I've
created a small test case below that illustrates the issue.  It seems to
work fine when going to XML (using the DomDriver), but not JSON (using
the JettisonMappedXmlDriver).  Do I need to create a custom converter for
this, is this a bug, or am I just missing something.  Any insight that can
be provided is appreciated. Thanks in advance!

Thanks,
Michael Minella

import java.io.ByteArrayInputStream;

import java.io.ByteArrayOutputStream;

import java.util.Properties;


import org.junit.Test;


import com.thoughtworks.xstream.XStream;

import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;

import com.thoughtworks.xstream.io.xml.DomDriver;


public class XStreamPropertiesTest {


private XStream xstream;


@Test

public void testPropertiesArrayJson() throws Exception {

xstream = new XStream(new JettisonMappedXmlDriver());

testLogic();

}


@Test

public void testPropertiesArrayXML() throws Exception {

xstream = new XStream(new DomDriver());

testLogic();

}


private void testLogic() {

TestClass test = new TestClass();

test.setProps(new Properties[3]);


ByteArrayOutputStream out = new ByteArrayOutputStream();


xstream.toXML(test, out);

System.err.println("out = " + out.toString());

TestClass result = (TestClass)
xstream.fromXML(newByteArrayInputStream(out.toByteArray()));

}


public static class TestClass {

private Properties[] props;


public void setProps(Properties[] props) {

this.props = props;

}


public Properties[] getProps() {

return props;

}

}

}

Reply via email to