test/testlibrary/com/oracle/java/testlibrary/Utils.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Cdiff test/testlibrary/com/oracle/java/testlibrary/Utils.java

test/testlibrary/com/oracle/java/testlibrary/Utils.java

Print this page
rev 7461 : 8066440: Various changes in testlibrary for JDK-8059613
Reviewed-by: iignatyev
Contributed-by: dmitrij.pochepko@oracle.com

*** 35,44 **** --- 35,45 ---- import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Random; + import java.util.function.BooleanSupplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import sun.misc.Unsafe; /**
*** 86,95 **** --- 87,103 ---- static { String toFactor = System.getProperty("test.timeout.factor", "1.0"); TIMEOUT_FACTOR = Double.parseDouble(toFactor); } + /** + * Returns the value of 'test.iterations.count' system property + * converted to {@code int}. + */ + public static final int ITERATIONS_COUNT = + Integer.getInteger("com.oracle.java.testlibrary.iterations", 1); + private Utils() { // Private constructor to prevent class instantiation } /**
*** 365,370 **** --- 373,405 ---- } } } return RANDOM_GENERATOR; } + + /** + * Wait for condition to be true + * + * @param condition, a condition to wait for, using default sleep time 100 + */ + public static final void waitForCondition(BooleanSupplier condition) { + waitForCondition(condition, 100); + } + + /** + * Wait until timeout for condition to be true + * + * @param condition, a condition to wait for + * @param sleepTime a time to sleep value in milliseconds + */ + public static final void waitForCondition(BooleanSupplier condition, + long sleepTime) { + while (!condition.getAsBoolean()) { + try { + Thread.sleep(sleepTime); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new Error(e); + } + } + } }
test/testlibrary/com/oracle/java/testlibrary/Utils.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File