summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webapp-test-js/src
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-03-02 13:15:54 +0000
committerOlivier Lamy <olamy@apache.org>2012-03-02 13:15:54 +0000
commit42594441029667d809c3f0f834ef9bb20946412e (patch)
treed51ee30e71ff287c361f369be8d94cee4bfdd05b /archiva-modules/archiva-web/archiva-webapp-test-js/src
parent54777fc53bb8c5a88341763d6d0b5e9b9fb75066 (diff)
downloadarchiva-42594441029667d809c3f0f834ef9bb20946412e.tar.gz
archiva-42594441029667d809c3f0f834ef9bb20946412e.zip
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
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webapp-test-js/src')
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java35
1 files changed, 14 insertions, 21 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
index 8afd1bedb..4e94ccc12 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
@@ -37,7 +37,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
-import java.util.regex.Pattern;
/**
* @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" );
String time = sdf.format( new Date() );
File targetPath = new File( "target", "screenshots" );
- StackTraceElement stackTrace[] = failure.getStackTrace();
String cName = this.getClass().getName();
- int index = getStackTraceIndexOfCallingClass( cName, stackTrace );
- String methodName = stackTrace[index].getMethodName();
- int lNumber = stackTrace[index].getLineNumber();
- String lineNumber = Integer.toString( lNumber );
+
+ String methodName = "";
+ int lineNumber = 0;
+
+ 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 );
targetPath.mkdirs();
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;
- }
-
} \ No newline at end of file