]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.hibernate/src/test/java/org/argeo/slc/hibernate/test/tree/CastorTestResultDaoHibernateTest.java
Update headers
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.hibernate / src / test / java / org / argeo / slc / hibernate / test / tree / CastorTestResultDaoHibernateTest.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.hibernate.test.tree;
17
18 import org.argeo.slc.core.structure.tree.TreeSPath;
19 import org.argeo.slc.core.test.tree.TreeTestResult;
20 import org.argeo.slc.dao.test.tree.TreeTestResultDao;
21 import org.argeo.slc.hibernate.unit.HibernateTestCase;
22 import org.argeo.slc.unit.test.tree.TreeTestResultTestUtils;
23 import org.springframework.oxm.Marshaller;
24 import org.springframework.oxm.Unmarshaller;
25 import org.springframework.xml.transform.StringResult;
26 import org.springframework.xml.transform.StringSource;
27
28 public class CastorTestResultDaoHibernateTest extends HibernateTestCase {
29
30 public void testUnmarshallAndCreate() throws Exception {
31 TreeTestResult ttr = TreeTestResultTestUtils
32 .createCompleteTreeTestResult();
33
34 StringResult result = new StringResult();
35 getBean(Marshaller.class).marshal(ttr, result);
36
37 StringSource source = new StringSource(result.toString());
38 TreeTestResult ttrUnm = (TreeTestResult) getBean(Unmarshaller.class)
39 .unmarshal(source);
40
41 for (TreeSPath path : ttrUnm.getResultParts().keySet()) {
42 log.debug("Path: " + path.getClass() + ": " + path);
43 }
44
45 TreeTestResultDao ttrDao = getBean(TreeTestResultDao.class);
46 ttrDao.create(ttrUnm);
47 TreeTestResult ttrPersist = ttrDao.getTestResult(ttr.getUuid());
48
49 TreeTestResultDaoHibernateTest.assertInHibernate(
50 getHibernateTemplate(), ttr, ttrPersist);
51 }
52
53 @Override
54 protected String getApplicationContextLocation() {
55 return "org/argeo/slc/hibernate/withCastor.xml";
56 }
57
58 }