In the suite file example, there was a parameter set for the environment property file. In order to keep the parallel sessions from interfering with each other, different sets of servers and/or users must be used, and the thread that holds the properties during the test must also run in parallel. The following method extends the Java Properties class to accomplish that:
/**
* ParallelProps method - extends Properties class to isolate
each thread instance
*
*/
public class ParallelProps extends Properties {
public static final long serialVerionUID = 12345678L;
private final ThreadLocal<Properties> localProperties =
new ThreadLocal<Properties>() {
@Override
protected Properties initialValue() {
return new Properties();
}
};
public ParallelProps(Properties properties) {
super(properties);
}
@Override
public String getProperty(String key) {
String localValue = localProperties.get().getProperty(key);
return localValue == null ? super.getProperty(key) :
localValue;
}
@Override
public Object setProperty(String key, String value) {
return localProperties.get().setProperty(key, value);
}
}
The JavaDoc for the ThreadLocal class is located at https://docs.oracle.com/javase/7/docs/api/java/lang/ThreadLocal.html.