01: /*
02: * Copyright 2005-2007 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: package net.sf.dozer.functional_tests;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import junit.framework.TestCase;
22: import net.sf.dozer.util.mapping.DozerBeanMapper;
23: import net.sf.dozer.util.mapping.MapperIF;
24: import net.sf.dozer.util.mapping.util.MapperConstants;
25: import net.sf.dozer.util.mapping.util.TestDataFactory;
26:
27: /**
28: * @author tierney.matt
29: * @author garsombke.franz
30: */
31: public abstract class AbstractMapperTest extends TestCase {
32: protected MapperIF mapper;
33: protected TestDataFactory testDataFactory = new TestDataFactory(
34: getDataObjectInstantiator());
35:
36: protected abstract DataObjectInstantiator getDataObjectInstantiator();
37:
38: protected void setUp() throws Exception {
39: super .setUp();
40: System.setProperty("log4j.debug", "true");
41: System.setProperty(MapperConstants.DEBUG_SYS_PROP, "true");
42: mapper = new DozerBeanMapper();
43: }
44:
45: protected MapperIF getMapper(String[] mappingFiles) {
46: List list = new ArrayList();
47: if (mappingFiles != null) {
48: for (int i = 0; i < mappingFiles.length; i++) {
49: list.add(mappingFiles[i]);
50: }
51: }
52: MapperIF result = new DozerBeanMapper();
53: ((DozerBeanMapper) result).setMappingFiles(list);
54: return result;
55: }
56:
57: protected Object newInstance(Class classToInstantiate) {
58: return getDataObjectInstantiator().newInstance(
59: classToInstantiate);
60: }
61:
62: }
|