1
votes

I will use user.properties to overwrite some properties in jmeter.properties.

Overwriting the properties summariser.out in jmeter.properties:

in jmeter.properties

summariser.out=true

in user.properties

summariser.out=false

In the apache doc is written:

Note: You can define additional JMeter properties in the file defined by the JMeter property user.properties which has the default value user.properties. The file will be automatically loaded if it is found in the current directory or if it is found in the JMeter bin directory. Similarly, system.properties is used to update system properties.

so, my user.properties is in /bin and I the property in jmeter.properties -> user.properties=user.properties.

I tried also to load manually like:

Properties props = new Properties();
InputStream is = getTempInputStream(userPropTempFilePath);
props.load(is);
is.close();

That all has no effect.

Some idea how to load user.properties in java and to check if the properties are loaded?

1

1 Answers

1
votes

Thats the solution:

String userProp = JMeterUtils.getPropDefault("user.properties", "");
    if (userProp.length() > 0) {
        FileInputStream fis = null;
        try {
            File file = JMeterUtils.findFile(userProp);
            if (file.canRead()) {
                log.info("Loading user properties from: "
                        + file.getCanonicalPath());
                fis = new FileInputStream(file);
                Properties tmp = new Properties();
                tmp.load(fis);
                jmeterProps.putAll(tmp);
                LoggingManager.setLoggingLevels(jmeterProps);//Do what would be done earlier
            }
        } catch (IOException e) {
            log.warn("Error loading user property file: " + userProp, e);
        } finally {
            try {
                if (fis != null) {
                    fis.close();
                }
            } catch (IOException ex) {
                log.warn("There was problem closing file stream", ex);
            }
        }
    }