You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by fl...@apache.org on 2012/10/28 23:07:56 UTC
svn commit: r1403108 - in /incubator/jspwiki/trunk: ChangeLog
src/org/apache/wiki/Release.java
src/org/apache/wiki/plugin/PageViewPlugin.java
tests/org/apache/wiki/plugin/PageViewPluginTest.java
Author: florianh
Date: Sun Oct 28 22:07:55 2012
New Revision: 1403108
URL: http://svn.apache.org/viewvc?rev=1403108&view=rev
Log:
2.9.0-incubating-14
JSPWIKI-750: PageViewPluginTest is failing very often when using a JDK 7
minor documentation and logging fixes to PageViewPlugin
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/src/org/apache/wiki/Release.java
incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java
incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=1403108&r1=1403107&r2=1403108&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Oct 28 22:07:55 2012
@@ -1,3 +1,11 @@
+2012-10-28 Florian Holeczek (florianh AT apache DOT org)
+
+ * 2.9.0-incubating-14
+
+ * JSPWIKI-750: PageViewPluginTest is failing very often when using a JDK 7
+
+ * minor documentation and logging fixes to PageViewPlugin
+
2012-10-22 Florian Holeczek (florianh AT apache DOT org)
* several small fixes and improvements related to building and licensing stuff
Modified: incubator/jspwiki/trunk/src/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/Release.java?rev=1403108&r1=1403107&r2=1403108&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/Release.java Sun Oct 28 22:07:55 2012
@@ -75,7 +75,7 @@ public final class Release
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "13";
+ public static final String BUILD = "14";
/**
* This is the generic version string you should use
Modified: incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java?rev=1403108&r1=1403107&r2=1403108&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java Sun Oct 28 22:07:55 2012
@@ -58,10 +58,18 @@ import org.apache.oro.text.regex.Pattern
import org.apache.oro.text.regex.Perl5Matcher;
/**
- * Counts the number of times each page has been viewed. Parameters:
- * count=yes|no show=none|count|list entries=max number of list entries
- * min=minimum page count to be listed sort=name|count Default values are
- * show=none and sort=name.
+ * This plugin counts the number of times a page has been viewed.<br/>
+ * Parameters:
+ * <ul>
+ * <li>count=yes|no</li>
+ * <li>show=none|count|list</li>
+ * <li>entries=maximum number of list entries to be returned</li>
+ * <li>min=minimum page count to be listed</li>
+ * <li>max=maximum page count to be listed</li>
+ * <li>sort=name|count</li>
+ * </ul>
+ * Default values:<br/>
+ * <code>show=none sort=name</code>
*
* @since 2.8
*/
@@ -108,7 +116,7 @@ public class PageViewPlugin extends Abst
/** Constant for comma-separated list separator. */
private static final String STR_COMMA = ",";
- /** Constant for no-op glob exression. */
+ /** Constant for no-op glob expression. */
private static final String STR_GLOBSTAR = "*";
/** Constant for file storage. */
@@ -286,7 +294,7 @@ public class PageViewPlugin extends Abst
/**
* Count a page hit, present a pages' counter or output a list of
- * pagecounts.
+ * page counts.
*
* @param context the wiki context
* @param params the plugin parameters
@@ -451,7 +459,7 @@ public class PageViewPlugin extends Abst
Entry entry = (Entry) iter.next();
String name = (String) entry.getKey();
- // check minimum count
+ // check minimum/maximum count
final int value = ((Counter) entry.getValue()).getValue();
boolean use = min <= value && value <= max;
@@ -542,7 +550,7 @@ public class PageViewPlugin extends Abst
}
/**
- * Adjust ofsset skipping whitespace.
+ * Adjust offset skipping whitespace.
*
* @param offset The offset in value to adjust.
* @param value String in which offset points.
@@ -575,24 +583,18 @@ public class PageViewPlugin extends Abst
{
if( m_counters != null && m_storage != null )
{
-
- log.warn( "loadCounters" );
+ log.info( "Loading counters." );
synchronized( this )
{
-
InputStream fis = null;
-
try
{
fis = new FileInputStream( new File( m_workDir, COUNTER_PAGE ) );
-
m_storage.load( fis );
-
}
catch( IOException ioe )
{
- log.error( "loadCounters: Can't load page counter store: " + ioe.getMessage() + " , will create a new one" );
-
+ log.error( "Can't load page counter store: " + ioe.getMessage() + " , will create a new one!" );
}
finally
{
@@ -605,7 +607,7 @@ public class PageViewPlugin extends Abst
}
catch( Exception ignore )
{
- /** ignore */
+ /* ignore */
}
}
@@ -618,9 +620,8 @@ public class PageViewPlugin extends Abst
m_counters.put( (String) entry.getKey(), new Counter( (String) entry.getValue() ) );
}
-
-
- log.info( "loadCounters: counters.size=" + m_counters.size() );
+
+ log.info( "Loaded " + m_counters.size() + " counter values." );
}
}
}
@@ -633,12 +634,10 @@ public class PageViewPlugin extends Abst
{
if( m_counters != null && m_storage != null && m_dirty )
{
+ log.info( "Storing " + m_counters.size() + " counter values." );
- log.info( "storeCounters: counters.size=" + m_counters.size() );
-
synchronized( this )
{
-
OutputStream fos = null;
// Write out the collection of counters
@@ -650,12 +649,10 @@ public class PageViewPlugin extends Abst
fos.flush();
m_dirty = false;
-
}
catch( IOException ioe )
{
- log.error( "storeCounters: Can't store counters: " + ioe.getMessage() );
-
+ log.error( "Couldn't store counters values: " + ioe.getMessage() );
}
finally
{
@@ -668,7 +665,7 @@ public class PageViewPlugin extends Abst
}
catch( Exception ignore )
{
- /** ignore */
+ /* ignore */
}
}
}
@@ -678,7 +675,7 @@ public class PageViewPlugin extends Abst
/**
* Is the given thread still current?
*
- * @return boolean <code>true</code> iff the thread is still the current
+ * @return boolean <code>true</code> if the thread is still the current
* background thread.
* @param thrd
*/
@@ -689,6 +686,7 @@ public class PageViewPlugin extends Abst
}
+
/**
* Counter for page hits collection.
*/
@@ -706,13 +704,12 @@ public class PageViewPlugin extends Abst
}
/**
- * Create and initialise a new counter.
+ * Create and initialize a new counter.
*
* @param value Count value.
*/
public Counter( String value )
{
-
setValue( value );
}
@@ -731,7 +728,6 @@ public class PageViewPlugin extends Abst
*/
public int getValue()
{
-
return m_count;
}
Modified: incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java?rev=1403108&r1=1403107&r2=1403108&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java (original)
+++ incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java Sun Oct 28 22:07:55 2012
@@ -39,6 +39,27 @@ public class PageViewPluginTest extends
PluginManager manager;
+ /*
+ * Constructor is part of a workaround for execution ordering of the tests
+ */
+ public PageViewPluginTest ( String testName )
+ {
+ super( testName );
+ }
+
+ /*
+ * Second part of the workaround for execution ordering of the tests
+ */
+ public static Test suite()
+ {
+ TestSuite ts = new TestSuite();
+ ts.addTest( new PageViewPluginTest( "testShowCountsBasic" ) );
+ ts.addTest( new PageViewPluginTest( "testShowCountsExclude" ) );
+ ts.addTest( new PageViewPluginTest( "testShowCountsSorted" ) );
+ ts.addTest( new PageViewPluginTest( "testShowCountEntries" ) );
+ return ts;
+ }
+
public void setUp() throws Exception
{
props.load( TestEngine.findTestProperties() );
@@ -188,9 +209,4 @@ public class PageViewPluginTest extends
TestEngine.deleteTestPage( "TestPage04" );
}
-
- public static Test suite()
- {
- return new TestSuite( PageViewPluginTest.class );
- }
}