2 * Copyright (C) 2007-2012 Mathieu Baudier
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.slc
.hibernate
.test
.tree
;
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
;
28 public class CastorTestResultDaoHibernateTest
extends HibernateTestCase
{
30 public void testUnmarshallAndCreate() throws Exception
{
31 TreeTestResult ttr
= TreeTestResultTestUtils
32 .createCompleteTreeTestResult();
34 StringResult result
= new StringResult();
35 getBean(Marshaller
.class).marshal(ttr
, result
);
37 StringSource source
= new StringSource(result
.toString());
38 TreeTestResult ttrUnm
= (TreeTestResult
) getBean(Unmarshaller
.class)
41 for (TreeSPath path
: ttrUnm
.getResultParts().keySet()) {
42 log
.debug("Path: " + path
.getClass() + ": " + path
);
45 TreeTestResultDao ttrDao
= getBean(TreeTestResultDao
.class);
46 ttrDao
.create(ttrUnm
);
47 TreeTestResult ttrPersist
= ttrDao
.getTestResult(ttr
.getUuid());
49 TreeTestResultDaoHibernateTest
.assertInHibernate(
50 getHibernateTemplate(), ttr
, ttrPersist
);
54 protected String
getApplicationContextLocation() {
55 return "org/argeo/slc/hibernate/withCastor.xml";