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.override;
18:
19: import org.compass.core.CompassHits;
20: import org.compass.core.CompassSession;
21: import org.compass.core.CompassTransaction;
22: import org.compass.core.config.CompassEnvironment;
23: import org.compass.core.config.CompassSettings;
24: import org.compass.core.test.AbstractTestCase;
25:
26: /**
27: * @author kimchy
28: */
29: public class OverrideTests extends AbstractTestCase {
30:
31: protected String[] getMappings() {
32: return new String[] { "component/override/mapping.cpm.xml" };
33: }
34:
35: protected void addSettings(CompassSettings settings) {
36: settings.setGroupSettings(CompassEnvironment.Converter.PREFIX,
37: "bconv",
38: new String[] { CompassEnvironment.Converter.TYPE },
39: new String[] { BConverter.class.getName() });
40: }
41:
42: public void testCompositeId() {
43: CompassSession session = openSession();
44: CompassTransaction tr = session.beginTransaction();
45:
46: A a = new A();
47: a.id = "1";
48: a.b = new B();
49: a.b.value = "test";
50: session.save(a);
51:
52: a = (A) session.load(A.class, "1");
53: assertEquals(a.b.value, "test");
54:
55: CompassHits hits = session.find("value:test");
56: assertEquals(1, hits.length());
57: hits = session.find("flatten:test");
58: assertEquals(1, hits.length());
59:
60: tr.commit();
61: session.close();
62: }
63: }
|