changeset 9442:ef9f4aa0ec4a

8141353: Testlibrary: add various changes into testlibrary Utils Summary: added TEST_JDK, TEST_CLASSES properties and getMandatoryProperty method Reviewed-by: iignatyev
author dpochepk
date Fri, 06 Nov 2015 14:51:15 +0300
parents 5bccb21c1b4e
children a7b9e9e46fd4
files test/testlibrary/jdk/test/lib/Utils.java
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/testlibrary/jdk/test/lib/Utils.java	Fri Nov 06 10:06:51 2015 -1000
+++ b/test/testlibrary/jdk/test/lib/Utils.java	Fri Nov 06 14:51:15 2015 +0300
@@ -44,6 +44,7 @@
 import java.util.Map;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Objects;
 import java.util.Random;
 import java.util.function.BooleanSupplier;
 import java.util.concurrent.TimeUnit;
@@ -82,6 +83,16 @@
      */
     public static final String TEST_SRC = System.getProperty("test.src", ".").trim();
 
+    /*
+     * Returns the value of 'test.jdk' system property
+     */
+    public static final String TEST_JDK = System.getProperty("test.jdk");
+
+    /**
+     * Returns the value of 'test.classes' system property
+     */
+    public static final String TEST_CLASSES = System.getProperty("test.classes", ".");
+
     private static Unsafe unsafe = null;
 
     /**
@@ -616,5 +627,18 @@
         NULL_VALUES.put(float.class, 0.0f);
         NULL_VALUES.put(double.class, 0.0d);
     }
+
+    /**
+     * Returns mandatory property value
+     * @param propName is a name of property to request
+     * @return a String with requested property value
+     */
+    public static String getMandatoryProperty(String propName) {
+        Objects.requireNonNull(propName, "Requested null property");
+        String prop = System.getProperty(propName);
+        Objects.requireNonNull(prop,
+                String.format("A mandatory property '%s' isn't set", propName));
+        return prop;
+    }
 }