You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2009/10/11 06:53:29 UTC
svn commit: r824023 - in /incubator/jspwiki/trunk: ./ etc/ldap/
src/java/org/apache/wiki/ src/java/org/apache/wiki/action/
src/java/org/apache/wiki/auth/ src/java/org/apache/wiki/auth/login/
src/java/org/apache/wiki/content/ src/java/org/apache/wiki/co...
Author: ajaquith
Date: Sun Oct 11 04:53:28 2009
New Revision: 824023
URL: http://svn.apache.org/viewvc?rev=824023&view=rev
Log:
Many unit test fixes. Minor tweaks to Inspector classes. Implemented ContentManager.pageExists() for versions; the lack of this feature was causing several tests to fail. When LDAP test harness is running, overall test scores are back up to 96%.
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/etc/ldap/README
incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/WikiPrincipal.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/login/AnonymousLoginModule.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/AkismetInspector.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BanListInspector.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BotTrapInspector.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/ChangeRateInspector.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/LinkCountInspector.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/PatternInspector.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/UserInspector.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/SpamInterceptor.java
incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl
incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DeleteActionBeanTest.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/inspect/SpamInspectionFactoryTest.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/SpamInterceptorTest.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Oct 11 04:53:28 2009
@@ -1,3 +1,16 @@
+2009-10-11 Andrew Jaquith <ajaquith AT apache DOT org>
+
+ * 3.0.0-svn-162
+
+ * Many unit test fixes. Minor tweaks to Inspector classes.
+ Implemented ContentManager.pageExists() for versions; the
+ lack of this feature was causing several tests to fail.
+ When LDAP test harness is running, overall test scores
+ are back up to 96%.
+
+ * Comment.jsp receives the Stripes treatment (initial checkin;
+ not fully tested yet).
+
2009-10-09 Juan Pablo Santos <ju...@gmail.com>
* updated es translation (no version bump).
Modified: incubator/jspwiki/trunk/etc/ldap/README
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/ldap/README?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/ldap/README (original)
+++ incubator/jspwiki/trunk/etc/ldap/README Sun Oct 11 04:53:28 2009
@@ -1,26 +1,22 @@
This document describes how to set up OpenLDAP with a sample dataset to support
the LdapAuthorizerTest and LdapLoginModuleTest unit tests. It assumes that OpenLDAP
is installed on your system and that config files are stored in /etc/openldap.
-OpenLDAP runs on most Unix-like systems. Mac OS X 10.5 Leopard has OpenLDAP installed
+OpenLDAP runs on most Unix-like systems. Mac OS X 10.6 Snow Leopard has OpenLDAP installed
out of the box. The out-of-the-box OS X setup was what this document was written
to work with. Your mileage may vary.
First-time setup
-1) copy ldap.conf to /etc/openldap
+1) Test that conf file is ok
+/usr/libexec/slapd -d -1 -f etc/ldap/slapd.conf -Tt -u
-2) copy slapd.conf to /etc/openldap
+2) Start slapd; bind to localhost and run as user 'arj'
+/usr/libexec/slapd -f etc/ldap/slapd.conf -h "ldap://127.0.0.1:4890/" -d -1 -u arj
-3) Test that conf file is ok
-/usr/libexec/slapd -d -1 -f /etc/openldap/slapd.conf -Tt -u
+3) Add user file (connection with password "test")
+ldapadd -x -h 127.0.0.1 -p 4890 -D "cn=Manager,dc=jspwiki,dc=org" -w test -f etc/ldap/test.ldif
-4) Start slapd; bind to localhost and run as user 'arj'
-/usr/libexec/slapd -h "ldap://127.0.0.1:4890/" -d -1 -u arj
-
-5) Add user file (connection with password "test")
-ldapadd -x -h 127.0.0.1 -p 4890 -D "cn=Manager,dc=jspwiki,dc=org" -w test -f test.ldif
-
-6) Verify users were added
-ldapsearch -x -h 127.0.0.1 -p 4890 -b 'dc=jspwiki,dc=org' | grep dn
+4) Verify users were added
+ldapsearch -x -h 127.0.0.1 -p 4890 -D "cn=Manager,dc=jspwiki,dc=org" -w test -b 'dc=jspwiki,dc=org'
ldapsearch -x -h 127.0.0.1 -p 4890 -b 'ou=people,dc=jspwiki,dc=org'
ldapsearch -x -h 127.0.0.1 -p 4890 -b 'ou=roles,dc=jspwiki,dc=org'
ldapsearch -x -h 127.0.0.1 -p 4890 -b 'dc=jspwiki,dc=org' '(objectClass=groupOfUniqueNames)'
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Sun Oct 11 04:53:28 2009
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "161";
+ public static final String BUILD = "162";
/**
* This is the generic version string you should use
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java Sun Oct 11 04:53:28 2009
@@ -22,10 +22,14 @@
package org.apache.wiki.action;
import java.net.URI;
+import java.util.List;
import net.sourceforge.stripes.action.*;
import net.sourceforge.stripes.controller.LifecycleStage;
+import net.sourceforge.stripes.validation.LocalizableError;
import net.sourceforge.stripes.validation.Validate;
+import net.sourceforge.stripes.validation.ValidationError;
+import net.sourceforge.stripes.validation.ValidationErrors;
import org.apache.wiki.WikiEngine;
import org.apache.wiki.api.WikiException;
@@ -39,7 +43,6 @@
/**
* Displays the wiki page a users requested, resolving special page names and
* redirecting if needed.
- *
*/
@UrlBinding( "/Wiki.action" )
public class ViewActionBean extends AbstractPageActionBean
@@ -90,7 +93,7 @@
{
return new ForwardResolution( "/PageInfo.jsp" );
}
-
+
/**
* <p>
* After the binding and validation
@@ -118,12 +121,13 @@
{
WikiEngine engine = getContext().getEngine();
- if ( getPage() == null )
+ if( isSpecialPageView() )
{
- // The page might be null because it's a special page WikiPageTypeConverter
+ // The page might be null because it's a special page
+ // WikiPageTypeConverter
// refused to convert. If so, redirect.
String pageName = getContext().getRequest().getParameter( "page" );
- if ( pageName != null )
+ if( pageName != null )
{
URI uri = getContext().getEngine().getSpecialPageReference( pageName );
if( uri != null )
@@ -164,20 +168,21 @@
return new RedirectResolution( getContext().getViewURL( specialUrl ) );
}
- // Ok, the page exists. If attachment, make sure it's directed to the "info" handler
+ // Ok, the page exists. If attachment, make sure it's directed to the
+ // "info" handler
WikiPage page = getPage();
String handler = getContext().getEventName();
- if ( getPage().isAttachment() && !"info".equals( handler ) )
+ if( getPage().isAttachment() && !"info".equals( handler ) )
{
return new RedirectResolution( ViewActionBean.class, "info" ).addParameter( "page", page.getPath().toString() );
}
-
+
return null;
}
/**
- * {@inheritDoc}. This method overrides the superclass method
- * by disabling validation of the <code>page</code> field.
+ * {@inheritDoc}. This method overrides the superclass method by disabling
+ * validation of the <code>page</code> field.
*/
@Override
@Validate( required = false )
@@ -185,7 +190,7 @@
{
super.setPage( page );
}
-
+
/**
* Sets the name to rename the page to
*
@@ -212,4 +217,33 @@
{
return new ForwardResolution( "/Wiki.jsp" );
}
+
+ /**
+ * Returns {@code true} if the WikiPageTypeConverter, upon converting the
+ * page, determined that the page name parameter actually referred to a
+ * special page.
+ *
+ * @return {@code true} if the {@code page} parameter referred to a special
+ * page; {@code false} otherwise.
+ */
+ private boolean isSpecialPageView()
+ {
+ ValidationErrors errors = getContext().getValidationErrors();
+ List<ValidationError> fieldErrors = errors.get( "page" );
+ if( fieldErrors == null )
+ {
+ return false;
+ }
+ for( ValidationError error : fieldErrors )
+ {
+ if( error instanceof LocalizableError )
+ {
+ if( "edit.specialPage".equals( ((LocalizableError) error).getMessageKey() ) )
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/WikiPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/WikiPrincipal.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/WikiPrincipal.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/WikiPrincipal.java Sun Oct 11 04:53:28 2009
@@ -55,6 +55,9 @@
/** WikiPrincipal type denoting a user's wiki name. */
public static final String WIKI_NAME = "wikiName";
+
+ /** WikiPrincipal type denoting an IP address. */
+ public static final String IP_ADDRESS = "ipAddress";
/** Generic WikiPrincipal of unspecified type. */
public static final String UNSPECIFIED = "unspecified";
@@ -66,7 +69,7 @@
static
{
- VALID_TYPES = new String[] { FULL_NAME, LOGIN_NAME, WIKI_NAME, UNSPECIFIED };
+ VALID_TYPES = new String[] { FULL_NAME, LOGIN_NAME, WIKI_NAME, IP_ADDRESS, UNSPECIFIED };
Arrays.sort( VALID_TYPES );
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/login/AnonymousLoginModule.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/login/AnonymousLoginModule.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/login/AnonymousLoginModule.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/login/AnonymousLoginModule.java Sun Oct 11 04:53:28 2009
@@ -83,7 +83,7 @@
{
m_handler.handle( callbacks );
HttpServletRequest request = hcb.getRequest();
- WikiPrincipal ipAddr = new WikiPrincipal( request.getRemoteAddr() );
+ WikiPrincipal ipAddr = new WikiPrincipal( request.getRemoteAddr(), WikiPrincipal.IP_ADDRESS );
if ( log.isDebugEnabled() )
{
HttpSession session = request.getSession( false );
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java Sun Oct 11 04:53:28 2009
@@ -577,7 +577,7 @@
QueryManager mgr = session.getWorkspace().getQueryManager();
- Query q = mgr.createQuery( "/jcr:root/"+JCR_PAGES_NODE+((space != null) ? ("/"+space) : "")+"/*", Query.XPATH );
+ Query q = mgr.createQuery( "/jcr:root/"+JCR_PAGES_NODE+((space != null) ? ("/"+space) : "/*")+"/*", Query.XPATH );
QueryResult qr = q.execute();
@@ -641,7 +641,7 @@
*/
private boolean isSpaceRoot(Node nd) throws RepositoryException
{
- return nd.getPath().startsWith( "/"+JCR_PAGES_NODE ) && nd.getDepth() == 2;
+ return nd != null && nd.getPath().startsWith( "/"+JCR_PAGES_NODE ) && nd.getDepth() == 2;
}
/**
@@ -920,6 +920,22 @@
try
{
node = getJCRNode( jcrPath );
+ if ( node == null )
+ {
+ return false;
+ }
+
+ if ( version == WikiProvider.LATEST_VERSION )
+ {
+ return !node.isNew();
+ }
+
+ String v = Integer.toString( version );
+ if ( node.hasNode( WIKI_VERSIONS ) )
+ {
+ Node versions = node.getNode( WIKI_VERSIONS );
+ return versions.hasNode( v ) && !versions.getNode( v ).isNew();
+ }
}
catch ( PathNotFoundException e )
{
@@ -930,9 +946,7 @@
{
throw new ProviderException( "Unable to check for page existence", e );
}
-
- // Node "exists" only if it's been saved already.
- return !node.isNew();
+ return false;
}
/**
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/AkismetInspector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/AkismetInspector.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/AkismetInspector.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/AkismetInspector.java Sun Oct 11 04:53:28 2009
@@ -33,6 +33,15 @@
m_akismetAPIKey = TextUtil.getStringProperty( config.getProperties(), PROP_AKISMET_API_KEY, m_akismetAPIKey );
}
+ /**
+ * Returns {@link Finding.Result#FAILED} if Akismet determines the change is
+ * spam; {@code null} otherwise.
+ * @param inspection the current Inspection
+ * @param content the content that is being inspected
+ * @param change the subset of the content that represents the added or
+ * deleted text since the last change
+ * @return {@link Finding.Result#FAILED} if the test fails; {@code null} otherwise
+ */
public Finding[] inspect( Inspection inspection, String content, Change change )
{
WikiContext context = inspection.getContext();
@@ -91,6 +100,6 @@
return new Finding[] { new Finding( Topic.SPAM, Finding.Result.FAILED, "You look like a spammer to me. (Incident code "
+ inspection.getUid() + ")" ) };
}
- return new Finding[] { new Finding( Topic.SPAM, Finding.Result.PASSED, "Akismet does not think the change is spam." ) };
+ return null;
}
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BanListInspector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BanListInspector.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BanListInspector.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BanListInspector.java Sun Oct 11 04:53:28 2009
@@ -19,6 +19,15 @@
{
}
+ /**
+ * Returns {@link Finding.Result#FAILED} if the IP address is banned;
+ * {@code null} otherwise.
+ * @param inspection the current Inspection
+ * @param content the content that is being inspected
+ * @param change the subset of the content that represents the added or
+ * deleted text since the last change
+ * @return {@link Finding.Result#FAILED} if the test fails; {@code null} otherwise
+ */
public Finding[] inspect( Inspection inspection, String content, Change change )
{
ReputationManager banList = inspection.getPlan().getReputationManager();
@@ -35,6 +44,6 @@
+ " seconds of ban left)" ) };
}
}
- return new Finding[] { new Finding( Topic.SPAM, Finding.Result.PASSED, "IP address is ok." ) };
+ return null;
}
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BotTrapInspector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BotTrapInspector.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BotTrapInspector.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/BotTrapInspector.java Sun Oct 11 04:53:28 2009
@@ -28,6 +28,15 @@
{
}
+ /**
+ * Returns {@link Finding.Result#FAILED} if any of the spam parameters are invalid;
+ * {@code null} otherwise.
+ * @param inspection the current Inspection
+ * @param content the content that is being inspected
+ * @param change the subset of the content that represents the added or
+ * deleted text since the last change
+ * @return {@link Finding.Result#FAILED} if the test fails; {@code null} otherwise
+ */
public Finding[] inspect( Inspection inspection, String content, Change change )
{
WikiContext context = inspection.getContext();
@@ -73,6 +82,6 @@
return new Finding[] { new Finding( Topic.SPAM, Finding.Result.FAILED, "Bot detected: missing UTF-8 parameter." ) };
}
- return new Finding[] { new Finding( Topic.SPAM, Finding.Result.PASSED, "Spam parameters ok." ) };
+ return null;
}
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/ChangeRateInspector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/ChangeRateInspector.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/ChangeRateInspector.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/ChangeRateInspector.java Sun Oct 11 04:53:28 2009
@@ -49,6 +49,15 @@
+ " mins, max page changes/m inute: " + m_limitSinglePageChanges );
}
+ /**
+ * Returns {@link Finding.Result#FAILED} if the user has recently submitted too many
+ * aggregate or identical changes; {@code null} otherwise.
+ * @param inspection the current Inspection
+ * @param content the content that is being inspected
+ * @param change the subset of the content that represents the added or
+ * deleted text since the last change
+ * @return {@link Finding.Result#FAILED} if the test fails; {@code null} otherwise
+ */
public Finding[] inspect( Inspection inspection, String content, Change change )
{
HttpServletRequest req = inspection.getContext().getHttpRequest();
@@ -97,7 +106,7 @@
return new Finding[] { new Finding( Topic.SPAM, Finding.Result.FAILED, "You look like a spammer to me. (Incident code "
+ inspection.getUid() + ")" ) };
}
- return new Finding[] { new Finding( Topic.SPAM, Finding.Result.PASSED, "Passed change-rate and change-similarity tests." ) };
+ return null;
}
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/LinkCountInspector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/LinkCountInspector.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/LinkCountInspector.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/LinkCountInspector.java Sun Oct 11 04:53:28 2009
@@ -52,6 +52,15 @@
m_maxUrls = TextUtil.getIntegerProperty( config.getProperties(), PROP_MAXURLS, m_maxUrls );
}
+ /**
+ * Returns {@link Finding.Result#FAILED} if the proposed change contains too many
+ * links; {@code null} otherwise.
+ * @param inspection the current Inspection
+ * @param content the content that is being inspected
+ * @param change the subset of the content that represents the added or
+ * deleted text since the last change
+ * @return {@link Finding.Result#FAILED} if the test fails; {@code null} otherwise
+ */
public Finding[] inspect( Inspection inspection, String content, Change change )
{
// Calculate the number of links in the addition.
@@ -73,7 +82,7 @@
return new Finding[] { new Finding( Topic.SPAM, Finding.Result.FAILED, "You look like a spammer to me. (Incident code "
+ inspection.getUid() + ")" ) };
}
- return new Finding[] { new Finding( Topic.SPAM, Finding.Result.PASSED, "Change does not have too many links." ) };
+ return null;
}
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/PatternInspector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/PatternInspector.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/PatternInspector.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/PatternInspector.java Sun Oct 11 04:53:28 2009
@@ -53,14 +53,13 @@
}
/**
- * Checks that the changed content does not contain any text that matches
- * patterns on the spam blacklist.
- *
+ * Returns {@link Finding.Result#FAILED} if any contents are contained on
+ * the banned-word pattern blacklist; {@code null} otherwise.
* @param inspection the current Inspection
- * @param content the content that
+ * @param content the content that is being inspected
* @param change the subset of the content that represents the added or
* deleted text since the last change
- * @throws InspectionInterruptedException if the inspection must be halted
+ * @return {@link Finding.Result#FAILED} if the test fails; {@code null} otherwise
*/
public Finding[] inspect( Inspection inspection, String content, Change change )
{
@@ -72,7 +71,7 @@
//
if( m_spamPatterns == null || context.getPage().getName().equals( m_forbiddenWordsPage ) )
{
- return new Finding[] { new Finding( Topic.SPAM, Finding.Result.PASSED, "No bad patterns defined." ) };
+ return null;
}
String ch = change.toString();
@@ -93,7 +92,7 @@
+ inspection.getUid() + ")" ) };
}
}
- return new Finding[] { new Finding( Topic.SPAM, Finding.Result.PASSED, "No bad patterns in the proposed change." ) };
+ return null;
}
/**
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/UserInspector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/UserInspector.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/UserInspector.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/inspect/UserInspector.java Sun Oct 11 04:53:28 2009
@@ -33,6 +33,11 @@
* ignore authenticated users, this method returns
* {@link Finding.Result#PASSED}. Otherwise, the method returns {@code null}
* but does not affect the score in any way.
+ * @param inspection the current Inspection
+ * @param content the content that is being inspected
+ * @param change the subset of the content that represents the added or
+ * deleted text since the last change
+ * @return {@link Finding.Result#FAILED} if the test fails; {@code null} otherwise
*/
public Finding[] inspect( Inspection inspection, String content, Change change )
{
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/SpamInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/SpamInterceptor.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/SpamInterceptor.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/SpamInterceptor.java Sun Oct 11 04:53:28 2009
@@ -48,7 +48,7 @@
* event handler resolution, and just after parameter binding, but before any
* other custom validation routines have run.
*/
-@Intercepts( { LifecycleStage.HandlerResolution } )
+@Intercepts( { LifecycleStage.CustomValidation } )
public class SpamInterceptor implements Interceptor
{
/**
@@ -57,9 +57,10 @@
* creates a new {@link Inspection} for each ActionBean parameter indicated
* by the annotation. The {@link InspectionPlan} for the Inspection is
* obtained by calling
- * {@link SpamInspectionFactory#getInspectionPlan(WikiEngine, java.util.Properties)}
- * . If any of the modifications are determined to be spam, a Stripes
+ * {@link SpamInspectionFactory#getInspectionPlan(WikiEngine, java.util.Properties)}.
+ * If any of the modifications are determined to be spam, a Stripes
* {@link ValidationError} is added to the ActionBeanContext.
+ * @return always returns {@code null}
*/
public Resolution intercept( ExecutionContext context ) throws Exception
{
@@ -140,10 +141,11 @@
PropertyExpressionEvaluation evaluation = new PropertyExpressionEvaluation( propExpression, actionBean );
Object value = evaluation.getValue();
{
- if( value != null )
+ if ( value == null )
{
- map.put( beanProperty, value );
+ value = "";
}
+ map.put( beanProperty, value );
}
}
catch( NoSuchPropertyException e )
Modified: incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl (original)
+++ incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl Sun Oct 11 04:53:28 2009
@@ -1,4 +1,4 @@
-#
+`#
# JSPWiki - a JSP-based WikiWiki clone.
#
# Licensed to the Apache Software Foundation (ASF) under one
@@ -139,3 +139,12 @@
admin.passwordHash={SSHA}JtQ3xFdBNDuYw5R8u8nhsg5xqsUpbiZhvOoisQ==
jspwiki.keychainPassword=Ga5ZrVe859WUPqG8
+# Spam inspector weights
+inspectorWeight.spam.org.apache.wiki.content.inspect.AkismetInspector=0.0
+inspectorWeight.spam.org.apache.wiki.content.inspect.BanListInspector=1.0
+inspectorWeight.spam.org.apache.wiki.content.inspect.BotTrapInspector=1.0
+inspectorWeight.spam.org.apache.wiki.content.inspect.ChangeRateInspector=1.0
+inspectorWeight.spam.org.apache.wiki.content.inspect.LinkCountInspector=1.0
+inspectorWeight.spam.org.apache.wiki.content.inspect.PatternInspector=1.0
+inspectorWeight.spam.org.apache.wiki.content.inspect.UserInspector=0.0
+spamScoreLimit=-0.5
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DeleteActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DeleteActionBeanTest.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DeleteActionBeanTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DeleteActionBeanTest.java Sun Oct 11 04:53:28 2009
@@ -29,6 +29,7 @@
import net.sourceforge.stripes.validation.ValidationErrors;
import org.apache.wiki.TestEngine;
+import org.apache.wiki.WikiProvider;
import org.apache.wiki.api.WikiPage;
import org.apache.wiki.auth.Users;
@@ -43,6 +44,7 @@
try
{
TestEngine.emptyWorkDir();
+ props.load( TestEngine.findTestProperties() );
m_engine = new TestEngine( props );
}
catch( Exception e )
@@ -162,8 +164,8 @@
assertEquals( 0, errors.size() );
// Verify that there is only one version left
+ assertTrue( m_engine.pageExists( "Test", WikiProvider.LATEST_VERSION ) );
assertFalse( m_engine.pageExists( "Test", 1 ) );
- assertTrue( m_engine.pageExists( "Test", 2 ) );
}
public void testValidation() throws Exception
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java Sun Oct 11 04:53:28 2009
@@ -25,6 +25,7 @@
import org.apache.wiki.TestEngine;
import org.apache.wiki.action.ViewActionBean;
import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.ContentManager;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -105,7 +106,8 @@
// ...we should get a dummy page for the 'page' property
ViewActionBean bean = trip.getActionBean(ViewActionBean.class);
- assertNull( bean.getPage() );
+ assertNotNull( bean.getPage() );
+ assertEquals( m_engine.getFrontPage( ContentManager.DEFAULT_SPACE ), bean.getPage() );
// ...and the destination should be Search.jsp
assertEquals("/Search.jsp", trip.getDestination() );
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/inspect/SpamInspectionFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/inspect/SpamInspectionFactoryTest.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/inspect/SpamInspectionFactoryTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/inspect/SpamInspectionFactoryTest.java Sun Oct 11 04:53:28 2009
@@ -51,7 +51,7 @@
private TestEngine m_engine;
- private static final float PERFECT_SCORE = 62f;
+ private static final float PERFECT_SCORE = 0f;
public SpamInspectionFactoryTest( String s )
{
@@ -92,7 +92,7 @@
// Running the inspection should cause the BanListInspector to fail
String newText = "Sample text";
inspection.inspect( newText, null );
- assertEquals( PERFECT_SCORE - 2 * 2f, inspection.getScore( Topic.SPAM ) );
+ assertEquals( -2f, inspection.getScore( Topic.SPAM ) );
}
/**
@@ -124,7 +124,7 @@
inspection.inspect( newText, null );
}
// Our change-rate check should fail
- assertEquals( PERFECT_SCORE - 2 * 4f, inspection.getScore( Topic.SPAM ) );
+ assertEquals( -4f, inspection.getScore( Topic.SPAM ) );
}
/**
@@ -153,7 +153,7 @@
inspection.inspect( newText, null );
// Link-count check should fail
- assertEquals( PERFECT_SCORE - 2 * 8f, inspection.getScore( Topic.SPAM ) );
+ assertEquals( -8f, inspection.getScore( Topic.SPAM ) );
}
/**
@@ -186,7 +186,7 @@
}
inspection.inspect( newText, null );
// Our similarity check should fail
- assertEquals( PERFECT_SCORE - 2 * 4f, inspection.getScore( Topic.SPAM ) );
+ assertEquals( -4f, inspection.getScore( Topic.SPAM ) );
}
/**
@@ -218,14 +218,14 @@
request.getParameterMap().remove( BotTrapInspector.REQ_ENCODING_CHECK );
inspection = createInspection( request );
inspection.inspect( newText, null );
- assertEquals( PERFECT_SCORE - 2 * 16f, inspection.getScore( Topic.SPAM ) );
+ assertEquals( -16f, inspection.getScore( Topic.SPAM ) );
// Removing the encrypted spam param suggests we have a bot
setupSpamParams( request );
request.getParameterMap().remove( BotTrapInspector.REQ_SPAM_PARAM );
inspection = createInspection( request );
inspection.inspect( newText, null );
- assertEquals( PERFECT_SCORE - 2 * 16f, inspection.getScore( Topic.SPAM ) );
+ assertEquals( -16f, inspection.getScore( Topic.SPAM ) );
// Supplying a non-null value for the first (trap) spam param should
// trigger the bot trap
@@ -233,14 +233,14 @@
request.getParameterMap().put( BotTrapInspector.REQ_TRAP_PARAM, new String[] { "botSuppliedValue" } );
inspection = createInspection( request );
inspection.inspect( newText, null );
- assertEquals( PERFECT_SCORE - 2 * 16f, inspection.getScore( Topic.SPAM ) );
+ assertEquals( -16f, inspection.getScore( Topic.SPAM ) );
// Removing the second (token) spam param should trip it also
setupSpamParams( request );
request.getParameterMap().remove( "TOKENA" );
inspection = createInspection( request );
inspection.inspect( newText, null );
- assertEquals( PERFECT_SCORE - 2 * 16f, inspection.getScore( Topic.SPAM ) );
+ assertEquals( -16f, inspection.getScore( Topic.SPAM ) );
// / Re-run the inspection with all parameters intact
setupSpamParams( request );
@@ -265,7 +265,8 @@
public void testGetScoreLimit() throws Exception
{
SpamInspectionFactory.getInspectionPlan( m_engine, m_props );
- assertEquals( SpamInspectionFactory.DEFAULT_SCORE_LIMIT, SpamInspectionFactory.defaultSpamLimit( m_engine ) );
+ // the value in the test properties file
+ assertEquals( -0.5f, SpamInspectionFactory.defaultSpamLimit( m_engine ) );
}
public void testGetWeight() throws Exception
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java Sun Oct 11 04:53:28 2009
@@ -340,12 +340,12 @@
JspParser parser = new JspParser();
JspDocument doc = parser.parse( s );
- // Should result in 14 nodes parsed (7 tags/directives + 7
+ // Should result in 16 nodes parsed (8 tags/directives + 8
// text/whitespace nodes
Node node;
Node attribute;
List<Node> nodes = doc.getNodes();
- assertEquals( 14, nodes.size() );
+ assertEquals( 16, nodes.size() );
int i = 0;
// Test line 1 aka nodes 0+1
@@ -353,11 +353,34 @@
assertEquals( 1, node.getLine() );
assertEquals( 1, node.getColumn() );
assertEquals( 0, node.getStart() );
- assertEquals( 79, node.getEnd() );
+ assertEquals( 867, node.getEnd() );
+ assertEquals( 0, node.getChildren().size() );
+ assertEquals( NodeType.JSP_COMMENT, node.getType() );
+ assertEquals( NodeType.ROOT, node.getParent().getType() );
+ assertEquals( 8, node.getSiblings().size() );
+ i++;
+ node = nodes.get( i );
+ assertEquals( 20, node.getLine() );
+ assertEquals( 5, node.getColumn() );
+ assertEquals( 867, node.getStart() );
+ assertEquals( 868, node.getEnd() );
+ assertEquals( 0, node.getChildren().size() );
+ assertEquals( NodeType.TEXT, node.getType() );
+ assertEquals( NodeType.ROOT, node.getParent().getType() );
+ assertEquals( 8, node.getSiblings().size() );
+ assertEquals( "(TEXT)", node.getName() );
+ i++;
+
+ // Test line 21 aka nodes 2+3
+ node = nodes.get( i );
+ assertEquals( 21, node.getLine() );
+ assertEquals( 1, node.getColumn() );
+ assertEquals( 868, node.getStart() );
+ assertEquals( 947, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.JSP_DIRECTIVE, node.getType() );
assertEquals( NodeType.ROOT, node.getParent().getType() );
- assertEquals( 6, node.getSiblings().size() );
+ assertEquals( 8, node.getSiblings().size() );
assertEquals( "taglib", node.getName() );
assertEquals( 2, ((Tag) node).getAttributes().size() );
attribute = ((Tag) node).getAttributes().get( 0 );
@@ -368,27 +391,27 @@
assertEquals( "stripes", attribute.getValue() );
i++;
node = nodes.get( i );
- assertEquals( 1, node.getLine() );
+ assertEquals( 21, node.getLine() );
assertEquals( 80, node.getColumn() );
- assertEquals( 79, node.getStart() );
- assertEquals( 80, node.getEnd() );
+ assertEquals( 947, node.getStart() );
+ assertEquals( 948, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.TEXT, node.getType() );
assertEquals( NodeType.ROOT, node.getParent().getType() );
- assertEquals( 6, node.getSiblings().size() );
+ assertEquals( 8, node.getSiblings().size() );
assertEquals( "(TEXT)", node.getName() );
i++;
- // Test line 2 aka nodes 2+3
+ // Test line 22 aka nodes 4+5
node = nodes.get( i );
- assertEquals( 2, node.getLine() );
+ assertEquals( 22, node.getLine() );
assertEquals( 1, node.getColumn() );
- assertEquals( 80, node.getStart() );
- assertEquals( 189, node.getEnd() );
+ assertEquals( 948, node.getStart() );
+ assertEquals( 1057, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.EMPTY_ELEMENT_TAG, node.getType() );
assertEquals( NodeType.ROOT, node.getParent().getType() );
- assertEquals( 6, node.getSiblings().size() );
+ assertEquals( 8, node.getSiblings().size() );
assertEquals( "stripes:useActionBean", node.getName() );
assertEquals( 3, ((Tag) node).getAttributes().size() );
attribute = ((Tag) node).getAttributes().get( 0 );
@@ -396,27 +419,27 @@
assertEquals( "org.apache.wiki.action.LoginActionBean", attribute.getValue() );
i++;
node = nodes.get( i );
- assertEquals( 2, node.getLine() );
+ assertEquals( 22, node.getLine() );
assertEquals( 110, node.getColumn() );
- assertEquals( 189, node.getStart() );
- assertEquals( 190, node.getEnd() );
+ assertEquals( 1057, node.getStart() );
+ assertEquals( 1058, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.TEXT, node.getType() );
assertEquals( NodeType.ROOT, node.getParent().getType() );
- assertEquals( 6, node.getSiblings().size() );
+ assertEquals( 8, node.getSiblings().size() );
assertEquals( "(TEXT)", node.getName() );
i++;
- // Test line 3 aka nodes 4+5
+ // Test line 23 aka nodes 6+7
node = nodes.get( i );
- assertEquals( 3, node.getLine() );
+ assertEquals( 23, node.getLine() );
assertEquals( 1, node.getColumn() );
- assertEquals( 190, node.getStart() );
- assertEquals( 257, node.getEnd() );
+ assertEquals( 1058, node.getStart() );
+ assertEquals( 1125, node.getEnd() );
assertEquals( 4, node.getChildren().size() );
assertEquals( NodeType.START_TAG, node.getType() );
assertEquals( NodeType.ROOT, node.getParent().getType() );
- assertEquals( 6, node.getSiblings().size() );
+ assertEquals( 8, node.getSiblings().size() );
assertEquals( "stripes:layout-render", node.getName() );
assertEquals( 1, ((Tag) node).getAttributes().size() );
attribute = ((Tag) node).getAttributes().get( 0 );
@@ -424,10 +447,10 @@
assertEquals( "/templates/default/DefaultLayout.jsp", attribute.getValue() );
i++;
node = nodes.get( i );
- assertEquals( 3, node.getLine() );
+ assertEquals( 23, node.getLine() );
assertEquals( 68, node.getColumn() );
- assertEquals( 257, node.getStart() );
- assertEquals( 260, node.getEnd() );
+ assertEquals( 1125, node.getStart() );
+ assertEquals( 1128, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.TEXT, node.getType() );
assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -435,12 +458,12 @@
assertEquals( "(TEXT)", node.getName() );
i++;
- // Test line 4 aka nodes 6+7
+ // Test line 24 aka nodes 8+9
node = nodes.get( i );
- assertEquals( 4, node.getLine() );
+ assertEquals( 24, node.getLine() );
assertEquals( 3, node.getColumn() );
- assertEquals( 260, node.getStart() );
- assertEquals( 301, node.getEnd() );
+ assertEquals( 1128, node.getStart() );
+ assertEquals( 1169, node.getEnd() );
assertEquals( 3, node.getChildren().size() );
assertEquals( NodeType.START_TAG, node.getType() );
assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -452,10 +475,10 @@
assertEquals( "content", attribute.getValue() );
i++;
node = nodes.get( i );
- assertEquals( 4, node.getLine() );
+ assertEquals( 24, node.getLine() );
assertEquals( 44, node.getColumn() );
- assertEquals( 301, node.getStart() );
- assertEquals( 306, node.getEnd() );
+ assertEquals( 1169, node.getStart() );
+ assertEquals( 1174, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.TEXT, node.getType() );
assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -463,12 +486,12 @@
assertEquals( "(TEXT)", node.getName() );
i++;
- // Test line 5 aka nodes 8+9
+ // Test line 25 aka nodes 10+11
node = nodes.get( i );
- assertEquals( 5, node.getLine() );
+ assertEquals( 25, node.getLine() );
assertEquals( 5, node.getColumn() );
- assertEquals( 306, node.getStart() );
- assertEquals( 364, node.getEnd() );
+ assertEquals( 1174, node.getStart() );
+ assertEquals( 1232, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.EMPTY_ELEMENT_TAG, node.getType() );
assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -480,10 +503,10 @@
assertEquals( "/templates/default/LoginContent.jsp", attribute.getValue() );
i++;
node = nodes.get( i );
- assertEquals( 5, node.getLine() );
+ assertEquals( 25, node.getLine() );
assertEquals( 63, node.getColumn() );
- assertEquals( 364, node.getStart() );
- assertEquals( 367, node.getEnd() );
+ assertEquals( 1232, node.getStart() );
+ assertEquals( 1235, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.TEXT, node.getType() );
assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -491,12 +514,12 @@
assertEquals( "(TEXT)", node.getName() );
i++;
- // Test line 6 aka nodes 10+11
+ // Test line 26 aka nodes 12+13
node = nodes.get( i );
- assertEquals( 6, node.getLine() );
+ assertEquals( 26, node.getLine() );
assertEquals( 3, node.getColumn() );
- assertEquals( 367, node.getStart() );
- assertEquals( 394, node.getEnd() );
+ assertEquals( 1235, node.getStart() );
+ assertEquals( 1262, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.END_TAG, node.getType() );
assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -505,10 +528,10 @@
assertEquals( 0, ((Tag) node).getAttributes().size() );
i++;
node = nodes.get( i );
- assertEquals( 6, node.getLine() );
+ assertEquals( 26, node.getLine() );
assertEquals( 30, node.getColumn() );
- assertEquals( 394, node.getStart() );
- assertEquals( 395, node.getEnd() );
+ assertEquals( 1262, node.getStart() );
+ assertEquals( 1263, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.TEXT, node.getType() );
assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -516,28 +539,28 @@
assertEquals( "(TEXT)", node.getName() );
i++;
- // Test line 7 aka nodes 12+13
+ // Test line 27 aka nodes 14+15
node = nodes.get( i );
- assertEquals( 7, node.getLine() );
+ assertEquals( 27, node.getLine() );
assertEquals( 1, node.getColumn() );
- assertEquals( 395, node.getStart() );
- assertEquals( 419, node.getEnd() );
+ assertEquals( 1263, node.getStart() );
+ assertEquals( 1287, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.END_TAG, node.getType() );
assertEquals( NodeType.ROOT, node.getParent().getType() );
- assertEquals( 6, node.getSiblings().size() );
+ assertEquals( 8, node.getSiblings().size() );
assertEquals( "stripes:layout-render", node.getName() );
assertEquals( 0, ((Tag) node).getAttributes().size() );
i++;
node = nodes.get( i );
- assertEquals( 7, node.getLine() );
+ assertEquals( 27, node.getLine() );
assertEquals( 25, node.getColumn() );
- assertEquals( 419, node.getStart() );
- assertEquals( 420, node.getEnd() );
+ assertEquals( 1287, node.getStart() );
+ assertEquals( 1288, node.getEnd() );
assertEquals( 0, node.getChildren().size() );
assertEquals( NodeType.TEXT, node.getType() );
assertEquals( NodeType.ROOT, node.getParent().getType() );
- assertEquals( 6, node.getSiblings().size() );
+ assertEquals( 8, node.getSiblings().size() );
assertEquals( "(TEXT)", node.getName() );
i++;
}
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/SpamInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/SpamInterceptorTest.java?rev=824023&r1=824022&r2=824023&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/SpamInterceptorTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/SpamInterceptorTest.java Sun Oct 11 04:53:28 2009
@@ -88,10 +88,11 @@
// Verify that we got the ActionBean...
trip.execute( "test" );
TestActionBean bean = trip.getActionBean( TestActionBean.class );
- assertEquals( null, bean.getPage() );
+ assertNull( bean.getPage() );
- // ...but that we failed the token check
- assertEquals( "/Wiki.action?view=&page=SessionExpired", trip.getDestination() );
+ // ...but that we failed the token check (sent back to source page to display errors)
+ assertEquals( bean.getContext().getSourcePage(), trip.getDestination() );
+ assertEquals( 1, trip.getValidationErrors().size() );
}
public void testInvalidTrap() throws Exception
@@ -110,8 +111,9 @@
TestActionBean bean = trip.getActionBean( TestActionBean.class );
assertEquals( null, bean.getPage() );
- // ...but that we failed the token check
- assertEquals( "/Wiki.action?view=&page=SessionExpired", trip.getDestination() );
+ // ...but that we failed the token check (sent back to source page to display errors)
+ assertEquals( bean.getContext().getSourcePage(), trip.getDestination() );
+ assertEquals( 1, trip.getValidationErrors().size() );
}
public void testMissingToken() throws Exception
@@ -129,8 +131,9 @@
TestActionBean bean = trip.getActionBean( TestActionBean.class );
assertEquals( null, bean.getPage() );
- // ...but that we failed the token check
- assertEquals( "/Wiki.action?view=&page=SessionExpired", trip.getDestination() );
+ // ...but that we failed the token check (sent back to source page to display errors)
+ assertEquals( bean.getContext().getSourcePage(), trip.getDestination() );
+ assertEquals( 1, trip.getValidationErrors().size() );
}
public void testMissingTrap() throws Exception
@@ -166,8 +169,9 @@
TestActionBean bean = trip.getActionBean( TestActionBean.class );
assertEquals( null, bean.getPage() );
- // ...but that we failed the token check
- assertEquals( "/Wiki.action?view=&page=SessionExpired", trip.getDestination() );
+ // ...but that we failed the token check (sent back to source page to display errors)
+ assertEquals( bean.getContext().getSourcePage(), trip.getDestination() );
+ assertEquals( 1, trip.getValidationErrors().size() );
}
public void testNoToken() throws Exception
@@ -183,8 +187,9 @@
TestActionBean bean = trip.getActionBean( TestActionBean.class );
assertEquals( null, bean.getPage() );
- // ...but that we failed the token check
- assertEquals( "/Wiki.action?view=&page=SessionExpired", trip.getDestination() );
+ // ...but that we failed the token check (sent back to source page to display errors)
+ assertEquals( bean.getContext().getSourcePage(), trip.getDestination() );
+ assertEquals( 1, trip.getValidationErrors().size() );
}
public void testToken() throws Exception
@@ -192,6 +197,7 @@
// Add the trap + token params
MockRoundtrip trip = m_engine.guestTrip( "/Test.action" );
TestEngine.addSpamProtectParams( trip );
+ trip.addParameter( "text", "test value" );
// Verify that we got the ActionBean...
trip.execute( "test" );