jdk/test/java/util/prefs/CheckUserPrefLater.java
author khazra
Fri, 30 Nov 2012 12:00:07 -0800
changeset 14694 6d6d54dc0ae1
parent 14186 bfb891f72a79
child 21596 0e3a39f29dbc
permissions -rw-r--r--
7197662: (prefs) java/util/prefs/AddNodeChangeListener.java fails by timeout or by "couldn't get file lock" Summary: Set -Djava.util.prefs.userRoot to current working directory of user in the prefs tests Reviewed-by: alanb, chegar, weijun, dxu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14186
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     1
/*
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     4
 *
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    10
 *
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    15
 * accompanied this code).
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    16
 *
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    20
 *
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    23
 * questions.
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    24
 */
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    25
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    26
import java.util.prefs.Preferences;
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    27
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    28
/**
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    29
 * CheckUserPrefsStorage.sh uses this to check that preferences stored
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    30
 * by CheckUserPrefFirst.java can be retrieved
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    31
 * @author khazra
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    32
 */
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    33
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    34
public class CheckUserPrefLater {
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    35
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    37
        Preferences prefs = Preferences.userNodeForPackage(CheckUserPrefFirst.class);
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    38
        String result = prefs.get("Check", null);
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    39
        if ((result == null) || !(result.equals("Success")))
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    40
            throw new RuntimeException("User pref not stored!");
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    41
        prefs.remove("Check");
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    42
        prefs.flush();
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    43
    }
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    44
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    45
}
bfb891f72a79 7198073: (prefs) user prefs not saved [macosx]
khazra
parents:
diff changeset
    46