1 package org
.argeo
.slc
.core
.test
.tree
;
3 import org
.springframework
.oxm
.Marshaller
;
4 import org
.springframework
.oxm
.Unmarshaller
;
5 import org
.springframework
.xml
.transform
.StringResult
;
6 import org
.springframework
.xml
.transform
.StringSource
;
7 import org
.springframework
.xml
.xsd
.XsdSchema
;
9 import org
.apache
.commons
.logging
.Log
;
10 import org
.apache
.commons
.logging
.LogFactory
;
12 import static org
.argeo
.slc
.core
.test
.tree
.TreeTestResultTestUtils
.createCompleteTreeTestResult
;
14 import org
.argeo
.slc
.unit
.AbstractSpringTestCase
;
15 import org
.argeo
.slc
.unit
.UnitXmlUtils
;
16 import org
.argeo
.slc
.unit
.test
.tree
.UnitTestTreeUtil
;
18 public class TreeTestResultCastorTest
extends AbstractSpringTestCase
{
19 private Log log
= LogFactory
.getLog(getClass());
21 public void testMarshUnmarsh() throws Exception
{
22 Marshaller marshaller
= getBean("marshaller");
23 Unmarshaller unmarshaller
= getBean("marshaller");
25 TreeTestResult ttr
= createCompleteTreeTestResult();
27 StringResult xml
= new StringResult();
28 marshaller
.marshal(ttr
, xml
);
30 log
.info("Marshalled TreeTestResult: " + xml
);
32 XsdSchema schema
= getBean("schema");
33 UnitXmlUtils
.assertXsdSchemaValidation(schema
, new StringSource(xml
36 TreeTestResult ttrUnm
= (TreeTestResult
) unmarshaller
37 .unmarshal(new StringSource(xml
.toString()));
39 UnitTestTreeUtil
.assertTreeTestResult(ttr
, ttrUnm
);