8209768: Refactor java/util/prefs/CheckUserPrefsStorage.sh to plain java test
authoramlu
Thu, 25 Oct 2018 11:05:24 +0800
changeset 52281 b646c9ea2394
parent 52280 09be9fd37b91
child 52282 003c062e16ea
8209768: Refactor java/util/prefs/CheckUserPrefsStorage.sh to plain java test Reviewed-by: bchristi, weijun
test/jdk/java/util/prefs/CheckUserPrefFirst.java
test/jdk/java/util/prefs/CheckUserPrefLater.java
test/jdk/java/util/prefs/CheckUserPrefsStorage.java
test/jdk/java/util/prefs/CheckUserPrefsStorage.sh
--- a/test/jdk/java/util/prefs/CheckUserPrefFirst.java	Thu Oct 25 11:00:40 2018 +0800
+++ b/test/jdk/java/util/prefs/CheckUserPrefFirst.java	Thu Oct 25 11:05:24 2018 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,9 +24,7 @@
 import java.util.prefs.Preferences;
 
 /**
- *
- * @author khazra
- * First class called by CheckUserPrefsStorage.sh to create and
+ * First class called by CheckUserPrefsStorage.java to create and
  * store a user preference
  */
 
--- a/test/jdk/java/util/prefs/CheckUserPrefLater.java	Thu Oct 25 11:00:40 2018 +0800
+++ b/test/jdk/java/util/prefs/CheckUserPrefLater.java	Thu Oct 25 11:05:24 2018 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,9 +24,8 @@
 import java.util.prefs.Preferences;
 
 /**
- * CheckUserPrefsStorage.sh uses this to check that preferences stored
+ * CheckUserPrefsStorage.java uses this to check that preferences stored
  * by CheckUserPrefFirst.java can be retrieved
- * @author khazra
  */
 
 public class CheckUserPrefLater {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/prefs/CheckUserPrefsStorage.java	Thu Oct 25 11:05:24 2018 +0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7198073 7197662
+ * @summary Tests that user preferences are stored in the permanent storage
+ * @library /test/lib
+ * @build jdk.test.lib.process.* CheckUserPrefFirst CheckUserPrefLater
+ * @run main CheckUserPrefsStorage
+ */
+
+import jdk.test.lib.process.ProcessTools;
+
+public class CheckUserPrefsStorage {
+
+    public static void main(String[] args) throws Throwable {
+        // First to create and store a user preference
+        run("CheckUserPrefFirst");
+        // Then check that preferences stored by CheckUserPrefFirst can be retrieved
+        run("CheckUserPrefLater");
+    }
+
+    public static void run(String testName) throws Exception {
+        ProcessTools.executeTestJvm("-Djava.util.prefs.userRoot=.", testName)
+                    .outputTo(System.out)
+                    .errorTo(System.out)
+                    .shouldHaveExitValue(0);
+    }
+}
--- a/test/jdk/java/util/prefs/CheckUserPrefsStorage.sh	Thu Oct 25 11:00:40 2018 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-#
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 7198073 7197662
-# @build CheckUserPrefFirst CheckUserPrefLater
-# @run shell CheckUserPrefsStorage.sh
-# @summary Tests that user preferences are stored in the
-#          permanent storage
-#
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-# run CheckUserPrefFirst - creates and stores a user pref
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} -Djava.util.prefs.userRoot=. CheckUserPrefFirst
-result=$?
-if [ "$result" -ne "0" ]; then
-    exit 1
-fi
-
-# run CheckUserPrefLater - Looks for the stored pref
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} -Djava.util.prefs.userRoot=. CheckUserPrefLater
-result=$?
-if [ "$result" -ne "0" ]; then
-    exit 1
-fi
-
-# no failures, exit.
-exit 0
-