package com.codeaffine.extras.workingset.internal;

import static org.junit.Assert.assertNotNull;

import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.junit.Test;

import com.codeaffine.extras.workingset.internal.Images;

public class ImagesPDETest {

  @Test
  public void testRegisteredImages() throws IllegalAccessException {
    for( String constantValue : getConstantValues() ) {
      checkImageDescriptor( constantValue );
    }
  }

  private static void checkImageDescriptor( String constantValue ) {
    ImageDescriptor descriptor = Images.getImageDescriptor( constantValue );
    assertNotNull( "No image descriptor registered for: " + constantValue, descriptor );
    Image image = descriptor.createImage( false );
    assertNotNull( "Image descriptor does not return image: " + constantValue, image );
    image.dispose();
  }

  private static String[] getConstantValues() throws IllegalAccessException {
    List<String> constantValues = new LinkedList<>();
    Field[] declaredFields = Images.class.getDeclaredFields();
    for( Field constant : declaredFields ) {
      constantValues.add( ( String )constant.get( null ) );
    }
    return constantValues.toArray( new String[ constantValues.size() ] );
  }
}
@@ -41,24 +41,126 @@
 .internal;%0A%0A
+import static java.lang.reflect.Modifier.isPublic;%0Aimport static java.lang.reflect.Modifier.isStatic;%0A
 import stati
@@ -397,66 +397,8 @@
 t;%0A%0A
-import com.codeaffine.extras.workingset.internal.Images;%0A%0A
 publ
@@ -1226,38 +1226,144 @@
 eld 
-constant : declaredFields ) %7B%0A
+declaredField : declaredFields ) %7B%0A      if( isStatic( declaredField.getModifiers() ) && isPublic( declaredField.getModifiers() ) ) %7B%0A  
     
@@ -1394,24 +1394,29 @@
 String )
-constant
+declaredField
 .get( nu
@@ -1419,24 +1419,32 @@
 ( null ) );%0A
+      %7D%0A
     %7D%0A    re

Work around occasionally thrown IllegalAccessException