|
1 /* |
|
2 * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
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 4703112 |
|
27 * @summary Verifies that ImageIO.getReaderFileSuffixes() and similar methods |
|
28 * return appropriate values |
|
29 */ |
|
30 |
|
31 import java.util.Iterator; |
|
32 |
|
33 import javax.imageio.ImageIO; |
|
34 import javax.imageio.ImageReader; |
|
35 import javax.imageio.ImageWriter; |
|
36 |
|
37 public class GetReaderWriterInfo { |
|
38 |
|
39 private static void testGetReaderFormatNames() { |
|
40 String[] names = ImageIO.getReaderFormatNames(); |
|
41 for (String n : names) { |
|
42 Iterator<ImageReader> it = ImageIO.getImageReadersByFormatName(n); |
|
43 if (!it.hasNext()) { |
|
44 throw new RuntimeException("getReaderFormatNames returned " + |
|
45 "an unknown name: " + n); |
|
46 } |
|
47 } |
|
48 } |
|
49 |
|
50 private static void testGetReaderMIMETypes() { |
|
51 String[] types = ImageIO.getReaderMIMETypes(); |
|
52 for (String t : types) { |
|
53 Iterator<ImageReader> it = ImageIO.getImageReadersByMIMEType(t); |
|
54 if (!it.hasNext()) { |
|
55 throw new RuntimeException("getReaderMIMETypes returned " + |
|
56 "an unknown type: " + t); |
|
57 } |
|
58 } |
|
59 } |
|
60 |
|
61 private static void testGetReaderFileSuffixes() { |
|
62 String[] suffixes = ImageIO.getReaderFileSuffixes(); |
|
63 for (String s : suffixes) { |
|
64 Iterator<ImageReader> it = ImageIO.getImageReadersBySuffix(s); |
|
65 if (!it.hasNext()) { |
|
66 throw new RuntimeException("getReaderFileSuffixes returned " + |
|
67 "an unknown suffix: " + s); |
|
68 } |
|
69 } |
|
70 } |
|
71 |
|
72 private static void testGetWriterFormatNames() { |
|
73 String[] names = ImageIO.getWriterFormatNames(); |
|
74 for (String n : names) { |
|
75 Iterator<ImageWriter> it = ImageIO.getImageWritersByFormatName(n); |
|
76 if (!it.hasNext()) { |
|
77 throw new RuntimeException("getWriterFormatNames returned " + |
|
78 "an unknown name: " + n); |
|
79 } |
|
80 } |
|
81 } |
|
82 |
|
83 private static void testGetWriterMIMETypes() { |
|
84 String[] types = ImageIO.getWriterMIMETypes(); |
|
85 for (String t : types) { |
|
86 Iterator<ImageWriter> it = ImageIO.getImageWritersByMIMEType(t); |
|
87 if (!it.hasNext()) { |
|
88 throw new RuntimeException("getWriterMIMETypes returned " + |
|
89 "an unknown type: " + t); |
|
90 } |
|
91 } |
|
92 } |
|
93 |
|
94 private static void testGetWriterFileSuffixes() { |
|
95 String[] suffixes = ImageIO.getWriterFileSuffixes(); |
|
96 for (String s : suffixes) { |
|
97 Iterator<ImageWriter> it = ImageIO.getImageWritersBySuffix(s); |
|
98 if (!it.hasNext()) { |
|
99 throw new RuntimeException("getWriterFileSuffixes returned " + |
|
100 "an unknown suffix: " + s); |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 public static void main(String[] args) { |
|
106 testGetReaderFormatNames(); |
|
107 testGetReaderMIMETypes(); |
|
108 testGetReaderFileSuffixes(); |
|
109 testGetWriterFormatNames(); |
|
110 testGetWriterMIMETypes(); |
|
111 testGetWriterFileSuffixes(); |
|
112 } |
|
113 } |