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
.msg
.test
.tree
.TreeTestResultRequest
;
15 import org
.argeo
.slc
.unit
.AbstractSpringTestCase
;
16 import org
.argeo
.slc
.unit
.UnitXmlUtils
;
17 import org
.argeo
.slc
.unit
.test
.tree
.UnitTestTreeUtil
;
19 public class TreeTestResultCastorTest
extends AbstractSpringTestCase
{
20 private Log log
= LogFactory
.getLog(getClass());
22 private Marshaller marshaller
;
23 private Unmarshaller unmarshaller
;
27 marshaller
= getBean("marshaller");
28 unmarshaller
= getBean("marshaller");
33 public void testMarshUnmarsh() throws Exception
{
34 TreeTestResult ttr
= createCompleteTreeTestResult();
36 StringResult xml
= new StringResult();
37 marshaller
.marshal(ttr
, xml
);
39 log
.info("Marshalled TreeTestResult: " + xml
);
41 XsdSchema schema
= getBean("schema");
42 UnitXmlUtils
.assertXsdSchemaValidation(schema
, new StringSource(xml
45 TreeTestResult ttrUnm
= (TreeTestResult
) unmarshaller
46 .unmarshal(new StringSource(xml
.toString()));
48 UnitTestTreeUtil
.assertTreeTestResult(ttr
, ttrUnm
);
51 public void testTreeTestResultRequest() throws Exception
{
52 TreeTestResultRequest req
= new TreeTestResultRequest();
53 req
.setTreeTestResult(createCompleteTreeTestResult());
55 StringResult xml
= new StringResult();
56 marshaller
.marshal(req
, xml
);
58 log
.info("Marshalled TreeTestResult Request: " + xml
);
60 XsdSchema schema
= getBean("schema");
61 UnitXmlUtils
.assertXsdSchemaValidation(schema
, new StringSource(xml
64 TreeTestResultRequest reqUnm
= (TreeTestResultRequest
) unmarshaller
65 .unmarshal(new StringSource(xml
.toString()));
67 UnitTestTreeUtil
.assertTreeTestResult(req
.getTreeTestResult(), reqUnm
.getTreeTestResult());