1 package org.apache.maven.plugin.resources.remote.it.support; 2 3 import java.io.File; 4 import java.io.IOException; 5 import java.net.URI; 6 import java.net.URISyntaxException; 7 import java.net.URL; 8 9 public class TestUtils 10 { 11 public static File getTestDir( final String name ) 12 throws IOException, URISyntaxException 13 { 14 ClassLoader cloader = Thread.currentThread().getContextClassLoader(); 15 URL resource = cloader.getResource( name ); 16 17 if ( resource == null ) 18 { 19 throw new IOException( "Cannot find test directory: " + name ); 20 } 21 22 return new File( new URI( resource.toExternalForm() ).normalize().getPath() ); 23 } 24 25 public static File getBaseDir() 26 { 27 File result = new File( System.getProperty( "basedir", "." ) ); 28 try 29 { 30 return result.getCanonicalFile(); 31 } 32 catch ( IOException e ) 33 { 34 return result.getAbsoluteFile(); 35 } 36 } 37 }