Java Path File Name nio getTestDataPath(Class clazz, String name)

Here you can find the source of getTestDataPath(Class clazz, String name)

Description

get Test Data Path

License

Apache License

Declaration

public static Path getTestDataPath(Class<?> clazz, String name) 

Method Source Code

//package com.java2s;
/**//from   ww w .  j a  va2 s . c o  m
 * Copyright 2017-2018 Gregory Moyer and contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    private static final String RESOURCES_PATH = "src/test/resources/";

    public static Path getTestDataPath(Class<?> clazz, String name) {
        String packageName = clazz.getPackage().getName();

        List<String> paths = new ArrayList<>();
        paths.addAll(Arrays.asList(packageName.split("\\.")));
        paths.add(name);

        return Paths.get(RESOURCES_PATH, paths.toArray(new String[paths.size()]));
    }
}

Related

  1. getRoot(final String pathName)
  2. getRootPathFromDirectory(String resourceName, URL resource)
  3. getSimpleName(String path)
  4. getSolrCorePath(Path solrHome, String indexName)
  5. getSourceRoot(Path filePath, String pkgName)
  6. getUniqueFileInDirectory(Path dir, String name)
  7. inheritGwtModule(Path path, String inheritableModuleLogicalName)
  8. initializePath(String... envVarNames)
  9. isExecutableOnPath(String execName)