1 package org.apache.maven.tools.plugin.util; 2 3 import java.net.URL ; 4 5 import junit.framework.TestCase; 6 7 10 public class TestUtils 11 extends TestCase 12 { 13 14 public void testDirnameFunction_METATEST() 15 { 16 String classname = getClass().getName().replace( '.', '/' ) + ".class"; 17 String basedir = TestUtils.dirname( classname ); 18 19 ClassLoader cl = Thread.currentThread().getContextClassLoader(); 20 URL resource = cl.getResource( classname ); 21 22 assertEquals( resource.getPath(), basedir + classname ); 23 } 24 25 public static String dirname( String file ) 26 { 27 ClassLoader cl = Thread.currentThread().getContextClassLoader(); 28 URL fileResource = cl.getResource( file ); 29 30 String fullPath = fileResource.getPath(); 31 32 return fullPath.substring( 0, fullPath.length() - file.length() ); 33 } 34 35 } | Popular Tags |