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 655c71146fb1e83a437f37ea343783c711bca0fb
Author: Juan Pablo Santos Rodríguez <[email protected]>
AuthorDate: Wed Sep 1 17:18:39 2021 +0200

    format + speed up counter plugin tests a little bit
---
 .../org/apache/wiki/plugin/CounterPluginTest.java  | 81 +++++-----------------
 1 file changed, 18 insertions(+), 63 deletions(-)

diff --git 
a/jspwiki-main/src/test/java/org/apache/wiki/plugin/CounterPluginTest.java 
b/jspwiki-main/src/test/java/org/apache/wiki/plugin/CounterPluginTest.java
index 94d5a75..c754690 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/CounterPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/CounterPluginTest.java
@@ -20,7 +20,6 @@ package org.apache.wiki.plugin;
 
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.core.Context;
-import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.spi.Wiki;
 import org.apache.wiki.parser.JSPWikiMarkupParser;
 import org.apache.wiki.parser.MarkupParser;
@@ -28,107 +27,63 @@ import org.apache.wiki.parser.WikiDocument;
 import org.apache.wiki.render.WikiRenderer;
 import org.apache.wiki.render.XHTMLRenderer;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import javax.servlet.ServletException;
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.Properties;
 
-public class CounterPluginTest
-{
-    Properties props = TestEngine.getTestProperties();
-    TestEngine testEngine;
+public class CounterPluginTest {
 
-    @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-        testEngine = new TestEngine(props);
-    }
+    TestEngine testEngine = TestEngine.build();
 
-    private String translate( final String src )
-        throws IOException,
-               NoRequiredPropertyException,
-               ServletException
-    {
+    private String translate( final String src ) throws IOException {
         final Context context = Wiki.context().create( testEngine, 
Wiki.contents().page(testEngine, "TestPage") );
-
         final MarkupParser p = new JSPWikiMarkupParser( context, new 
StringReader(src) );
-
         final WikiDocument dom = p.parse();
-
         final WikiRenderer r = new XHTMLRenderer( context, dom );
-
         return r.getString();
     }
 
     @Test
-    public void testSimpleCount()
-        throws Exception
-    {
+    public void testSimpleCount() throws Exception {
         final String src = "[{Counter}], [{Counter}]";
-
-        Assertions.assertEquals( "1, 2", translate(src) );
+        Assertions.assertEquals( "1, 2", translate( src ) );
     }
 
     @Test
-    public void testSimpleVar()
-        throws Exception
-    {
+    public void testSimpleVar() throws Exception {
         final String src = "[{Counter}], [{Counter}], [{$counter}]";
-
-        Assertions.assertEquals( "1, 2, 2",
-                      translate(src) );
+        Assertions.assertEquals( "1, 2, 2", translate( src ) );
     }
 
     @Test
-    public void testTwinVar()
-        throws Exception
-    {
+    public void testTwinVar() throws Exception {
         final String src = "[{Counter}], [{Counter name=aa}], [{$counter-aa}]";
-
-        Assertions.assertEquals( "1, 1, 1",
-                      translate(src) );
+        Assertions.assertEquals( "1, 1, 1", translate( src ) );
     }
 
     @Test
-    public void testIncrement()
-        throws Exception
-    {
+    public void testIncrement() throws Exception {
         String src = "[{Counter}], [{Counter increment=9}]";
-
-        Assertions.assertEquals( "1, 10", translate(src) );
-
+        Assertions.assertEquals( "1, 10", translate( src ) );
         src = "[{Counter}],[{Counter}], [{Counter increment=-8}]";
-
-        Assertions.assertEquals( "1,2, -6", translate(src) );
+        Assertions.assertEquals( "1,2, -6", translate( src ) );
     }
 
     @Test
-    public void testIncrement2() throws Exception
-    {
+    public void testIncrement2() throws Exception {
         String src = "[{Counter start=5}], [{Counter increment=-1}], [{Counter 
increment=-1}]";
-
-        Assertions.assertEquals( "5, 4, 3", translate(src) );
-
+        Assertions.assertEquals( "5, 4, 3", translate( src ) );
         src = "[{Counter}],[{Counter start=11}], [{Counter increment=-8}]";
-
-        Assertions.assertEquals( "1,11, 3", translate(src) );
+        Assertions.assertEquals( "1,11, 3", translate( src ) );
     }
 
     @Test
-    public void testShow()
-        throws Exception
-    {
+    public void testShow() throws Exception {
         String src = "[{Counter}],[{Counter showResult=false}],[{Counter}]";
-
-        Assertions.assertEquals( "1,,3", translate(src) );
-
+        Assertions.assertEquals( "1,,3", translate( src ) );
         src = "[{Counter}],[{Counter showResult=true}],[{Counter}]";
-
-        Assertions.assertEquals( "1,2,3", translate(src) );
+        Assertions.assertEquals( "1,2,3", translate( src ) );
     }
 
 }

Reply via email to