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 12:08:41 UTC

[jspwiki] branch master updated (0c8ef00 -> f07c919)

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git.


    from 0c8ef00  separate prefix and suffix on temporary files
     new 283cf39  changes on FileUtils:
     new 4fb6877  show collection contents on tests failure
     new ac81885  new static methods to build TestEngine instances which do not throw checked Exceptions
     new 481877b  example using static method to build TestEngine
     new f07c919  2.11.0-M6-git-02

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog                                          | 13 ++++++++-
 .../src/main/java/org/apache/wiki/Release.java     |  2 +-
 .../src/test/java/org/apache/wiki/TestEngine.java  | 12 ++++++++
 .../providers/BasicAttachmentProviderTest.java     | 20 +++++++-------
 .../java/org/apache/wiki/ui/PageCommandTest.java   |  3 +-
 .../main/java/org/apache/wiki/util/FileUtil.java   | 32 +++++++---------------
 6 files changed, 46 insertions(+), 36 deletions(-)


[jspwiki] 03/05: new static methods to build TestEngine instances which do not throw checked Exceptions

Posted by ju...@apache.org.
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 ac81885fb22a904b9b69188024b0a236a51cec31
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Oct 12 14:06:22 2019 +0200

    new static methods to build TestEngine instances which do not throw checked Exceptions
---
 jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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 71de8c0..f9cc932 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -118,6 +118,18 @@ public class TestEngine extends WikiEngine
         return m_janneWikiSession;
     }
 
+    public static TestEngine build() {
+        return build( getTestProperties() );
+    }
+
+    public static TestEngine build( final Properties props ) {
+        try {
+            return new TestEngine( props );
+        } catch(  WikiException we ) {
+            throw new UnsupportedOperationException( "Unable to build TestEngine: " + we.getMessage(), we );
+        }
+    }
+
     public TestEngine() throws WikiException {
         this( getTestProperties() );
     }


[jspwiki] 04/05: example using static method to build TestEngine

Posted by ju...@apache.org.
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 481877b6f03c675de7772a3629abf517fb6d5acd
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Oct 12 14:07:36 2019 +0200

    example using static method to build TestEngine
---
 jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java
index 937a3f4..b1ed7d9 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java
@@ -32,12 +32,11 @@ import org.junit.jupiter.api.Test;
 
 public class PageCommandTest {
 
-    TestEngine     testEngine;
+    TestEngine     testEngine = TestEngine.build();
     WikiPage       testPage;
 
     @BeforeEach
     public void setUp() throws Exception {
-        testEngine = new TestEngine();
         testEngine.saveText( "TestPage", "This is a test." );
         testPage = testEngine.getPage( "TestPage" );
     }


[jspwiki] 02/05: show collection contents on tests failure

Posted by ju...@apache.org.
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 4fb6877d9a480e4c6698a3da7d0089684d364241
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Oct 12 14:02:13 2019 +0200

    show collection contents on tests failure
---
 .../wiki/providers/BasicAttachmentProviderTest.java  | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/BasicAttachmentProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/BasicAttachmentProviderTest.java
index 4a346a8..ca46cf6 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/BasicAttachmentProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/BasicAttachmentProviderTest.java
@@ -167,8 +167,8 @@ public class BasicAttachmentProviderTest {
         final Attachment a2 = res.get(0);  // Most recently changed
         final Attachment a1 = res.get(1);  // Least recently changed
 
-        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name" );
-        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name" );
+        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name :: " + res );
+        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name :: " + res );
     }
 
 
@@ -196,8 +196,8 @@ public class BasicAttachmentProviderTest {
         final Attachment a2 = res.get(0);  // Most recently changed
         final Attachment a1 = res.get(1);  // Least recently changed
 
-        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name" );
-        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name" );
+        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name :: " + res );
+        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name :: " + res );
     }
 
     /**
@@ -226,8 +226,8 @@ public class BasicAttachmentProviderTest {
         final Attachment a2 = res.get(0);  // Most recently changed
         final Attachment a1 = res.get(1);  // Least recently changed
 
-        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name" );
-        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name" );
+        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name :: " + res );
+        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name :: " + res );
     }
 
     /**
@@ -258,8 +258,8 @@ public class BasicAttachmentProviderTest {
         final Attachment a2 = res.get(0);  // Most recently changed
         final Attachment a1 = res.get(1);  // Least recently changed
 
-        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name" );
-        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name" );
+        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name :: " + res );
+        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name :: " + res );
     }
 
     @Test
@@ -280,8 +280,8 @@ public class BasicAttachmentProviderTest {
         final Attachment a2 = res.get(0);  // Most recently changed
         final Attachment a1 = res.get(1);  // Least recently changed
 
-        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name" );
-        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name" );
+        Assertions.assertEquals( att.getName(), a1.getName(), "a1 name :: " + res );
+        Assertions.assertEquals( att2.getName(), a2.getName(), "a2 name :: " + res );
     }
 
 }


[jspwiki] 01/05: changes on FileUtils:

Posted by ju...@apache.org.
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 283cf393a47d1e60a6a75948cb317d0c0b1fab32
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Oct 12 14:01:08 2019 +0200

    changes on FileUtils:
    
    * readContents uses try with resources
    * buffer doubles its size so it copyContents(InputStream, OutputStream) method mimics private Files.copyContents(InputStream, OutputStream) more closely
    * copyContents(InputStream, OutputStream) enforces writes to disk for FileOutputStream through their associated FileDescriptor
---
 .../main/java/org/apache/wiki/util/FileUtil.java   | 32 +++++++---------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java b/jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java
index 30c1354..89f0299 100644
--- a/jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java
+++ b/jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java
@@ -23,6 +23,7 @@ import org.apache.log4j.Logger;
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileDescriptor;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -47,7 +48,7 @@ import java.nio.charset.StandardCharsets;
 public final class FileUtil {
 
     /** Size of the buffer used when copying large chunks of data. */
-    private static final int      BUFFER_SIZE = 4096;
+    private static final int      BUFFER_SIZE = 8192;
     private static final Logger   log         = Logger.getLogger(FileUtil.class);
 
     /**
@@ -166,6 +167,12 @@ public final class FileUtil {
         }
 
         out.flush();
+
+        // FileOutputStream.flush is an empty method, so in this case we grab the underlying file descriptor and force from there thw write to disk
+        if( out instanceof FileOutputStream ) {
+            FileDescriptor fd = ( ( FileOutputStream )out ).getFD();
+            fd.sync();
+        }
     }
 
     /**
@@ -231,30 +238,11 @@ public final class FileUtil {
      *  @return String read from the Reader
      *  @throws IOException If reading fails.
      */
-    public static String readContents( Reader in )
-        throws IOException
-    {
-        Writer out = null;
-
-        try
-        {
-            out = new StringWriter();
-
+    public static String readContents( final Reader in ) throws IOException {
+        try( Writer out = new StringWriter() ) {
             copyContents( in, out );
-
             return out.toString();
         }
-        finally
-        {
-            try
-            {
-                out.close();
-            }
-            catch( Exception e )
-            {
-                log.error("Not able to close the stream while reading contents.");
-            }
-        }
     }
 
     /**


[jspwiki] 05/05: 2.11.0-M6-git-02

Posted by ju...@apache.org.
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 f07c919bd458c72f9ec736e4ea9a88c6d504ac29
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Oct 12 14:08:07 2019 +0200

    2.11.0-M6-git-02
---
 ChangeLog                                               | 13 ++++++++++++-
 jspwiki-main/src/main/java/org/apache/wiki/Release.java |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9bc95bc..12ec2a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,21 @@
+2019-12-10  Juan Pablo Santos (juanpablo AT apache DOT org)
+
+       * 2.11.0-M6-git-02
+
+       * FileUtils.copyContents( InputStream, OutputStream ) enforces writes to disk for FileOutputStream through
+         their associated FileDescriptor.
+
+       * new static methods to build TestEngine instances which do not throw checked Exceptions and thus allows
+         TestEngine instances to be built as member of test classes, instead of rebuilding for every test and saving
+         some time in the process.
+
 2019-10-10  Juan Pablo Santos (juanpablo AT apache DOT org)
 
        * 2.11.0-M6-git-01
 
        * Introduce Awaitility to speed up tests formerly relaying on Thread.sleep(..)
 
-       * LuceneSearchProvider now uses an Executor to increase performance on searches
+       * LuceneSearchProvider now uses an Executor to increase performance on searches.
 
 2019-12-09  Dirk Frederickx (brushed AT apache DOT org)
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/Release.java b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
index e9d28f9..6359706 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
@@ -72,7 +72,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "git-01";
+    public static final String     BUILD         = "git-02";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of