/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 4929170 * @summary Tests that user-supplied IIOMetadata implementations loaded by * system class loader (i.e. corresponding classes are available via * classpath) is able to load correspnding IIOMetadataFormat * implementations. * @run main UserPluginMetadataFormatTest */ import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.ByteArrayInputStream; import java.util.Iterator; import java.util.ListResourceBundle; import java.util.Locale; import java.util.MissingResourceException; import java.util.Objects; import java.util.Vector; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.ImageReadParam; import javax.imageio.IIOException; import javax.imageio.ImageTypeSpecifier; import javax.imageio.event.IIOReadWarningListener; import javax.imageio.metadata.IIOMetadata; import javax.imageio.metadata.IIOMetadataFormat; import javax.imageio.metadata.IIOMetadataFormatImpl; import javax.imageio.metadata.IIOInvalidTreeException; import javax.imageio.spi.ImageReaderSpi; import org.w3c.dom.Node; public class UserPluginMetadataFormatTest implements MetadataTest { public static void main(String[] argv) throws IOException { new UserPluginMetadataFormatTest().doTest(); } public void doTest() throws IOException { DummyImageReaderImpl reader; reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl()); byte[] data = new byte[1024]; ByteArrayInputStream bais = new ByteArrayInputStream(data); reader.setInput(ImageIO.createImageInputStream(bais)); IIOMetadata metadata = reader.getImageMetadata(1); if(metadata == null) { throw new RuntimeException("IIOMetada is NULL"); } String[] formatNames = metadata.getMetadataFormatNames(); for(int j=0; j