Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/imageio/metadata/RegisteredFormatsTest.java
51315 views
1
/*
2
* Copyright (c) 2012, 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 5017991
27
* @summary This test verifies two things:
28
* a) we can get MetadataFormat classes for
29
* each registered metadata format.
30
* b) all metadata formats for standard plugins
31
* are registered.
32
* @run main RegisteredFormatsTest
33
*/
34
35
import javax.imageio.spi.IIORegistry;
36
import javax.imageio.spi.ImageReaderSpi;
37
import javax.imageio.metadata.IIOMetadataFormat;
38
import java.util.Iterator;
39
import java.util.Hashtable;
40
import java.util.Enumeration;
41
42
public class RegisteredFormatsTest {
43
44
private static Hashtable fmts;
45
46
public static void main(String[] args) {
47
fmts = new Hashtable();
48
49
fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE);
50
fmts.put("javax_imageio_jpeg_image_1.0", Boolean.FALSE);
51
fmts.put("javax_imageio_png_1.0", Boolean.FALSE);
52
fmts.put("javax_imageio_bmp_1.0", Boolean.FALSE);
53
fmts.put("javax_imageio_wbmp_1.0", Boolean.FALSE);
54
fmts.put("javax_imageio_gif_stream_1.0", Boolean.FALSE);
55
fmts.put("javax_imageio_gif_image_1.0", Boolean.FALSE);
56
57
IIORegistry registry = IIORegistry.getDefaultInstance();
58
Iterator iter = registry.getServiceProviders(ImageReaderSpi.class,
59
false);
60
while(iter.hasNext()) {
61
ImageReaderSpi spi = (ImageReaderSpi)iter.next();
62
String fmt_name;
63
fmt_name = spi.getNativeStreamMetadataFormatName();
64
testStreamMetadataFormat(spi, fmt_name);
65
66
fmt_name = spi.getNativeImageMetadataFormatName();
67
testImageMetadataFormat(spi, fmt_name);
68
69
String[] fmt_names;
70
fmt_names = spi.getExtraStreamMetadataFormatNames();
71
for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
72
testStreamMetadataFormat(spi, fmt_names[i]);
73
}
74
75
fmt_names = spi.getExtraImageMetadataFormatNames();
76
for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
77
testImageMetadataFormat(spi, fmt_names[i]);
78
}
79
}
80
Enumeration keys = fmts.keys();
81
while (keys.hasMoreElements()) {
82
String key = (String)keys.nextElement();
83
boolean val = ((Boolean)fmts.get(key)).booleanValue();
84
if (!val) {
85
throw new RuntimeException("Test failed: format " +
86
key + "is not registered.");
87
}
88
}
89
}
90
91
private static void testStreamMetadataFormat(ImageReaderSpi spi,
92
String fmt_name) {
93
if (fmt_name == null) {
94
return;
95
}
96
try {
97
testMetadataFormat(spi.getStreamMetadataFormat(fmt_name),
98
fmt_name);
99
} catch (Exception e) {
100
throw new RuntimeException("Test failed for " + fmt_name,
101
e);
102
}
103
}
104
105
private static void testImageMetadataFormat(ImageReaderSpi spi,
106
String fmt_name) {
107
if (fmt_name == null) {
108
return;
109
}
110
try {
111
testMetadataFormat(spi.getImageMetadataFormat(fmt_name),
112
fmt_name);
113
} catch (Exception e) {
114
throw new RuntimeException("Test failed for " + fmt_name,
115
e);
116
}
117
}
118
private static void testMetadataFormat(IIOMetadataFormat fmt,
119
String fmt_name) {
120
System.out.print(fmt_name + "...");
121
if (fmt != null) {
122
fmts.put(fmt_name, Boolean.TRUE);
123
System.out.println("Ok");
124
} else {
125
throw new RuntimeException("Test failed for " + fmt_name);
126
}
127
}
128
}
129
130