01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.test;
18:
19: import java.io.IOException;
20: import java.util.ArrayList;
21: import java.util.List;
22: import java.util.Map;
23: import java.util.Properties;
24:
25: import org.kuali.rice.config.BaseConfig;
26: import org.springframework.util.ResourceUtils;
27:
28: import edu.iu.uis.eden.exception.WorkflowRuntimeException;
29:
30: /**
31: * BaseConfig implementation that is the entry point for workflow configuration
32: * running under unit tests.
33: * A 'test.platform' property is defined in the base properties. This property
34: * is initialized from TestUtilities.getTestPlatform() which obtains the property
35: * from the Ant build.properties as a convenience.
36: */
37: public class TestConfigurer extends BaseConfig {
38:
39: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
40: .getLogger(TestConfigurer.class);
41:
42: private static final String TEST_PLATFORM = "test.platform";
43:
44: private static List<String> fileLocations = new ArrayList<String>();
45: private String testPlatform;
46:
47: public TestConfigurer() throws IOException {
48: super (fileLocations);
49: this .testPlatform = TestUtilities.getTestPlatform();
50: System.setProperty(TEST_PLATFORM, testPlatform);
51: // this is ghetto but the constructor aspect of the BaseConfig is making it difficult for me to do what I want to here
52: fileLocations.clear();
53: String configFile = "classpath:META-INF/test-" + testPlatform
54: + "-workflow.xml";
55: fileLocations.add(configFile);
56: LOG
57: .info("Intitializing TestConfigurer with configuration file: "
58: + configFile);
59: }
60:
61: public Properties getBaseProperties() {
62: Properties baseProps = new Properties();
63: try {
64: //baseProps.put("workflow.base", ResourceUtils.getFile("classpath:").getAbsolutePath());
65: baseProps.put("workflow.base", ResourceUtils.getFile(
66: "classpath:").getAbsolutePath()
67: + "/../../..");
68: baseProps.put(TEST_PLATFORM, testPlatform);
69: //baseProps.put("workflowBase", ".");
70: } catch (Exception e) {
71: throw new WorkflowRuntimeException(e);
72: }
73: return baseProps;
74: }
75:
76: public Map getBaseObjects() {
77: return null;
78: }
79:
80: }
|