Path: blob/master/test/jdk/javax/imageio/GetReaderWriterInfo.java
41144 views
/*1* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 470311226* @summary Verifies that ImageIO.getReaderFileSuffixes() and similar methods27* return appropriate values28*/2930import java.util.Iterator;3132import javax.imageio.ImageIO;33import javax.imageio.ImageReader;34import javax.imageio.ImageWriter;3536public class GetReaderWriterInfo {3738private static void testGetReaderFormatNames() {39String[] names = ImageIO.getReaderFormatNames();40for (String n : names) {41Iterator<ImageReader> it = ImageIO.getImageReadersByFormatName(n);42if (!it.hasNext()) {43throw new RuntimeException("getReaderFormatNames returned " +44"an unknown name: " + n);45}46}47}4849private static void testGetReaderMIMETypes() {50String[] types = ImageIO.getReaderMIMETypes();51for (String t : types) {52Iterator<ImageReader> it = ImageIO.getImageReadersByMIMEType(t);53if (!it.hasNext()) {54throw new RuntimeException("getReaderMIMETypes returned " +55"an unknown type: " + t);56}57}58}5960private static void testGetReaderFileSuffixes() {61String[] suffixes = ImageIO.getReaderFileSuffixes();62for (String s : suffixes) {63Iterator<ImageReader> it = ImageIO.getImageReadersBySuffix(s);64if (!it.hasNext()) {65throw new RuntimeException("getReaderFileSuffixes returned " +66"an unknown suffix: " + s);67}68}69}7071private static void testGetWriterFormatNames() {72String[] names = ImageIO.getWriterFormatNames();73for (String n : names) {74Iterator<ImageWriter> it = ImageIO.getImageWritersByFormatName(n);75if (!it.hasNext()) {76throw new RuntimeException("getWriterFormatNames returned " +77"an unknown name: " + n);78}79}80}8182private static void testGetWriterMIMETypes() {83String[] types = ImageIO.getWriterMIMETypes();84for (String t : types) {85Iterator<ImageWriter> it = ImageIO.getImageWritersByMIMEType(t);86if (!it.hasNext()) {87throw new RuntimeException("getWriterMIMETypes returned " +88"an unknown type: " + t);89}90}91}9293private static void testGetWriterFileSuffixes() {94String[] suffixes = ImageIO.getWriterFileSuffixes();95for (String s : suffixes) {96Iterator<ImageWriter> it = ImageIO.getImageWritersBySuffix(s);97if (!it.hasNext()) {98throw new RuntimeException("getWriterFileSuffixes returned " +99"an unknown suffix: " + s);100}101}102}103104public static void main(String[] args) {105testGetReaderFormatNames();106testGetReaderMIMETypes();107testGetReaderFileSuffixes();108testGetWriterFormatNames();109testGetWriterMIMETypes();110testGetWriterFileSuffixes();111}112}113114115