]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/jcr/MapperTest.java
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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.
17 package org
.argeo
.jcr
;
21 import javax
.jcr
.Node
;
22 import javax
.jcr
.Repository
;
24 import org
.apache
.jackrabbit
.core
.TransientRepository
;
25 import org
.argeo
.jcr
.spring
.BeanNodeMapper
;
26 import org
.argeo
.jcr
.unit
.AbstractJcrTestCase
;
27 import org
.springframework
.core
.io
.ClassPathResource
;
28 import org
.springframework
.core
.io
.Resource
;
30 public class MapperTest
extends AbstractJcrTestCase
{
31 public void testSimpleObject() throws Exception
{
32 SimpleObject mySo
= new SimpleObject();
34 mySo
.setString("hello world");
36 OtherObject oo1
= new OtherObject();
37 oo1
.setKey("someKey");
38 oo1
.setValue("stringValue");
39 mySo
.setOtherObject(oo1
);
41 OtherObject oo2
= new OtherObject();
42 oo2
.setKey("anotherSimpleObject");
43 oo2
.setValue(new SimpleObject());
44 mySo
.setAnotherObject(oo2
);
46 BeanNodeMapper bnm
= new BeanNodeMapper();
48 Node node
= bnm
.save(session(), mySo
);
53 protected File
getRepositoryFile() throws Exception
{
54 Resource res
= new ClassPathResource(
55 "org/argeo/server/jcr/repository-h2.xml");
59 protected Repository
createRepository() throws Exception
{
60 Repository repository
= new TransientRepository(getRepositoryFile(), getHomeDir());