author | khazra |
Fri, 30 Nov 2012 12:00:07 -0800 | |
changeset 14694 | 6d6d54dc0ae1 |
parent 5506 | 202f599c92aa |
child 14786 | a9f61e0cbe61 |
permissions | -rw-r--r-- |
3620
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
1 |
#!/bin/sh |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
2 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
3 |
# |
5506 | 4 |
# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
3620
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
5 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
6 |
# |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
7 |
# This code is free software; you can redistribute it and/or modify it |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
8 |
# under the terms of the GNU General Public License version 2 only, as |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
9 |
# published by the Free Software Foundation. |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
10 |
# |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
15 |
# accompanied this code). |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
16 |
# |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
17 |
# You should have received a copy of the GNU General Public License version |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
20 |
# |
5506 | 21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
3620
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
24 |
# |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
25 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
26 |
# @test |
14694
6d6d54dc0ae1
7197662: (prefs) java/util/prefs/AddNodeChangeListener.java fails by timeout or by "couldn't get file lock"
khazra
parents:
5506
diff
changeset
|
27 |
# @bug 4991526 6514993 7197662 |
3620
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
28 |
# @summary Unit test for Preferences jar providers |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
29 |
# |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
30 |
# @build PrefsSpi |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
31 |
# @run shell PrefsSpi.sh |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
32 |
# @author Martin Buchholz |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
33 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
34 |
# Command-line usage: sh PrefsSpi.sh /path/to/build |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
35 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
36 |
if [ -z "$TESTJAVA" ]; then |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
37 |
if [ $# -lt 1 ]; then exit 1; fi |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
38 |
TESTJAVA="$1"; shift |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
39 |
TESTSRC="`pwd`" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
40 |
TESTCLASSES="`pwd`" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
41 |
fi |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
42 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
43 |
java="$TESTJAVA/bin/java" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
44 |
javac="$TESTJAVA/bin/javac" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
45 |
jar="$TESTJAVA/bin/jar" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
46 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
47 |
Die() { printf "%s\n" "$*"; exit 1; } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
48 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
49 |
Sys() { |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
50 |
printf "%s\n" "$*"; "$@"; rc="$?"; |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
51 |
test "$rc" -eq 0 || Die "Command \"$*\" failed with exitValue $rc"; |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
52 |
} |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
53 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
54 |
cat > StubPreferences.java <<'EOF' |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
55 |
import java.util.prefs.*; |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
56 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
57 |
public class StubPreferences extends AbstractPreferences { |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
58 |
public StubPreferences() { super(null, ""); } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
59 |
public String getSpi(String x) { return null; } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
60 |
public void putSpi(String x, String y) { } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
61 |
public void removeSpi(String x) { } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
62 |
public AbstractPreferences childSpi(String x) { return null; } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
63 |
public void removeNodeSpi() { } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
64 |
public String[] keysSpi() { return null; } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
65 |
public String[] childrenNamesSpi() { return null; } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
66 |
public void syncSpi() { } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
67 |
public void flushSpi() { } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
68 |
} |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
69 |
EOF |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
70 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
71 |
cat > StubPreferencesFactory.java <<'EOF' |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
72 |
import java.util.prefs.*; |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
73 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
74 |
public class StubPreferencesFactory implements PreferencesFactory { |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
75 |
public Preferences userRoot() { return new StubPreferences(); } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
76 |
public Preferences systemRoot() { return new StubPreferences(); } |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
77 |
} |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
78 |
EOF |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
79 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
80 |
Sys rm -rf jarDir extDir |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
81 |
Sys mkdir -p jarDir/META-INF/services extDir |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
82 |
echo "StubPreferencesFactory" \ |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
83 |
> "jarDir/META-INF/services/java.util.prefs.PreferencesFactory" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
84 |
Sys "$javac" -d jarDir StubPreferencesFactory.java StubPreferences.java |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
85 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
86 |
(cd jarDir && "$jar" "cf" "../extDir/PrefsSpi.jar" ".") |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
87 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
88 |
case "`uname`" in Windows*|CYGWIN* ) CPS=';';; *) CPS=':';; esac |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
89 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
90 |
Sys "$java" "-cp" "$TESTCLASSES${CPS}extDir/PrefsSpi.jar" \ |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
91 |
-Djava.util.prefs.PreferencesFactory=StubPreferencesFactory \ |
14694
6d6d54dc0ae1
7197662: (prefs) java/util/prefs/AddNodeChangeListener.java fails by timeout or by "couldn't get file lock"
khazra
parents:
5506
diff
changeset
|
92 |
-Djava.util.prefs.userRoot=. \ |
3620
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
93 |
PrefsSpi "StubPreferences" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
94 |
Sys "$java" "-cp" "$TESTCLASSES" \ |
14694
6d6d54dc0ae1
7197662: (prefs) java/util/prefs/AddNodeChangeListener.java fails by timeout or by "couldn't get file lock"
khazra
parents:
5506
diff
changeset
|
95 |
-Djava.util.prefs.userRoot=. \ |
3620
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
96 |
PrefsSpi "java.util.prefs.*" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
97 |
Sys "$java" "-cp" "$TESTCLASSES${CPS}extDir/PrefsSpi.jar" \ |
14694
6d6d54dc0ae1
7197662: (prefs) java/util/prefs/AddNodeChangeListener.java fails by timeout or by "couldn't get file lock"
khazra
parents:
5506
diff
changeset
|
98 |
-Djava.util.prefs.userRoot=. \ |
3620
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
99 |
PrefsSpi "StubPreferences" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
100 |
Sys "$java" "-cp" "$TESTCLASSES" "-Djava.ext.dirs=extDir" \ |
14694
6d6d54dc0ae1
7197662: (prefs) java/util/prefs/AddNodeChangeListener.java fails by timeout or by "couldn't get file lock"
khazra
parents:
5506
diff
changeset
|
101 |
-Djava.util.prefs.userRoot=. \ |
3620
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
102 |
PrefsSpi "StubPreferences" |
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
103 |
|
23aad720fe49
6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff
changeset
|
104 |
rm -rf jarDir extDir |