]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org/argeo/jcr/MapperTest.java
Prepare next development cycle
[lgpl/argeo-commons.git] / org / argeo / jcr / MapperTest.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
17 package org.argeo.jcr;
18
19 import java.io.File;
20
21 import javax.jcr.Node;
22 import javax.jcr.Repository;
23
24 import org.apache.jackrabbit.core.TransientRepository;
25 import org.argeo.jcr.unit.AbstractJcrTestCase;
26 import org.springframework.core.io.ClassPathResource;
27 import org.springframework.core.io.Resource;
28
29 public class MapperTest extends AbstractJcrTestCase {
30 public void testSimpleObject() throws Exception {
31 SimpleObject mySo = new SimpleObject();
32 mySo.setInteger(100);
33 mySo.setString("hello world");
34
35 OtherObject oo1 = new OtherObject();
36 oo1.setKey("someKey");
37 oo1.setValue("stringValue");
38 mySo.setOtherObject(oo1);
39
40 OtherObject oo2 = new OtherObject();
41 oo2.setKey("anotherSimpleObject");
42 oo2.setValue(new SimpleObject());
43 mySo.setAnotherObject(oo2);
44
45 BeanNodeMapper bnm = new BeanNodeMapper();
46
47 Node node = bnm.save(session(), mySo);
48 session().save();
49 JcrUtils.debug(node);
50 }
51
52 protected File getRepositoryFile() throws Exception {
53 Resource res = new ClassPathResource(
54 "org/argeo/server/jcr/repository.xml");
55 return res.getFile();
56 }
57
58 protected Repository createRepository() throws Exception{
59 Repository repository = new TransientRepository(getRepositoryFile(), getHomeDir());
60 return repository;
61 }
62
63
64 }