Esempio n. 1
0
  private void testFormat(String format) {
    ImageReader reader = ImageIO.getImageReadersByFormatName(format).next();
    ImageWriter writer = ImageIO.getImageWritersByFormatName(format).next();

    assertEquals(
        "getImageReader() returns an incorrect reader for " + format,
        ImageIO.getImageReader(writer).getClass(),
        reader.getClass());
    assertEquals(
        "getImageWriter() returns an incorrect writer for " + format,
        ImageIO.getImageWriter(reader).getClass(),
        writer.getClass());
  }
Esempio n. 2
0
  public void testGetNullReaderWriter() throws Exception {
    try {
      ImageIO.getImageWriter(null);
      fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // Ok
    }

    try {
      ImageIO.getImageReader(null);
      fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // Ok
    }
  }
Esempio n. 3
0
  public void testGetWriterMIMETypes() {
    Set<String> expectedMIMETypes =
        new HashSet<String>(Arrays.asList(new String[] {"image/x-png", "image/png", "image/jpeg"}));

    Set<String> actualMIMETypes = new HashSet<String>(Arrays.asList(ImageIO.getWriterMIMETypes()));
    assertTrue(actualMIMETypes.containsAll(expectedMIMETypes));
  }
Esempio n. 4
0
 public void testReadURL() throws Exception {
   // Regression for HARMONY-3135
   for (URL url : listImages()) {
     assertNotNull("Failed to load image from URL " + url, ImageIO.read(url));
     assertFalse(
         "The current thread has been interrupted! URL: " + url, // $NON-NLS-1$
         Thread.currentThread().isInterrupted());
   }
 }
Esempio n. 5
0
  public void testGetWriterFormatNames() {
    Set<String> expectedFormatNames =
        new HashSet<String>(
            Arrays.asList(new String[] {"JPG", "jpg", "JPEG", "jpeg", "PNG", "png"}));

    Set<String> actualFormatNames =
        new HashSet<String>(Arrays.asList(ImageIO.getWriterFormatNames()));
    assertTrue(actualFormatNames.containsAll(expectedFormatNames));
  }
Esempio n. 6
0
  public void testCache() throws Exception {
    ImageIO.setUseCache(true);
    assertTrue("Failed to enable cache", ImageIO.getUseCache());
    ImageIO.setUseCache(false);
    assertFalse("Failed to disable cache", ImageIO.getUseCache());

    ImageIO.setCacheDirectory(null);
    assertNull("Failed to set cache directory", ImageIO.getCacheDirectory());

    try {
      ImageIO.setCacheDirectory(new File(""));
      fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException expected) {
      // OK
    }
  }