01: package org.compass.core.test.component.inheritance1;
02:
03: import org.compass.core.CompassSession;
04: import org.compass.core.CompassTransaction;
05: import org.compass.core.Resource;
06: import org.compass.core.config.CompassEnvironment;
07: import org.compass.core.config.CompassSettings;
08: import org.compass.core.test.AbstractTestCase;
09:
10: /**
11: * This holds a pretty complex relationship that has been reported as
12: * broken in Compass. The main goal here is to test that the relationship
13: * is supported.
14: *
15: * @author kimchy
16: */
17: public class NoUnmarshallInheritance1Tests extends AbstractTestCase {
18:
19: protected String[] getMappings() {
20: return new String[] { "component/inheritance1/Father.cpm.xml",
21: "component/inheritance1/Child.cpm.xml" };
22: }
23:
24: protected void addSettings(CompassSettings settings) {
25: settings.setBooleanSetting(
26: CompassEnvironment.Osem.SUPPORT_UNMARSHALL, false);
27: }
28:
29: public void testCorrectFatherSave() throws Exception {
30: CompassSession session = openSession();
31: CompassTransaction tr = session.beginTransaction();
32:
33: FatherImpl.resetId();
34:
35: FatherImpl father = new FatherImpl("Sir Ivan");
36: FavouriteSonImpl favouriteSon = new FavouriteSonImpl("Ivan Jr",
37: father);
38: father.setFavouriteSon(favouriteSon);
39:
40: DaughterImpl daughter = new DaughterImpl("Betty Jr", father);
41: father.getChildren().add(daughter);
42:
43: session.save(father);
44:
45: Resource resource = session.loadResource("father", father
46: .getId());
47: assertEquals(8, resource.getProperties().length);
48: assertEquals("father", resource.getValue("alias"));
49: assertEquals("0", resource.getValue("$/father/id"));
50: assertEquals("Sir Ivan", resource.getProperties("name")[0]
51: .getStringValue());
52: assertEquals("Ivan Jr", resource.getProperties("name")[1]
53: .getStringValue());
54: assertEquals("child", resource.getProperties("childalias")[0]
55: .getStringValue());
56: assertEquals("Betty Jr", resource.getProperties("name")[2]
57: .getStringValue());
58: assertEquals("child", resource.getProperties("childalias")[1]
59: .getStringValue());
60:
61: tr.commit();
62: session.close();
63: }
64: }
|