01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.compass.core.test.component.inheritance2;
18:
19: import org.compass.core.CompassSession;
20: import org.compass.core.CompassTransaction;
21: import org.compass.core.Resource;
22: import org.compass.core.test.AbstractTestCase;
23:
24: /**
25: * This test verifies that with ploymprphic relationship, on the component
26: * of the component mapping, things works. Also verifies that no intenral
27: * id is created for {@link org.compass.core.test.component.inheritance2.GrandChild#value}.
28: *
29: * @author kimchy
30: */
31: public class Ineritance2Tests extends AbstractTestCase {
32:
33: protected String[] getMappings() {
34: return new String[] { "component/inheritance2/mapping.cpm.xml" };
35: }
36:
37: public void testCorrectInternalId() {
38: CompassSession session = openSession();
39: CompassTransaction tr = session.beginTransaction();
40:
41: Father father = new Father();
42: father.id = "1";
43: father.child = new Child();
44: father.child.child = new GrandChild1();
45: father.child.child.value = "value";
46: session.save(father);
47:
48: Resource resource = session.loadResource(Father.class, "1");
49: assertEquals(5, resource.getProperties().length);
50: assertEquals("father", resource.getValue("alias"));
51: assertEquals("1", resource.getValue("$/father/id"));
52: assertEquals("value", resource.getValue("value"));
53: assertEquals(GrandChild1.class.getName(), resource
54: .getValue("$/father/child/child/class"));
55:
56: father = (Father) session.load(Father.class, "1");
57: assertEquals("1", father.id);
58: assertEquals("value", father.child.child.value);
59:
60: tr.commit();
61: session.close();
62: }
63: }
|