package se.jiderhamn.classloader.leak.prevention;

import javax.imageio.ImageIO;

import org.junit.Test;
import org.junit.runner.RunWith;

import se.jiderhamn.classloader.leak.JUnitClassloaderRunner;
import se.jiderhamn.classloader.leak.LeakPreventor;

/**
 * @author Thomas Scheffler
 */
@RunWith(JUnitClassloaderRunner.class)
@LeakPreventor(ImageIOTest.Prevent.class)
public class ImageIOTest {
  
  @Test
  public void triggerImageIOLeak() throws Exception {
    ImageIO.scanForPlugins();
  }
  
  public static class Prevent implements Runnable {
    public void run() {
      new ClassLoaderLeakPreventor() {
        { // Initializer / "Constructor"
          deregisterIIOServiceProvider();
        }
      };
    }

  }

}
@@ -73,16 +73,38 @@
 ImageIO;
+%0Aimport javax.swing.*;
 %0A%0Aimport
@@ -153,17 +153,16 @@
 unWith;%0A
-%0A
 import s
@@ -415,19 +415,17 @@
 t %7B%0A
-  
 %0A
+
   @Test%0A
   pu
@@ -420,16 +420,16 @@
   @Test%0A
-
   public
@@ -474,16 +474,340 @@
 ption %7B%0A
+    // ImageIO.scanForPlugins() triggers two different leaks, but the preventor only removes one, so we need to avoid%0A    // the other one%0A    new ClassLoaderLeakPreventor().doInSystemClassLoader(new Runnable() %7B%0A      @Override%0A      public void run() %7B%0A        new JEditorPane(%22text/plain%22, %22dummy%22);%0A      %7D%0A    %7D);%0A    %0A
     Imag

Fix ImageIOTest dependency on JEditorPaneTest