All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.katalon.kata.helper.ParameterHelper Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package com.katalon.kata.helper;

import org.slf4j.Logger;

import java.io.InputStream;
import java.util.Properties;
import java.util.Set;

public class ParameterHelper {

    private static final Logger log = LogHelper.getLogger();

    private static Properties properties;

    static {
        try {
            loadParameters(Constants.KATA_DEFAULT_PARAMETERS_FILE);
        } catch (Exception e) {
            ExceptionHelper.rethrow(e);
        }
    }

    private static void loadParameters(String propertiesFile) {
        try (InputStream inputStream = ParameterHelper.class.getClassLoader().getResourceAsStream(propertiesFile)) {
            properties = new Properties();
            properties.load(inputStream);
        } catch (Exception ex) {
            log.error("Fail to load properties", ex);
        }
        properties.putAll(System.getProperties());
        properties.putAll(System.getenv());
    }

    public static String getParameterDefaultValue(String key) {
        String value = properties.getProperty(key);
        return value;
    }

    public static Set getParameterNames() {
        return properties.stringPropertyNames();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy