1 17 18 package org.apache.tools.ant.util; 19 20 import java.io.File ; 21 import java.io.IOException ; 22 import java.util.Enumeration ; 23 import junit.framework.TestCase; 24 25 import org.apache.tools.ant.BuildException; 26 import org.apache.tools.ant.Project; 27 import org.apache.tools.ant.types.Path; 28 29 30 34 public class ClasspathUtilsTest extends TestCase { 35 36 private Project p; 37 38 public ClasspathUtilsTest(String name) { 39 super(name); 40 } 41 42 public void setUp() { 43 p = new Project(); 44 p.init(); 45 } 46 47 48 public void testOnlyOneInstance() { 49 Enumeration enumeration; 50 String list = ""; 51 ClassLoader c = ClasspathUtils.getUniqueClassLoaderForPath(p, (Path) null, false); 52 try { 53 enumeration = c.getResources( 54 "org/apache/tools/ant/taskdefs/defaults.properties"); 55 } catch (IOException e) { 56 throw new BuildException( 57 "Could not get the defaults.properties resource"); 58 } 59 int count = 0; 60 while (enumeration.hasMoreElements()) { 61 list = list + " " + enumeration.nextElement(); 62 count++; 63 } 64 assertTrue("Should be only one and not " + count + " " + list, count == 1); 65 } 66 } 67 | Popular Tags |