mirror of https://github.com/apache/archiva.git
simplify finding the stack strace in case of issue
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1296190 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
54777fc53b
commit
4259444102
|
@ -37,7 +37,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||||
|
@ -507,12 +506,21 @@ public abstract class AbstractSeleniumTest
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" );
|
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" );
|
||||||
String time = sdf.format( new Date() );
|
String time = sdf.format( new Date() );
|
||||||
File targetPath = new File( "target", "screenshots" );
|
File targetPath = new File( "target", "screenshots" );
|
||||||
StackTraceElement stackTrace[] = failure.getStackTrace();
|
|
||||||
String cName = this.getClass().getName();
|
String cName = this.getClass().getName();
|
||||||
int index = getStackTraceIndexOfCallingClass( cName, stackTrace );
|
|
||||||
String methodName = stackTrace[index].getMethodName();
|
String methodName = "";
|
||||||
int lNumber = stackTrace[index].getLineNumber();
|
int lineNumber = 0;
|
||||||
String lineNumber = Integer.toString( lNumber );
|
|
||||||
|
for ( StackTraceElement stackTrace : failure.getStackTrace() )
|
||||||
|
{
|
||||||
|
if ( stackTrace.getClassName().equals( this.getClass().getName() ) )
|
||||||
|
{
|
||||||
|
methodName = stackTrace.getMethodName();
|
||||||
|
lineNumber = stackTrace.getLineNumber();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
|
String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
|
||||||
targetPath.mkdirs();
|
targetPath.mkdirs();
|
||||||
Selenium selenium = AbstractSeleniumTest.getSelenium();
|
Selenium selenium = AbstractSeleniumTest.getSelenium();
|
||||||
|
@ -525,19 +533,4 @@ public abstract class AbstractSeleniumTest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement stackTrace[] )
|
|
||||||
{
|
|
||||||
boolean match = false;
|
|
||||||
int i = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
String className = stackTrace[i].getClassName();
|
|
||||||
match = Pattern.matches( nameOfClass, className );
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
while ( match == false );
|
|
||||||
i--;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue