/** * Find the resource file by looking in to the following locations: * <ul> * <li>working dir (assumed to be "") * <li>src/main/resources * <li>src/main/external-resources * </ul> * If file or directory can not be found in the given locations, exception will be thrown. * * @param resource * File or directory to locate. * @return existing {@link File} * @throws IOException * If resource can not be found. */ public static File getResourceFile(String resource) throws IOException { return getResourceFile(resource, new File("")); }
/** * Initializes {@link #configDirFile}. */ protected void init() { try { configDirFile = ResourcesPathResolver.getResourceFile(CONFIG_DIR); } catch (IOException exception) { throw new BeanInitializationException("Property manager can not locate configuration directory.", exception); } }
/** * Initializes {@link #configDirFile}. */ @PostConstruct protected void init() { try { templatesDir = ResourcesPathResolver.getResourceFile(DEFAULT_TEMPLATE_FOLDER); } catch (IOException exception) { throw new BeanInitializationException("Template manager can not locate templates directory.", exception); } } }
/** * Initializes {@link #configDirFile}. */ @PostConstruct protected void init() { try { ciDirFile = ResourcesPathResolver.getResourceFile(DEFAULT_CI_FOLDER); } catch (IOException exception) { throw new BeanInitializationException("Property manager can not locate configuration directory.", exception); } }
Path logPath = ResourcesPathResolver.getResourceFile(DEFAULT_LOG_FILE_NAME).toPath().toAbsolutePath(); if (Files.exists(logPath)) { is = Files.newInputStream(logPath, StandardOpenOption.READ);
Path logPath = ResourcesPathResolver.getResourceFile(DEFAULT_LOG_FILE_NAME, Platform.getLocation().toFile()).toPath().toAbsolutePath(); if (Files.exists(logPath)) { is = Files.newInputStream(logPath, StandardOpenOption.READ);
/** * Init logging. */ @BeforeSuite public void initLogging() throws IOException { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); context.reset(); Path logPath = ResourcesPathResolver.getResourceFile(CMR.DEFAULT_LOG_FILE_NAME).toPath().toAbsolutePath(); try (InputStream is = Files.newInputStream(logPath, StandardOpenOption.READ)) { configurator.doConfigure(is); } catch (JoranException je) { // NOPMD StatusPrinter will handle this } StatusPrinter.printInCaseOfErrorsOrWarnings(context); }
/** * Init logging. */ @BeforeSuite public void initLogging() throws IOException { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); context.reset(); Path logPath = ResourcesPathResolver.getResourceFile(CMR.DEFAULT_LOG_FILE_NAME).toPath().toAbsolutePath(); try (InputStream is = Files.newInputStream(logPath, StandardOpenOption.READ)) { configurator.doConfigure(is); } catch (JoranException je) { // NOPMD StatusPrinter will handle this } StatusPrinter.printInCaseOfErrorsOrWarnings(context); }