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 2019/10/12 17:12:13 UTC
[jspwiki] 03/05: TestEngine will generate separate page,
attachment and work directories,
in order to allow each instance to work with a clean file installation - no
version bump
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 b62d8cfd1a1219f0f61a6e377db0b50fc1f36fec
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Oct 12 19:10:57 2019 +0200
TestEngine will generate separate page, attachment and work directories, in order to allow each instance to work with a clean file installation - no version bump
---
.../src/test/java/org/apache/wiki/TestEngine.java | 23 ++++++++++++++++------
1 file changed, 17 insertions(+), 6 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 f9cc932..9eef99e 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -445,14 +445,25 @@ public class TestEngine extends WikiEngine
* @return the corrected/clean properties
*/
private static Properties cleanTestProps( final Properties props ) {
- final String pageDir = props.getProperty( "jspwiki.fileSystemProvider.pageDir" );
- final String stripNumbers = pageDir.substring( pageDir.lastIndexOf( '/' ) );
- final String testDir = pageDir.substring( 0, pageDir.lastIndexOf( '/' ) ) +
- stripNumbers.replaceAll( "\\d", StringUtils.EMPTY ) + System.currentTimeMillis();
+ long millis = System.currentTimeMillis();
props.put( AuthenticationManager.PROP_LOGIN_THROTTLING, "false" );
- props.setProperty( "jspwiki.fileSystemProvider.pageDir", testDir );
- props.setProperty( "jspwiki.basicAttachmentProvider.storageDir", testDir );
+ props.setProperty( "jspwiki.fileSystemProvider.pageDir", cleanNewDirFrom( props.getProperty( "jspwiki.fileSystemProvider.pageDir" ), millis ) );
+ props.setProperty( "jspwiki.basicAttachmentProvider.storageDir", cleanNewDirFrom( props.getProperty( "jspwiki.basicAttachmentProvider.storageDir" ), millis ) );
+ props.setProperty( "jspwiki.workDir", cleanNewDirFrom( props.getProperty( "jspwiki.workDir" ), millis ) );
return props;
}
+ private static String cleanNewDirFrom( final String pageDir, final long millis ) {
+ if( StringUtils.isBlank( pageDir ) ) {
+ return "";
+ }
+ if( pageDir.lastIndexOf( '/' ) == -1 ) {
+ return "target/" + millis + "-" + 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 );
+ }
+
}