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.converter.classmapping;
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 ClassMappingConverterTests extends AbstractTestCase {
30:
31: protected String[] getMappings() {
32: return new String[] { "converter/classmapping/mapping.cpm.xml" };
33: }
34:
35: protected void addSettings(CompassSettings settings) {
36: settings
37: .setGroupSettings(
38: CompassEnvironment.Converter.PREFIX,
39: CompassEnvironment.Converter.DefaultTypeNames.Mapping.CLASS_MAPPING,
40: new String[] { CompassEnvironment.Converter.TYPE },
41: new String[] { CustomClassMappingConverter.class
42: .getName() });
43: }
44:
45: public void testCustomClassMapping() {
46: CompassSession session = openSession();
47: CompassTransaction tr = session.beginTransaction();
48:
49: A a = new A();
50: a.id = 1;
51: a.value = "test";
52:
53: session.save("a", a);
54:
55: Resource resource = session.loadResource("a", "1");
56: assertNotNull(resource.getProperty("specialprop"));
57:
58: tr.commit();
59: session.close();
60: }
61: }
|