]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.core/src/test/java/org/argeo/slc/core/test/tree/TreeTestResultCastorTest.java
Implemented a first version of testUpdate.
[gpl/argeo-slc.git] / org.argeo.slc.core / src / test / java / org / argeo / slc / core / test / tree / TreeTestResultCastorTest.java
1 package org.argeo.slc.core.test.tree;
2
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;
8
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11
12 import static org.argeo.slc.core.test.tree.TreeTestResultTestUtils.createCompleteTreeTestResult;
13
14 import org.argeo.slc.unit.AbstractSpringTestCase;
15 import org.argeo.slc.unit.UnitXmlUtils;
16 import org.argeo.slc.unit.test.tree.UnitTestTreeUtil;
17
18 public class TreeTestResultCastorTest extends AbstractSpringTestCase {
19 private Log log = LogFactory.getLog(getClass());
20
21 public void testMarshUnmarsh() throws Exception {
22 Marshaller marshaller = getBean("marshaller");
23 Unmarshaller unmarshaller = getBean("marshaller");
24
25 TreeTestResult ttr = createCompleteTreeTestResult();
26
27 StringResult xml = new StringResult();
28 marshaller.marshal(ttr, xml);
29
30 log.info("Marshalled TreeTestResult: " + xml);
31
32 XsdSchema schema = getBean("schema");
33 UnitXmlUtils.assertXsdSchemaValidation(schema, new StringSource(xml
34 .toString()));
35
36 TreeTestResult ttrUnm = (TreeTestResult) unmarshaller
37 .unmarshal(new StringSource(xml.toString()));
38
39 UnitTestTreeUtil.assertTreeTestResult(ttr, ttrUnm);
40
41 }
42 }