test/jdk/javax/imageio/GetReaderWriterInfo.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45351
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     1
/*
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     2
 * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     4
 *
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     8
 *
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    13
 * accompanied this code).
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    14
 *
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    18
 *
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    21
 * questions.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    22
 */
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    23
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    24
/*
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    25
 * @test
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    26
 * @bug 4703112
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    27
 * @summary Verifies that ImageIO.getReaderFileSuffixes() and similar methods
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    28
 *          return appropriate values
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    29
 */
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    30
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    31
import java.util.Iterator;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    32
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    33
import javax.imageio.ImageIO;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    34
import javax.imageio.ImageReader;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    35
import javax.imageio.ImageWriter;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    36
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    37
public class GetReaderWriterInfo {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    38
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    39
    private static void testGetReaderFormatNames() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    40
        String[] names = ImageIO.getReaderFormatNames();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    41
        for (String n : names) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    42
            Iterator<ImageReader> it = ImageIO.getImageReadersByFormatName(n);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    43
            if (!it.hasNext()) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    44
                throw new RuntimeException("getReaderFormatNames returned " +
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    45
                                           "an unknown name: " + n);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    46
            }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    47
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    48
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    49
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    50
    private static void testGetReaderMIMETypes() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    51
        String[] types = ImageIO.getReaderMIMETypes();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    52
        for (String t : types) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    53
            Iterator<ImageReader> it = ImageIO.getImageReadersByMIMEType(t);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    54
            if (!it.hasNext()) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    55
                throw new RuntimeException("getReaderMIMETypes returned " +
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    56
                                           "an unknown type: " + t);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    57
            }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    58
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    59
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    60
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    61
    private static void testGetReaderFileSuffixes() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    62
        String[] suffixes = ImageIO.getReaderFileSuffixes();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    63
        for (String s : suffixes) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    64
            Iterator<ImageReader> it = ImageIO.getImageReadersBySuffix(s);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    65
            if (!it.hasNext()) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    66
                throw new RuntimeException("getReaderFileSuffixes returned " +
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    67
                                           "an unknown suffix: " + s);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    68
            }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    69
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    70
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    71
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    72
    private static void testGetWriterFormatNames() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    73
        String[] names = ImageIO.getWriterFormatNames();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    74
        for (String n : names) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    75
            Iterator<ImageWriter> it = ImageIO.getImageWritersByFormatName(n);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    76
            if (!it.hasNext()) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    77
                throw new RuntimeException("getWriterFormatNames returned " +
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    78
                                           "an unknown name: " + n);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    79
            }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    80
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    81
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    82
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    83
    private static void testGetWriterMIMETypes() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    84
        String[] types = ImageIO.getWriterMIMETypes();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    85
        for (String t : types) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    86
            Iterator<ImageWriter> it = ImageIO.getImageWritersByMIMEType(t);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    87
            if (!it.hasNext()) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    88
                throw new RuntimeException("getWriterMIMETypes returned " +
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    89
                                           "an unknown type: " + t);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    90
            }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    91
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    92
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    93
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    94
    private static void testGetWriterFileSuffixes() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    95
        String[] suffixes = ImageIO.getWriterFileSuffixes();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    96
        for (String s : suffixes) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    97
            Iterator<ImageWriter> it = ImageIO.getImageWritersBySuffix(s);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    98
            if (!it.hasNext()) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    99
                throw new RuntimeException("getWriterFileSuffixes returned " +
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   100
                                           "an unknown suffix: " + s);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   101
            }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   102
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   103
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   104
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   105
    public static void main(String[] args) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   106
        testGetReaderFormatNames();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   107
        testGetReaderMIMETypes();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   108
        testGetReaderFileSuffixes();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   109
        testGetWriterFormatNames();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   110
        testGetWriterMIMETypes();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   111
        testGetWriterFileSuffixes();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   112
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   113
}