package fitnesse.components;

import static org.junit.Assert.*;

import org.junit.Test;


public class PluginsClassLoaderTest {

  @Test
  public void whenPluginsDirectoryDoesNotExist() throws Exception {
    new PluginsClassLoader().getClassLoader("nonExistingRootDirectory");

    assertTrue("didn't cause exception", true);
  }

  @Test
  public void addPluginsToClassLoader() throws Exception {
    String[] dynamicClasses = new String[]{"fitnesse.testing.PluginX", "fitnesse.testing.PluginY"};
    //todo This fails because some other test probably loads plugin path    assertLoadingClassCausesException(dynamicClasses);
    ClassLoader cl = PluginsClassLoader.getClassLoader(".");


    assertLoadingClassWorksNow(cl, dynamicClasses);
  }

  private void assertLoadingClassWorksNow(ClassLoader cl, String... dynamicClasses) {
    for (String dynamicClass : dynamicClasses) {
      try {
        Class<?> dynamicallyLoadedClass = Class.forName(dynamicClass, true, cl);
        assertEquals(dynamicClass, dynamicallyLoadedClass.getName());
      } catch (ClassNotFoundException e) {
        fail("Class not found: " + e.getMessage());
      }
    }
  }
}

@@ -496,135 +496,8 @@
 %22%7D;%0A
-    //todo This fails because some other test probably loads plugin path    assertLoadingClassCausesException(dynamicClasses);%0A
     
@@ -554,17 +554,16 @@
 (%22.%22);%0A%0A
-%0A
     asse

Remove no longer valid todo