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/11/25 12:10:39 UTC
svn commit: r884040 - in /incubator/jspwiki/trunk: src/WebContent/
src/WebContent/templates/default/ src/java/org/apache/wiki/action/
src/java/org/apache/wiki/tags/ tests/java/org/apache/wiki/action/
Author: ajaquith
Date: Wed Nov 25 11:10:38 2009
New Revision: 884040
URL: http://svn.apache.org/viewvc?rev=884040&view=rev
Log:
Diff.jsp received the Stripes treatment.
Added:
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DiffActionBean.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DiffActionBeanTest.java
Removed:
incubator/jspwiki/trunk/src/WebContent/templates/default/DiffContent.jsp
incubator/jspwiki/trunk/src/WebContent/templates/default/DiffTab.jsp
Modified:
incubator/jspwiki/trunk/src/WebContent/Diff.jsp
incubator/jspwiki/trunk/src/WebContent/templates/default/PageInfoTab.jsp
incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/AllTests.java
Modified: incubator/jspwiki/trunk/src/WebContent/Diff.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Diff.jsp?rev=884040&r1=884039&r2=884040&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/WebContent/Diff.jsp (original)
+++ incubator/jspwiki/trunk/src/WebContent/Diff.jsp Wed Nov 25 11:10:38 2009
@@ -18,80 +18,21 @@
specific language governing permissions and limitations
under the License.
--%>
-<%@ page import="org.apache.wiki.log.Logger" %>
-<%@ page import="org.apache.wiki.log.LoggerFactory" %>
-<%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.util.*" %>
-<%@ page import="org.apache.wiki.tags.InsertDiffTag" %>
-<%@ page import="org.apache.wiki.api.WikiPage" %>
-<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld" prefix="wiki" %>
<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s" %>
-<s:useActionBean beanclass="org.apache.wiki.action.EditActionBean" event="diff" id="wikiActionBean" />
+<s:useActionBean beanclass="org.apache.wiki.action.DiffActionBean" event="diff" executeResolution="true" id="wikiActionBean" />
+<s:layout-render name="${templates['DefaultLayout.jsp']}">
-<%!
- Logger log = LoggerFactory.getLogger("JSPWiki");
-%>
+ <s:layout-component name="content">
+ <wiki:NoSuchPage>
+ <fmt:message key="common.nopage">
+ <fmt:param><wiki:EditLink><fmt:message key="common.createit" /></wiki:EditLink></fmt:param>
+ </fmt:message>
+ </wiki:NoSuchPage>
+ <wiki:PageExists>
+ <jsp:include page="${templates['PageInfoTab.jsp']}" />
+ </wiki:PageExists>
+ </s:layout-component>
-<%
- WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
- // Create wiki context and check for authorization
- WikiContext wikiContext = wiki.createContext( request, WikiContext.DIFF );
- String pagereq = wikiContext.getPage().getName();
-
- WatchDog w = wiki.getCurrentWatchDog();
- try
- {
- w.enterState("Generating INFO response",60);
-
- // Notused ?
- // String pageurl = wiki.encodeName( pagereq );
-
- // If "r1" is null, then assume current version (= -1)
- // If "r2" is null, then assume the previous version (=current version-1)
-
- // FIXME: There is a set of unnecessary conversions here: InsertDiffTag
- // does the String->int conversion anyway.
-
- WikiPage wikipage = wikiContext.getPage();
-
- String srev1 = request.getParameter("r1");
- String srev2 = request.getParameter("r2");
-
- int ver1 = -1, ver2 = -1;
-
- if( srev1 != null )
- {
- ver1 = Integer.parseInt( srev1 );
- }
-
- if( srev2 != null )
- {
- ver2 = Integer.parseInt( srev2 );
- }
- else
- {
- int lastver = wikipage.getVersion();
-
- if( lastver > 1 )
- {
- ver2 = lastver-1;
- }
- }
-
- pageContext.setAttribute( InsertDiffTag.ATTR_OLDVERSION,
- new Integer(ver1),
- PageContext.REQUEST_SCOPE );
- pageContext.setAttribute( InsertDiffTag.ATTR_NEWVERSION,
- new Integer(ver2),
- PageContext.REQUEST_SCOPE );
-
- // log.debug("Request for page diff for '"+pagereq+"' from "+request.getRemoteAddr()+" by "+request.getRemoteUser()+". R1="+ver1+", R2="+ver2 );
-
- // Set the content type and include the response content
- response.setContentType("text/html; charset="+wiki.getContentEncoding() );
- String contentPage = wiki.getTemplateManager().findJSP( pageContext,
- wikiContext.getTemplate(),
- "ViewTemplate.jsp" );
-%><wiki:Include page="<%=contentPage%>" />
-<% } finally { w.exitState(); } %>
\ No newline at end of file
+</s:layout-render>
Modified: incubator/jspwiki/trunk/src/WebContent/templates/default/PageInfoTab.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/PageInfoTab.jsp?rev=884040&r1=884039&r2=884040&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/WebContent/templates/default/PageInfoTab.jsp (original)
+++ incubator/jspwiki/trunk/src/WebContent/templates/default/PageInfoTab.jsp Wed Nov 25 11:10:38 2009
@@ -150,11 +150,40 @@
<%-- DIFF section --%>
<wiki:CheckRequestContext context='diff'>
- <wiki:Include page="DiffTab.jsp" />
+ <s:form beanclass="org.apache.wiki.action.DiffActionBean" method="get" acceptcharset="UTF-8">
+ <div class="collapsebox" id="diffcontent">
+ <h4>
+ <s:hidden name="page" value="${wikiActionBean.page.name}" />
+ <fmt:message key="diff.difference">
+ <fmt:param>
+ <s:select id="r1" name="r1" value="${wikiActionBean.r1}" onchange="this.form.submit();">
+ <s:options-collection collection="${wikiActionBean.history}" value="version" label="version" />
+ </s:select>
+ </fmt:param>
+ <fmt:param>
+ <s:select id="r2" name="r2" value="${wikiActionBean.r2}" onchange="this.form.submit();">
+ <s:options-collection collection="${wikiActionBean.history}" value="version" label="version" />
+ </s:select>
+ </fmt:param>
+ </fmt:message>
+ </h4>
+
+ <c:if test='${diffprovider eq "ContextualDiffProvider"}'>
+ <div class="diffnote">
+ <a href="#change-1" title="<fmt:message key='diff.gotofirst.title' />" class="diff-nextprev">
+ <fmt:message key="diff.gotofirst" />
+ </a>»»
+ </div>
+ </c:if>
+
+ <div class="diffbody">
+ <wiki:InsertDiff><i><fmt:message key="diff.nodiff" /></i></wiki:InsertDiff>
+ </div>
+ </div>
+ </s:form>
</wiki:CheckRequestContext>
<%-- DIFF section --%>
-
<wiki:CheckVersion mode="first"><fmt:message key="info.noversions" /></wiki:CheckVersion>
<wiki:CheckVersion mode="notfirst">
<%-- if( itemcount > 1 ) { --%>
Added: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DiffActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DiffActionBean.java?rev=884040&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DiffActionBean.java (added)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DiffActionBean.java Wed Nov 25 11:10:38 2009
@@ -0,0 +1,127 @@
+package org.apache.wiki.action;
+
+import java.util.List;
+
+import net.sourceforge.stripes.action.DefaultHandler;
+import net.sourceforge.stripes.action.ForwardResolution;
+import net.sourceforge.stripes.action.HandlesEvent;
+import net.sourceforge.stripes.action.Resolution;
+import net.sourceforge.stripes.validation.Validate;
+
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiProvider;
+import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.auth.permissions.PagePermission;
+import org.apache.wiki.content.PageNotFoundException;
+import org.apache.wiki.providers.ProviderException;
+import org.apache.wiki.ui.stripes.HandlerPermission;
+import org.apache.wiki.ui.stripes.WikiRequestContext;
+
+/**
+ * ActionBean that compares two versions of the same page. If "r1" is null, then
+ * assume current version (= -1). If "r2" is null, then assume the previous
+ * version (=current version-1)
+ */
+public class DiffActionBean extends AbstractPageActionBean
+{
+ private int m_r1 = WikiProvider.LATEST_VERSION;
+
+ private int m_r2 = WikiProvider.LATEST_VERSION;
+
+ private String m_diffProvider = null;
+
+ private List<WikiPage> m_history = null;
+
+ /**
+ * Returns the newer version to compare.
+ *
+ * @return the newer version
+ */
+ public int getR2()
+ {
+ return m_r2;
+ }
+
+ /**
+ * Returns the old version to compare.
+ *
+ * @return the old version
+ */
+ public int getR1()
+ {
+ return m_r1;
+ }
+
+ /**
+ * Sets the old version to compare. If not supplied, defaults to the current
+ * version.
+ *
+ * @param r1 the old version
+ */
+ @Validate( required = false )
+ public void setR1( int r1 )
+ {
+ m_r1 = r1;
+ }
+
+ /**
+ * Sets the newer version to compare. If not supplied, defaults to the
+ * previous version.
+ *
+ * @param r2 the new version
+ */
+ @Validate( required = false )
+ public void setR2( int r2 )
+ {
+ m_r2 = r2;
+ }
+
+ /**
+ * Returns the DiffProvider used by this wiki.
+ * @return the diff provider
+ */
+ public String getDiffProvider()
+ {
+ return m_diffProvider;
+ }
+
+ /**
+ * Returns the page history.
+ * @return the history
+ */
+ public List<WikiPage> getHistory()
+ {
+ return m_history;
+ }
+
+ /**
+ * Event that diffs the current state of the edited page and forwards the
+ * user to the diff JSP.
+ *
+ * @return a forward resolution back to the preview page.
+ */
+ @DefaultHandler
+ @HandlesEvent( "diff" )
+ @HandlerPermission( permissionClass = PagePermission.class, target = "${page.path}", actions = PagePermission.VIEW_ACTION )
+ @WikiRequestContext( "diff" )
+ public Resolution diff() throws ProviderException, PageNotFoundException
+ {
+ // Set R2 if default not set
+ if( getR2() == WikiProvider.LATEST_VERSION )
+ {
+ int currentVersion = getPage().getVersion();
+ if( currentVersion > 1 )
+ {
+ setR2( currentVersion - 1 );
+ }
+ }
+
+ // Set the page history collection and DiffProvider
+ WikiContext c = getContext();
+ m_history = c.getEngine().getVersionHistory( getPage().getName() );
+ m_diffProvider = c.getEngine().getVariable( c, "jspwiki.diffProvider" );
+
+ return new ForwardResolution( "/Diff.jsp" );
+ }
+
+}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java?rev=884040&r1=884039&r2=884040&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java Wed Nov 25 11:10:38 2009
@@ -23,10 +23,11 @@
import java.io.IOException;
import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.PageContext;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
+import org.apache.wiki.action.DiffActionBean;
+import org.apache.wiki.api.WikiException;
import org.apache.wiki.content.PageNotFoundException;
import org.apache.wiki.providers.ProviderException;
@@ -47,10 +48,12 @@
{
private static final long serialVersionUID = 0L;
- /** Attribute which is used to store the old page content to the Page Context */
+ /** Attribute which is used to store the old page content to the Page Context
+ * @deprecated Use {@link org.apache.wiki.action.DiffActionBean#getR1()} instead. */
public static final String ATTR_OLDVERSION = "olddiff";
- /** Attribute which is used to store the new page content to the Page Context */
+ /** Attribute which is used to store the new page content to the Page Context
+ * @deprecated Use {@link org.apache.wiki.action.DiffActionBean#getR2()} instead. */
public static final String ATTR_NEWVERSION = "newdiff";
protected String m_pageName;
@@ -82,8 +85,16 @@
/** {@inheritDoc} */
public final int doWikiStartTag()
- throws IOException
+ throws IOException, WikiException
{
+ // Get old and new page version
+ if ( m_wikiActionBean == null || !( m_wikiActionBean instanceof DiffActionBean ) )
+ {
+ throw new WikiException( "No DiffActionBean found!" );
+ }
+ int vernew = ((DiffActionBean)m_wikiActionBean).getR2();
+ int verold = ((DiffActionBean)m_wikiActionBean).getR1();
+
WikiEngine engine = m_wikiContext.getEngine();
WikiContext ctx;
@@ -108,20 +119,13 @@
}
}
- Integer vernew = (Integer) pageContext.getAttribute( ATTR_NEWVERSION,
- PageContext.REQUEST_SCOPE );
- Integer verold = (Integer) pageContext.getAttribute( ATTR_OLDVERSION,
- PageContext.REQUEST_SCOPE );
-
log.info("Request diff between version "+verold+" and "+vernew);
if( ctx.getPage() != null )
{
JspWriter out = pageContext.getOut();
- String diff = engine.getDiff( ctx,
- vernew.intValue(),
- verold.intValue() );
+ String diff = engine.getDiff( ctx, vernew, verold );
if( diff.length() == 0 )
{
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/AllTests.java?rev=884040&r1=884039&r2=884040&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/AllTests.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/AllTests.java Wed Nov 25 11:10:38 2009
@@ -37,6 +37,7 @@
TestSuite suite = new TestSuite("ActionBean tests");
suite.addTest( DeleteActionBeanTest.suite() );
+ suite.addTest( DiffActionBeanTest.suite() );
suite.addTest( EditActionBeanTest.suite() );
suite.addTest( GroupActionBeanTest.suite() );
suite.addTest( LoginActionBeanTest.suite() );
Added: incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DiffActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DiffActionBeanTest.java?rev=884040&view=auto
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DiffActionBeanTest.java (added)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/DiffActionBeanTest.java Wed Nov 25 11:10:38 2009
@@ -0,0 +1,251 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.wiki.action;
+
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import net.sourceforge.stripes.mock.MockRoundtrip;
+import net.sourceforge.stripes.validation.ValidationErrors;
+
+import org.apache.wiki.TestEngine;
+import org.apache.wiki.WikiProvider;
+import org.apache.wiki.api.WikiPage;
+
+public class DiffActionBeanTest extends TestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite( DiffActionBeanTest.class );
+ }
+
+ TestEngine m_engine;
+
+ public void setUp()
+ {
+ // Start the WikiEngine, and stash reference
+ Properties props = new Properties();
+ try
+ {
+ props.load( TestEngine.findTestProperties() );
+ m_engine = new TestEngine( props );
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException( "Could not set up TestEngine: " + e.getMessage() );
+ }
+ }
+
+ public void tearDown()
+ {
+ m_engine.shutdown();
+ }
+
+ public void testDiffProvider() throws Exception
+ {
+ // Try diffing without specifying a page
+ MockRoundtrip trip = m_engine.guestTrip( "/Diff.action" );
+ trip.execute( "diff" );
+ DiffActionBean bean = trip.getActionBean( DiffActionBean.class );
+ assertEquals( "ContextualDiffProvider", bean.getDiffProvider() );
+ }
+
+ public void testHistory() throws Exception
+ {
+ String pageName = "DiffActionBeanTest" + System.currentTimeMillis();
+
+ // Save 3 versions
+ m_engine.saveText( pageName, "This is version one." );
+ WikiPage page = m_engine.getPage( pageName );
+ assertNotNull( "Did not save page " + pageName + "!", page );
+ m_engine.saveText( pageName, "This is version two!" );
+ m_engine.saveText( pageName, "This is version three..." );
+
+ // Diff with no versions
+ MockRoundtrip trip = m_engine.guestTrip( "/Diff.action" );
+ trip.setParameter( "page", pageName );
+ trip.execute( "diff" );
+
+ // The page history should be set
+ DiffActionBean bean = trip.getActionBean( DiffActionBean.class );
+ List<WikiPage> history = bean.getHistory();
+ assertNotNull( history );
+ assertEquals( 3, history.size() );
+
+ // Verify that the history was retrieved in the right order
+ assertEquals( 1, history.get( 0 ).getVersion() );
+ assertEquals( 2, history.get( 1 ).getVersion() );
+ assertEquals( 3, history.get( 2 ).getVersion() );
+ assertEquals( "This is version one.\r\n", history.get( 0 ).getContentAsString() );
+ assertEquals( "This is version two!\r\n", history.get( 1 ).getContentAsString() );
+ assertEquals( "This is version three...\r\n", history.get( 2 ).getContentAsString() );
+
+ // Delete the test page
+ m_engine.deletePage( pageName );
+ }
+
+ public void testNoParameters() throws Exception
+ {
+ // Try diffing without specifying a page
+ MockRoundtrip trip = m_engine.guestTrip( "/Diff.action" );
+ trip.execute( "diff" );
+
+ // ...we should NOT see any page bound to the ActionBean
+ DiffActionBean bean = trip.getActionBean( DiffActionBean.class );
+ assertNull( bean.getPage() );
+
+ // ...and the "page" param should be flagged as invalid
+ ValidationErrors errors = trip.getValidationErrors();
+ assertEquals( 1, errors.size() );
+ assertTrue( errors.hasFieldErrors() );
+ assertTrue( errors.containsKey( "page" ) );
+
+ // ...and the destination should be the original display JSP (for
+ // displaying errors)
+ assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+ }
+
+ public void testNoVersionParameters() throws Exception
+ {
+ String pageName = "DiffActionBeanTest" + System.currentTimeMillis();
+
+ // Save 3 versions
+ m_engine.saveText( pageName, "This is version one." );
+ WikiPage page = m_engine.getPage( pageName );
+ assertNotNull( "Did not save page " + pageName + "!", page );
+ m_engine.saveText( pageName, "This is version two!" );
+ m_engine.saveText( pageName, "This is version three..." );
+
+ // Diff without specifying R1 or R2
+ MockRoundtrip trip = m_engine.guestTrip( "/Diff.action" );
+ trip.setParameter( "page", pageName );
+ trip.execute( "diff" );
+
+ // The default versions should be set
+ DiffActionBean bean = trip.getActionBean( DiffActionBean.class );
+ assertEquals( WikiProvider.LATEST_VERSION, bean.getR1() );
+ assertEquals( 2, bean.getR2() );
+
+ // ...and the destination should be Diff.jsp (aka display JSP)
+ assertEquals( "/Diff.jsp", trip.getDestination() );
+
+ // Delete the test page
+ m_engine.deletePage( pageName );
+ }
+
+ public void testR1andR2() throws Exception
+ {
+
+ String pageName = "DiffActionBeanTest" + System.currentTimeMillis();
+
+ // Save 3 versions
+ m_engine.saveText( pageName, "This is version one." );
+ WikiPage page = m_engine.getPage( pageName );
+ assertNotNull( "Did not save page " + pageName + "!", page );
+ m_engine.saveText( pageName, "This is version two!" );
+ m_engine.saveText( pageName, "This is version three..." );
+
+ // Diff with R1 and R2
+ MockRoundtrip trip = m_engine.guestTrip( "/Diff.action" );
+ trip.setParameter( "page", pageName );
+ trip.setParameter( "r1", "1" );
+ trip.setParameter( "r2", "2" );
+ trip.execute( "diff" );
+
+ // ...we should automatically see the test page bound to the ActionBean
+ DiffActionBean bean = trip.getActionBean( DiffActionBean.class );
+ ValidationErrors errors = trip.getValidationErrors();
+ assertEquals( 0, errors.size() );
+ assertEquals( page, bean.getPage() );
+ assertEquals( "This is version three...\r\n", page.getContentAsString() );
+
+ // .. and the correct versions should be set
+ assertEquals( 1, bean.getR1() );
+ assertEquals( 2, bean.getR2() );
+
+ // ...and the destination should be Diff.jsp (aka display JSP)
+ assertEquals( "/Diff.jsp", trip.getDestination() );
+
+ // Delete the test page
+ m_engine.deletePage( pageName );
+ }
+
+ public void testR1Only() throws Exception
+ {
+ String pageName = "DiffActionBeanTest" + System.currentTimeMillis();
+
+ // Save 3 versions
+ m_engine.saveText( pageName, "This is version one." );
+ WikiPage page = m_engine.getPage( pageName );
+ assertNotNull( "Did not save page " + pageName + "!", page );
+ m_engine.saveText( pageName, "This is version two!" );
+ m_engine.saveText( pageName, "This is version three..." );
+
+ // Diff with R1 but not R2
+ MockRoundtrip trip = m_engine.guestTrip( "/Diff.action" );
+ trip.setParameter( "page", pageName );
+ trip.setParameter( "r1", "1" );
+ trip.execute( "diff" );
+
+ // The default R2 should be set
+ DiffActionBean bean = trip.getActionBean( DiffActionBean.class );
+ assertEquals( 1, bean.getR1() );
+ assertEquals( 2, bean.getR2() );
+
+ // ...and the destination should be Diff.jsp (aka display JSP)
+ assertEquals( "/Diff.jsp", trip.getDestination() );
+
+ // Delete the test page
+ m_engine.deletePage( pageName );
+ }
+
+ public void testR2Only() throws Exception
+ {
+ String pageName = "DiffActionBeanTest" + System.currentTimeMillis();
+
+ // Save 3 versions
+ m_engine.saveText( pageName, "This is version one." );
+ WikiPage page = m_engine.getPage( pageName );
+ assertNotNull( "Did not save page " + pageName + "!", page );
+ m_engine.saveText( pageName, "This is version two!" );
+ m_engine.saveText( pageName, "This is version three..." );
+
+ // Diff with R2 but not R1
+ MockRoundtrip trip = m_engine.guestTrip( "/Diff.action" );
+ trip.setParameter( "page", pageName );
+ trip.setParameter( "r2", "1" );
+ trip.execute( "diff" );
+
+ // The default R2 should be set
+ DiffActionBean bean = trip.getActionBean( DiffActionBean.class );
+ assertEquals( WikiProvider.LATEST_VERSION, bean.getR1() );
+ assertEquals( 1, bean.getR2() );
+
+ // ...and the destination should be Diff.jsp (aka display JSP)
+ assertEquals( "/Diff.jsp", trip.getDestination() );
+
+ // Delete the test page
+ m_engine.deletePage( pageName );
+ }
+}