import junit.framework.TestCase; import cc.lovo.types.MyEL; import cc.lovo.types.ObjectFactory; import cc.lovo.types.AnotherElement; import javax.xml.bind.JAXBException; import java.io.StringWriter; import com.sun.xml.bind.StringInputStream; /** * @author csturm */ public class JaxbTest extends TestCase { public void testJaxbProblem() throws JAXBException { ObjectFactory o = new ObjectFactory(); MyEL myEL = o.createMyEL(); myEL.setWhatever("whatever"); AnotherElement anotherElement = o.createAnotherElement(); anotherElement.setCtHolder(myEL); StringWriter stringWriter = new StringWriter(); o.createMarshaller().marshal(anotherElement, stringWriter); o.createUnmarshaller().unmarshal(new StringInputStream(stringWriter.toString())); } }