1 17 18 package org.apache.tools.ant; 19 20 import java.io.File ; 21 import java.io.IOException ; 22 import java.net.URL ; 23 import java.util.ArrayList ; 24 import java.util.Arrays ; 25 import java.util.Collections ; 26 import java.util.Enumeration ; 27 import java.util.List ; 28 import junit.framework.TestCase; 29 import org.apache.tools.ant.BuildException; 30 import org.apache.tools.ant.Project; 31 import org.apache.tools.ant.types.Path; 32 import org.apache.tools.ant.util.FileUtils; 33 34 38 public class AntClassLoaderTest extends TestCase { 39 40 private Project p; 41 42 public AntClassLoaderTest(String name) { 43 super(name); 44 } 45 46 public void setUp() { 47 p = new Project(); 48 p.init(); 49 } 50 51 public void testCleanup() throws BuildException { 52 Path path = new Path(p, "."); 53 AntClassLoader loader = new AntClassLoader(p, path); 54 try { 55 loader.findClass("fubar"); 57 fail("Did not expect to find fubar class"); 58 } catch (ClassNotFoundException e) { 59 } 61 62 loader.cleanup(); 63 try { 64 loader.findClass("fubar"); 66 fail("Did not expect to find fubar class"); 67 } catch (ClassNotFoundException e) { 68 } catch (NullPointerException e) { 70 fail("loader should not fail even if cleaned up"); 71 } 72 73 p.fireBuildFinished(null); 75 try { 76 loader.findClass("fubar"); 78 fail("Did not expect to find fubar class"); 79 } catch (ClassNotFoundException e) { 80 } catch (NullPointerException e) { 82 fail("loader should not fail even if project finished"); 83 } 84 } 85 } 86 | Popular Tags |