src/main/java/org/apache/sling/testing/clients/util/TimeoutsProvider.java [31:84]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class TimeoutsProvider {
    private static final Logger log = LoggerFactory.getLogger(TimeoutsProvider.class);
    public static final String PROP_TIMEOUT_MULTIPLIER = "sling.testing.timeout.multiplier";
    private static float timeoutFactor = -1;
    private static TimeoutsProvider INSTANCE;
    
    private TimeoutsProvider() {
        if(timeoutFactor < 0) {
            timeoutFactor = 1;
            final String str = System.getProperty(PROP_TIMEOUT_MULTIPLIER);
            if(str != null) {
                try {
                    timeoutFactor = Float.valueOf(str.trim());
                    log.info("Timeout factor set to {} from system property {}", 
                            timeoutFactor, PROP_TIMEOUT_MULTIPLIER);
                } catch(NumberFormatException nfe) {
                    throw new IllegalStateException("Invalid timeout factor: " + PROP_TIMEOUT_MULTIPLIER + "=" + str);
                }
            }
        }
    }
    
    public static TimeoutsProvider getInstance() {
        if(INSTANCE == null) {
            synchronized (TimeoutsProvider.class) {
                INSTANCE = new TimeoutsProvider();
            }
        }
        return INSTANCE;
    }
    
    public long getTimeout(long nomimalValue) {
        final long result = (long)(nomimalValue * timeoutFactor);
        return result;
    }
    
    public int getTimeout(int nomimalValue) {
        final int result = (int)(nomimalValue * timeoutFactor);
        return result;
    }

    /**
     * Get timeout from a system property, with default value
     * @param systemPropertyName Name of the system property that holds the timeout multiplier
     * @param defaultNominalValue The default timeout multiplier
     * @return the total timeout value
     */
    public int getTimeout(String systemPropertyName, int defaultNominalValue) {
        int result = defaultNominalValue;
        final String str = System.getProperty(systemPropertyName);
        if(str != null) {
            result = Integer.parseInt(str);
        }
        return getTimeout(result);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/main/java/org/apache/sling/testing/timeouts/TimeoutsProvider.java [27:94]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class TimeoutsProvider {
    private static final Logger log = LoggerFactory.getLogger(TimeoutsProvider.class);
    public static final String PROP_TIMEOUT_MULTIPLIER = "sling.testing.timeout.multiplier";
    private static float timeoutFactor = -1;
    private static TimeoutsProvider INSTANCE;
    
    private TimeoutsProvider() {
        if(timeoutFactor < 0) {
            timeoutFactor = 1;
            final String str = System.getProperty(PROP_TIMEOUT_MULTIPLIER);
            if(str != null) {
                try {
                    timeoutFactor = Float.valueOf(str.trim());
                    log.info("Timeout factor set to {} from system property {}", 
                            timeoutFactor, PROP_TIMEOUT_MULTIPLIER);
                } catch(NumberFormatException nfe) {
                    throw new IllegalStateException("Invalid timeout factor: " + PROP_TIMEOUT_MULTIPLIER + "=" + str);
                }
            }
        }
    }

    /**
     *
     * @return the instance of the singleton
     */
    public static TimeoutsProvider getInstance() {
        if(INSTANCE == null) {
            synchronized (TimeoutsProvider.class) {
                INSTANCE = new TimeoutsProvider();
            }
        }
        return INSTANCE;
    }

    /**
     *
     * @param nomimalValue base number to be multiplied internally with the factor
     * @return the new timeout
     */
    public long getTimeout(long nomimalValue) {
        final long result = (long)(nomimalValue * timeoutFactor);
        return result;
    }

    /**
     *
     * @param nomimalValue base number to be multiplied internally with the factor
     * @return the new timeout
     */
    public int getTimeout(int nomimalValue) {
        final int result = (int)(nomimalValue * timeoutFactor);
        return result;
    }
    
    /**
     * Get timeout from a system property, with default value
     * @param systemPropertyName the name of the system prop from which to get the timeout
     * @param defaultNominalValue default value in case the property does not exist
     * @return the timeout
     */
    public int getTimeout(String systemPropertyName, int defaultNominalValue) {
        int result = defaultNominalValue;
        final String str = System.getProperty(systemPropertyName);
        if(str != null) {
            result = Integer.parseInt(str);
        }
        return getTimeout(result);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



