1 package org.objectweb.celtix.testutil.common; 2 3 import java.io.File ; 4 import java.net.URL ; 5 import java.net.URLClassLoader ; 6 7 8 public final class TestUtil { 9 10 private TestUtil() { 11 } 13 14 public static boolean deleteDir(File dir) { 18 if (dir.isDirectory()) { 19 String [] children = dir.list(); 20 for (int i = 0; i < children.length; i++) { 21 boolean success = deleteDir(new File (dir, children[i])); 22 if (!success) { 23 return false; 24 } 25 } 26 } 27 28 return dir.delete(); 30 } 31 32 public static String getClassPath(ClassLoader loader) { 33 StringBuffer classPath = new StringBuffer (); 34 if (loader instanceof URLClassLoader ) { 35 URLClassLoader urlLoader = (URLClassLoader )loader; 36 for (URL url : urlLoader.getURLs()) { 37 String file = url.getFile(); 38 if (file.indexOf("junit") == -1) { 39 classPath.append(url.getFile()); 40 classPath.append(System.getProperty("path.separator")); 41 } 42 } 43 } 44 return classPath.toString(); 45 } 46 } 47 | Popular Tags |