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.inferalias;
18:
19: import org.compass.core.CompassSession;
20: import org.compass.core.CompassTransaction;
21: import org.compass.core.test.AbstractTestCase;
22: import org.compass.core.test.component.SimpleComponent;
23: import org.compass.core.test.component.SimpleRoot;
24:
25: /**
26: * @author kimchy
27: */
28: public class InferComponentRefAliasTests extends AbstractTestCase {
29:
30: protected String[] getMappings() {
31: return new String[] {
32: "component/inferalias/InferRefAlias.cpm.xml",
33: "component/SimpleComponent.cpm.xml" };
34: }
35:
36: public void testInferRefAlias() {
37: CompassSession session = openSession();
38: CompassTransaction tr = session.beginTransaction();
39:
40: Long id = new Long(1);
41:
42: SimpleRoot root = new SimpleRoot();
43: root.setId(id);
44: root.setValue("test");
45: SimpleComponent first = new SimpleComponent();
46: first.setValue("test1");
47: root.setFirstComponent(first);
48: SimpleComponent second = new SimpleComponent();
49: second.setValue("test2");
50: root.setSecondComponent(second);
51: session.save("sr-infer", root);
52:
53: root = (SimpleRoot) session.load("sr-infer", id);
54: assertEquals("test", root.getValue());
55: assertNotNull(root.getFirstComponent());
56: assertEquals("test1", root.getFirstComponent().getValue());
57: assertNotNull(root.getSecondComponent());
58: assertEquals("test2", root.getSecondComponent().getValue());
59:
60: tr.commit();
61: }
62:
63: }
|