o pull in the ~/build.properties

o allow absolute paths in the expected results specifications


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162783 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-06-17 19:37:22 +00:00
parent 3d085c9ca8
commit 240aaecc58
1 changed files with 69 additions and 8 deletions

View File

@ -4,7 +4,10 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@ -14,6 +17,8 @@ public class Verifier
{
private String basedir;
private String mavenRepoLocal;
public Verifier( String basedir )
{
this.basedir = basedir;
@ -26,6 +31,19 @@ public class Verifier
public void verify()
throws VerificationException
{
Properties mavenProperties = new Properties();
try
{
mavenProperties.load( new FileInputStream( new File( System.getProperty( "user.home" ), "build.properties" ) ) );
}
catch ( IOException e )
{
throw new VerificationException( "Can't find the build.properties file! Verification can't proceed!" );
}
mavenRepoLocal = mavenProperties.getProperty( "maven.repo.local" );
try
{
BufferedReader reader = new BufferedReader( new FileReader( new File( basedir, "expected-results.txt" ) ) );
@ -42,18 +60,14 @@ public class Verifier
throw new VerificationException( e );
}
System.out.println( "\n" );
System.out.println( "-------------------------------------" );
System.out.println( "Integration test OK" );
System.out.println( "-------------------------------------" );
System.out.println( "---------------------------> OK" );
}
private void verifyExpectedResult( String line )
throws VerificationException
{
line = replace( line, "${maven.repo.local}", mavenRepoLocal );
if ( line.indexOf( "!/" ) > 0 )
{
String urlString = "jar:file:" + line;
@ -76,7 +90,16 @@ public class Verifier
}
else
{
File expectedFile = new File( basedir, line );
File expectedFile;
if ( line.startsWith( "/" ) )
{
expectedFile = new File( line );
}
else
{
expectedFile = new File( basedir, line );
}
if ( !expectedFile.exists() )
{
@ -85,6 +108,44 @@ public class Verifier
}
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public static String replaceOnce( String text, String repl, String with )
{
return replace( text, repl, with, 1 );
}
public static String replace( String text, String repl, String with )
{
return replace( text, repl, with, -1 );
}
public static String replace( String text, String repl, String with, int max )
{
if ( text == null || repl == null || with == null || repl.length() == 0 )
{
return text;
}
StringBuffer buf = new StringBuffer( text.length() );
int start = 0, end = 0;
while ( ( end = text.indexOf( repl, start ) ) != -1 )
{
buf.append( text.substring( start, end ) ).append( with );
start = end + repl.length();
if ( --max == 0 )
{
break;
}
}
buf.append( text.substring( start ) );
return buf.toString();
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------