]> git.argeo.org Git - lgpl/argeo-commons.git/blob - server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/jcr/MapperTest.java
Fix path generation based on date
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jcr / src / test / java / 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.spring.BeanNodeMapper;
26 import org.argeo.jcr.unit.AbstractJcrTestCase;
27 import org.springframework.core.io.ClassPathResource;
28 import org.springframework.core.io.Resource;
29
30 public class MapperTest extends AbstractJcrTestCase {
31 public void testSimpleObject() throws Exception {
32 SimpleObject mySo = new SimpleObject();
33 mySo.setInteger(100);
34 mySo.setString("hello world");
35
36 OtherObject oo1 = new OtherObject();
37 oo1.setKey("someKey");
38 oo1.setValue("stringValue");
39 mySo.setOtherObject(oo1);
40
41 OtherObject oo2 = new OtherObject();
42 oo2.setKey("anotherSimpleObject");
43 oo2.setValue(new SimpleObject());
44 mySo.setAnotherObject(oo2);
45
46 BeanNodeMapper bnm = new BeanNodeMapper();
47
48 Node node = bnm.save(session(), mySo);
49 session().save();
50 JcrUtils.debug(node);
51 }
52
53 protected File getRepositoryFile() throws Exception {
54 Resource res = new ClassPathResource(
55 "org/argeo/server/jcr/repository-h2.xml");
56 return res.getFile();
57 }
58
59 protected Repository createRepository() throws Exception{
60 Repository repository = new TransientRepository(getRepositoryFile(), getHomeDir());
61 return repository;
62 }
63
64
65 }