You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/01/09 22:17:19 UTC
[jspwiki] 09/32: Improvements on TestEngine
This is an automated email from the ASF dual-hosted git repository.
juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit 3a4c6a55b9646ef1a4b5386dcd26d1459c502e68
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 4 15:15:43 2020 +0100
Improvements on TestEngine
* includes class and method creating the TestEngine on page, attachment and work directories, so its easier to locate which test created which folders
* ensure page, attachment and work directories are always created under target/ folder
---
.../src/test/java/org/apache/wiki/TestEngine.java | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
index 0437b48..6140d83 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -125,7 +125,7 @@ public class TestEngine extends WikiEngine
public static TestEngine build( final Properties props ) {
try {
return new TestEngine( props );
- } catch( WikiException we ) {
+ } catch( final WikiException we ) {
throw new UnsupportedOperationException( "Unable to build TestEngine: " + we.getMessage(), we );
}
}
@@ -421,16 +421,28 @@ public class TestEngine extends WikiEngine
}
private static String cleanNewDirFrom( final String pageDir, final long millis ) {
+ final String testEngineCreationOrigin = getTestEngineCreationOrigin();
if( StringUtils.isBlank( pageDir ) ) {
- return "";
+ return "target/" + millis + "-" + testEngineCreationOrigin;
}
if( pageDir.lastIndexOf( '/' ) == -1 ) {
- return "target/" + millis + "-" + pageDir;
+ return "target/" + millis + "-" + testEngineCreationOrigin + "-" + pageDir;
}
final String stripNumbers = pageDir.substring( pageDir.lastIndexOf( '/' ) );
return pageDir.substring( 0, pageDir.lastIndexOf( '/' ) + 1 )
- + millis // place all related tests' folders one next to the others
- + stripNumbers.replaceAll( "\\d", StringUtils.EMPTY );
+ + millis
+ + "-" + testEngineCreationOrigin
+ + stripNumbers.replaceAll( "\\d", StringUtils.EMPTY ); // place all related tests' folders one next to the others
+ }
+
+ private static String getTestEngineCreationOrigin() {
+ for( final StackTraceElement trace : Thread.currentThread().getStackTrace() ) {
+ if( !( trace.getClassName().contains( TestEngine.class.getSimpleName() ) ||
+ trace.getClassName().contains( Thread.class.getSimpleName() ) ) ) {
+ return trace.getClassName() + "-" + trace.getMethodName();
+ }
+ }
+ return "Unable to locate TestEngine creation";
}
}