01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2;
21:
22: import junit.framework.TestCase;
23:
24: import java.io.File;
25:
26: /**
27: * Abstract base class for test cases.
28: */
29: public abstract class AbstractTestCase extends TestCase {
30: protected String testDir = "test" + File.separator;
31: protected String sampleDir = "samples" + File.separator;
32: protected String outDir = "target" + File.separator + "generated"
33: + File.separator + "samples" + File.separator;
34: protected String tempDir = "target" + File.separator + "generated"
35: + File.separator + "temp";
36: protected String testResourceDir = "test-resources";
37:
38: /**
39: * Basedir for all file I/O. Important when running tests from
40: * the reactor. Note that anyone can use this statically.
41: */
42: public static String basedir;
43:
44: static {
45: basedir = System.getProperty("basedir");
46: if (basedir == null) {
47: basedir = new File(".").getAbsolutePath();
48: }
49: }
50:
51: /**
52: * @param testName
53: */
54: public AbstractTestCase(String testName) {
55: super (testName);
56: testDir = new File(basedir, testDir).getAbsolutePath();
57: sampleDir = new File(basedir, sampleDir).getAbsolutePath();
58: outDir = new File(basedir, outDir).getAbsolutePath();
59: tempDir = new File(basedir, tempDir).getAbsolutePath();
60: }
61:
62: public File getTestResourceFile(String relativePath) {
63: return new File(testResourceDir, relativePath);
64: }
65: }
|