test/java/util/prefs/RemoveReadOnlyNode.java

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 /* @test
  26    @bug 6178148
  27    @summary check if wrong exception gets thrown if one of the child
  28             nodes is readonly on underlying filesystem when node is
  29             being removed.

  30  */
  31 
  32 import java.io.*;
  33 import java.util.prefs.*;
  34 
  35 public class RemoveReadOnlyNode {
  36     public static void main(String[] args) throws Exception {
  37         String osName = System.getProperty("os.name");
  38         if (osName.startsWith("Windows"))
  39             return;
  40         Preferences root = Preferences.userRoot();
  41         Preferences node1 = root.node("node1");
  42         Preferences node1A = node1.node("node1A");
  43         Preferences node1B = node1.node("node1B");
  44         node1B.put("mykey", "myvalue");
  45         node1.flush();
  46         String node1BDirName = System.getProperty("user.home")
  47             + "/.java/.userPrefs"
  48             + "/node1/node1B";
  49         File node1BDir = new File(node1BDirName);


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 /* @test
  26  * @bug 6178148 7197662
  27  * @summary check if wrong exception gets thrown if one of the child
  28  *          nodes is readonly on underlying filesystem when node is
  29  *          being removed.
  30  * @run main/othervm -Djava.util.prefs.userRoot=. RemoveReadOnlyNode
  31  */
  32 
  33 import java.io.*;
  34 import java.util.prefs.*;
  35 
  36 public class RemoveReadOnlyNode {
  37     public static void main(String[] args) throws Exception {
  38         String osName = System.getProperty("os.name");
  39         if (osName.startsWith("Windows"))
  40             return;
  41         Preferences root = Preferences.userRoot();
  42         Preferences node1 = root.node("node1");
  43         Preferences node1A = node1.node("node1A");
  44         Preferences node1B = node1.node("node1B");
  45         node1B.put("mykey", "myvalue");
  46         node1.flush();
  47         String node1BDirName = System.getProperty("user.home")
  48             + "/.java/.userPrefs"
  49             + "/node1/node1B";
  50         File node1BDir = new File(node1BDirName);