jdk/test/java/util/prefs/CommentsInXml.java
author sherman
Thu, 13 Aug 2009 15:01:18 -0700
changeset 3620 23aad720fe49
child 5506 202f599c92aa
permissions -rw-r--r--
6676423: (prefs) Opensource unit/regression tests for java.util.prefs Summary: Moved the existing test cases for prefs to open area Reviewed-by: martin, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3620
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
     1
/*
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
     3
 * 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
     4
 *
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
     5
 * 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
     6
 * 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
     7
 * published by the Free Software Foundation.
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
     8
 *
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
     9
 * 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
    10
 * 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
    11
 * 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
    12
 * 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
    13
 * accompanied this code).
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    14
 *
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    15
 * 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
    16
 * 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
    17
 * 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
    18
 *
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    21
 * have any questions.
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    22
 */
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    23
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
 * @test
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    26
 * @bug 4619564
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    27
 * @summary XMl Comments in Preferences File lead to ClassCastException
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    28
 * @author kladko
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
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    31
import java.io.*;
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    32
import java.util.prefs.*;
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
public class CommentsInXml {
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
    public static void main(String[] argv) throws Exception {
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    37
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    38
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    39
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    40
        bos.write(new String(
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    41
            "<!DOCTYPE preferences SYSTEM                          " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    42
            "\"http://java.sun.com/dtd/preferences.dtd\">          " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    43
            "<preferences EXTERNAL_XML_VERSION=\"1.0\">            " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    44
            "  <root type=\"user\">                                " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    45
            "    <map>                                             " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    46
            "    </map>                                            " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    47
            "    <node name=\"hlrAgent\"> <!-- HLR Agent -->       " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    48
            "      <map>                                           " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    49
            "        <entry key=\"agentName\" value=\"HLRAgent\" />" +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    50
            "      </map>                                          " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    51
            "    </node>                                           " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    52
            "  </root>                                             " +
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    53
            "</preferences>                                        "
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    54
        ).getBytes());
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    55
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    56
        Preferences ur = Preferences.userRoot();
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    57
        ur.importPreferences(new ByteArrayInputStream(bos.toByteArray()));
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    58
        ur.node("hlrAgent").removeNode(); // clean
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    59
    }
23aad720fe49 6676423: (prefs) Opensource unit/regression tests for java.util.prefs
sherman
parents:
diff changeset
    60
}