1/*
2 * Copyright 2016 Federico Tomassetti
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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
17package com.github.javaparser.symbolsolver;
18
19import java.io.File;
20
21public abstract class AbstractTest {
22
23    protected static File adaptPath(File path) {
24        if (path.exists()) {
25            return path;
26        } else {
27            File underJavaParserCore = new File("javaparser-symbol-solver-testing/" + path.getPath());
28            if (underJavaParserCore.exists()) {
29                return underJavaParserCore;
30            } else {
31                throw new IllegalArgumentException("I cannot adapt the path " + path.getAbsolutePath());
32            }
33        }
34    }
35
36    protected static String adaptPath(String path) {
37        return adaptPath(new File(path)).getPath();
38    }
39
40    protected boolean isJava9() {
41        return System.getProperty("java.version").startsWith("9.");
42    }
43
44    protected boolean isJava8() {
45        return System.getProperty("java.version").startsWith("1.8.");
46    }
47}
48