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.inheritance3;
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 polymorphic relationship, with the
26: * base class having a colleciton of properties, all is well and no
27: * internal id is generated for the
28: * {@link org.compass.core.test.component.inheritance3.Child#names}
29: * mapping.
30: *
31: * @author kimchy
32: */
33: public class Ineritance3Tests extends AbstractTestCase {
34:
35: protected String[] getMappings() {
36: return new String[] { "component/inheritance3/mapping.cpm.xml" };
37: }
38:
39: public void testCorrectInternalId() {
40: CompassSession session = openSession();
41: CompassTransaction tr = session.beginTransaction();
42:
43: Father father = new Father();
44: father.id = "1";
45: father.child = new Child();
46: father.child.names = new String[] { "value1", "value2" };
47: session.save(father);
48:
49: Resource resource = session.loadResource(Father.class, "1");
50: assertEquals(7, resource.getProperties().length);
51: assertEquals("father", resource.getValue("alias"));
52: assertEquals("1", resource.getValue("$/father/id"));
53: assertEquals(2, resource.getProperties("name").length);
54: assertEquals(Child.class.getName(), resource
55: .getValue("$/father/child/class"));
56: assertEquals("2", resource
57: .getValue("$/father/child/names/colSize"));
58:
59: father = (Father) session.load(Father.class, "1");
60: assertEquals(2, father.child.names.length);
61: assertEquals("value1", father.child.names[0]);
62: assertEquals("value2", father.child.names[1]);
63:
64: tr.commit();
65: session.close();
66: }
67: }
|