import org.springframework.oxm.Unmarshaller;\r
import org.springframework.xml.transform.StringResult;\r
import org.springframework.xml.transform.StringSource;\r
+import org.springframework.xml.xsd.XsdSchema;\r
\r
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
\r
import static org.argeo.slc.core.test.tree.TreeTestResultTestUtils.createCompleteTreeTestResult;\r
\r
+import org.argeo.slc.msg.test.tree.TreeTestResultRequest;\r
import org.argeo.slc.unit.AbstractSpringTestCase;\r
+import org.argeo.slc.unit.UnitXmlUtils;\r
import org.argeo.slc.unit.test.tree.UnitTestTreeUtil;\r
\r
public class TreeTestResultCastorTest extends AbstractSpringTestCase {\r
private Log log = LogFactory.getLog(getClass());\r
+ \r
+ private Marshaller marshaller;\r
+ private Unmarshaller unmarshaller;\r
+\r
+ @Override\r
+ public void setUp() {\r
+ marshaller = getBean("marshaller");\r
+ unmarshaller = getBean("marshaller");\r
+ }\r
\r
- public void testMarshUnmarsh() throws Exception {\r
- Marshaller marshaller = getBean("marshaller");\r
- Unmarshaller unmarshaller = getBean("marshaller");\r
\r
+\r
+ public void testMarshUnmarsh() throws Exception {\r
TreeTestResult ttr = createCompleteTreeTestResult();\r
\r
StringResult xml = new StringResult();\r
\r
log.info("Marshalled TreeTestResult: " + xml);\r
\r
+ XsdSchema schema = getBean("schema");\r
+ UnitXmlUtils.assertXsdSchemaValidation(schema, new StringSource(xml\r
+ .toString()));\r
+\r
TreeTestResult ttrUnm = (TreeTestResult) unmarshaller\r
.unmarshal(new StringSource(xml.toString()));\r
\r
UnitTestTreeUtil.assertTreeTestResult(ttr, ttrUnm);\r
+ }\r
+ \r
+ public void testTreeTestResultRequest() throws Exception{\r
+ TreeTestResultRequest req = new TreeTestResultRequest();\r
+ req.setTreeTestResult(createCompleteTreeTestResult());\r
+ \r
+ StringResult xml = new StringResult();\r
+ marshaller.marshal(req, xml);\r
+\r
+ log.info("Marshalled TreeTestResult Request: " + xml);\r
+\r
+ XsdSchema schema = getBean("schema");\r
+ UnitXmlUtils.assertXsdSchemaValidation(schema, new StringSource(xml\r
+ .toString()));\r
+\r
+ TreeTestResultRequest reqUnm = (TreeTestResultRequest) unmarshaller\r
+ .unmarshal(new StringSource(xml.toString()));\r
\r
+ UnitTestTreeUtil.assertTreeTestResult(req.getTreeTestResult(), reqUnm.getTreeTestResult());\r
}\r
}\r