test/jdk/javax/imageio/metadata/DOML3Node.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 13769 jdk/test/javax/imageio/metadata/DOML3Node.java@ba52da5186ad
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
13769
ba52da5186ad 7186799: Regression tests for ImageIO metadata fail on second run
bae
parents: 9196
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
13769
ba52da5186ad 7186799: Regression tests for ImageIO metadata fail on second run
bae
parents: 9196
diff changeset
     7
 * published by the Free Software Foundation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
9196
4ec60abb855b 6942504: test/javax/imageio/metadata/DOML3Node.java fails
prr
parents: 5506
diff changeset
    26
 * @bug 6559064 6942504
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * @summary Verify DOM L3 Node APIs behave as per Image I/O spec.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @run main DOML3Node
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.imageio.metadata.IIOMetadataNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import org.w3c.dom.Attr;
9196
4ec60abb855b 6942504: test/javax/imageio/metadata/DOML3Node.java fails
prr
parents: 5506
diff changeset
    35
import org.w3c.dom.Node;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import org.w3c.dom.DOMException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import org.w3c.dom.UserDataHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class DOML3Node {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    public static void main(String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        IIOMetadataNode node = new IIOMetadataNode("node");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
            node.setIdAttribute("name", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            node.setIdAttributeNS("namespaceURI", "localName", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            node.setIdAttributeNode((Attr)null, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            node.getSchemaTypeInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            node.setUserData("key", null, (UserDataHandler)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        try {
9196
4ec60abb855b 6942504: test/javax/imageio/metadata/DOML3Node.java fails
prr
parents: 5506
diff changeset
    76
            node.getUserData("key");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            node.getFeature("feature", "version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            node.isSameNode((Node)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            node.isEqualNode((Node)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            node.lookupNamespaceURI("prefix");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            node.isDefaultNamespace("namespaceURI");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            node.lookupPrefix("namespaceURI");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            node.getTextContent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            node.setTextContent("textContent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            node.compareDocumentPosition((Node)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            node.getBaseURI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            throw new RuntimeException("No expected DOM exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        } catch (DOMException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
}