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 2022/05/01 12:55:20 UTC
[jspwiki] 01/07: TestEngine#shutdown() now cleans cache, wiki pages dir and their associated attachments, if any
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 31a0633216743f19cb275ebdf339b372cffb1de0
Author: Juan Pablo Santos RodrÃguez <ju...@gmail.com>
AuthorDate: Sun May 1 14:47:24 2022 +0200
TestEngine#shutdown() now cleans cache, wiki pages dir and their associated attachments, if any
* TestEngine#emptyWikiDir( Properties ) deletes both page and attachment directories
---
.../src/test/java/org/apache/wiki/TestEngine.java | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 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 1ccf1ef0b..95dbe234a 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -230,6 +230,14 @@ public class TestEngine extends WikiEngine {
return request;
}
+ /** {@inheritDoc} */
+ @Override
+ public void shutdown() {
+ super.shutdown();
+ TestEngine.emptyWikiDir( getWikiProperties() );
+ TestEngine.emptyWorkDir( getWikiProperties() );
+ }
+
public static void emptyWorkDir() {
emptyWorkDir( null );
}
@@ -258,9 +266,13 @@ public class TestEngine extends WikiEngine {
if( properties == null ) {
properties = getTestProperties();
}
- final String wikidir = properties.getProperty( AbstractFileProvider.PROP_PAGEDIR );
- if ( wikidir != null ) {
- final File f = new File( wikidir );
+ emptyDir( properties.getProperty( AbstractFileProvider.PROP_PAGEDIR ) );
+ emptyDir( properties.getProperty( AttachmentProvider.PROP_STORAGEDIR ) );
+ }
+
+ static void emptyDir( final String dir ) {
+ if ( dir != null ) {
+ final File f = new File( dir );
if( f.exists() && f.isDirectory() ) {
deleteAll( f );
}