1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * https://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.commons.exec;
21
22 import java.io.File;
23
24 /**
25 * Abstracts tests.
26 */
27 public abstract class AbstractExecTest {
28
29 /**
30 * Default test timeout in milliseconds.
31 */
32 public static final int TEST_TIMEOUT = 15_000;
33
34 /**
35 * Watchdog timeout in milliseconds.
36 */
37 public static final int WATCHDOG_TIMEOUT = 3_000;
38
39 private final File testDir = new File("src/test/scripts");
40
41 /**
42 * Resolve the OS-specific test file to execute.
43 */
44 protected File resolveTestScript(final String baseName) {
45 final File result = TestUtil.resolveScriptFileForOS(testDir + "/" + baseName);
46 if (!result.exists()) {
47 throw new IllegalArgumentException("Unable to find the following file: " + result.getAbsolutePath());
48 }
49 return result;
50 }
51
52 /**
53 * Resolve the OS-specific test file to execute.
54 */
55 protected File resolveTestScript(final String directoryName, final String baseName) {
56 final File result = TestUtil.resolveScriptFileForOS(testDir + "/" + directoryName + "/" + baseName);
57 if (!result.exists()) {
58 throw new IllegalArgumentException("Unable to find the following file: " + result.getAbsolutePath());
59 }
60 return result;
61 }
62 }