
com.atlassian.clover.CloverProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clover-runtime Show documentation
Show all versions of clover-runtime Show documentation
Clover's runtime library - required by code instrumented by Clover.
Clover is an award-winning code coverage and testing tool for Java and Groovy.
It integrates easily with Maven, Ant, Grails, Eclipse and IntelliJ IDEA
as well as with continuous integration servers such as Bamboo, Jenkins or Hudson.
The newest version!
package com.atlassian.clover;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class CloverProperties {
private final Map instrTimeProperties;
public CloverProperties(String... instrTimeProperties) {
this.instrTimeProperties = toMap(instrTimeProperties);
}
public String getProperty(final String name) {
return getSysProperty(name, instrTimeProperties.get(name));
}
public boolean getBooleanProperty(String name, boolean defaultValue) {
return Boolean.parseBoolean(getSysProperty(name, Boolean.toString(defaultValue)));
}
public static String getSysProperty(final String name, final String defaultValue) {
return AccessController.doPrivileged(new PrivilegedAction() {
@Override
public String run() {
return System.getProperty(name, defaultValue);
}
});
}
public static boolean getBooleanSysProperty(String name, boolean defaultValue) {
return Boolean.parseBoolean(getSysProperty(name, Boolean.toString(defaultValue)));
}
private static Map toMap(String[] nvpProperties) {
Map properties = new HashMap<>();
if (nvpProperties != null) {
if (nvpProperties.length % 2 != 0) {
throw new IllegalArgumentException("The number of Clover properties strings supplied should be a multiple of 2");
}
for(int i = 0; i < nvpProperties.length; i += 2) {
properties.put(nvpProperties[i], nvpProperties[i + 1]);
}
}
return properties;
}
public static CloverProperties newEmptyProperties() {
return new CloverProperties();
}
@Override
public String toString() {
return "[InstrumentationProperties=" + instrTimeProperties + ", cloverSystemProperties=" + getCloverSystemProperties() + "]";
}
private String getCloverSystemProperties() {
Properties systemProperties = AccessController.doPrivileged(new PrivilegedAction() {
@Override
public Properties run() {
return System.getProperties();
}
});
Map cloverSystemProperties = new HashMap<>();
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy