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.managedidconverter;
18:
19: import org.compass.core.CompassSession;
20: import org.compass.core.CompassTransaction;
21: import org.compass.core.Resource;
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 ManagedIdConverterTests extends AbstractTestCase {
30:
31: protected String[] getMappings() {
32: return new String[] { "managedidconverter/A.cpm.xml" };
33: }
34:
35: protected void addSettings(CompassSettings settings) {
36: settings.setGroupSettings(CompassEnvironment.Converter.PREFIX,
37: "simple",
38: new String[] { CompassEnvironment.Converter.TYPE },
39: new String[] { SimpleConverter.class.getName() });
40:
41: }
42:
43: public void testManagedIdConverter() {
44: CompassSession session = openSession();
45: CompassTransaction tr = session.beginTransaction();
46:
47: A a = new A();
48: a.id = 1;
49: a.value1 = "value1";
50: a.value2 = "value2";
51: session.save("a", a);
52:
53: a = (A) session.load("a", new Integer(1));
54: assertEquals("value1", a.value1);
55: assertEquals("value2", a.value2);
56:
57: // check that the simple converter was applied to the managed id created
58: Resource resource = session.loadResource("a", new Integer(1));
59: assertEquals("Xvalue1", resource.getValue("$/a/value1"));
60: assertEquals("Xvalue2", resource.getValue("$/a/value2"));
61:
62: tr.commit();
63: session.close();
64: }
65: }
|