01: package org.compass.core.test.reference.withprop;
02:
03: import org.compass.core.CompassHits;
04: import org.compass.core.CompassSession;
05: import org.compass.core.CompassTransaction;
06: import org.compass.core.config.CompassEnvironment;
07: import org.compass.core.config.CompassSettings;
08: import org.compass.core.test.AbstractTestCase;
09:
10: /**
11: * @author kimchy
12: */
13: public class ReferenceWithPropTests extends AbstractTestCase {
14:
15: protected void addSettings(CompassSettings settings) {
16: settings.setGroupSettings(CompassEnvironment.Converter.PREFIX,
17: "b",
18: new String[] { CompassEnvironment.Converter.TYPE },
19: new String[] { BConverter.class.getName() });
20: }
21:
22: protected String[] getMappings() {
23: return new String[] { "reference/withprop/mapping.cpm.xml" };
24: }
25:
26: public void testReferenceWithProperty() {
27: CompassSession session = openSession();
28: CompassTransaction tr = session.beginTransaction();
29:
30: A a = new A();
31: a.id = new Long(1);
32: a.b = new B();
33: a.b.id = new Long(1);
34: a.b.value = "test";
35:
36: session.save(a);
37: session.save(a.b);
38:
39: a = (A) session.load(A.class, "1");
40: assertEquals("test", a.b.value);
41: B b = (B) session.load(B.class, "1");
42: assertEquals("test", b.value);
43:
44: // A test that shows we don't support property and reference on the same mapping
45: CompassHits hits = session.find("test");
46: assertEquals(1, hits.length());
47:
48: tr.commit();
49: session.close();
50: }
51: }
|