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 2008/08/03 14:28:11 UTC

svn commit: r682151 [3/4] - in /incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki: ./ action/ attachment/ auth/ auth/acl/ auth/authorize/ auth/login/ auth/user/ content/ diff/ parser/ plugin/ providers/ render/ rss/ search/ ...

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java Sun Aug  3 05:28:09 2008
@@ -1,5 +1,7 @@
 package com.ecyrd.jspwiki.auth.user;
+import java.io.Serializable;
 import java.security.Principal;
+import java.util.Map;
 import java.util.Properties;
 
 import org.apache.commons.lang.ArrayUtils;
@@ -12,6 +14,7 @@
 import com.ecyrd.jspwiki.auth.Users;
 import com.ecyrd.jspwiki.auth.WikiPrincipal;
 import com.ecyrd.jspwiki.auth.WikiSecurityException;
+import com.ecyrd.jspwiki.util.CryptoUtil;
 
 
 
@@ -44,7 +47,7 @@
 
       // Create a new user with random name
       String loginName = "TestUser" + String.valueOf( System.currentTimeMillis() );
-      UserProfile profile = new DefaultUserProfile();
+      UserProfile profile = m_db.newProfile();
       profile.setEmail("testuser@testville.com");
       profile.setLoginName( loginName );
       profile.setFullname( "FullName"+loginName );
@@ -61,15 +64,49 @@
       assertEquals( oldUserCount, m_db.getWikiNames().length );
   }
 
+  public void testAttributes() throws Exception
+  {
+      UserProfile profile = m_db.findByEmail( "janne@ecyrd.com" );
+      
+      Map<String,Serializable> attributes = profile.getAttributes();
+      assertEquals( 2, attributes.size() );
+      assertTrue( attributes.containsKey( "attribute1" ) );
+      assertTrue( attributes.containsKey( "attribute2" ) );
+      assertEquals( "some random value", attributes.get( "attribute1" ) );
+      assertEquals( "another value", attributes.get( "attribute2" ) );
+      
+      // Change attribute 1, and add another one
+      attributes.put( "attribute1", "replacement value" );
+      attributes.put( "attribute the third", "some value" );
+      m_db.save( profile );
+      
+      // Retrieve the profile again and make sure our values got saved
+      profile = m_db.findByEmail( "janne@ecyrd.com" );
+      attributes = profile.getAttributes();
+      assertEquals( 3, attributes.size() );
+      assertTrue( attributes.containsKey( "attribute1" ) );
+      assertTrue( attributes.containsKey( "attribute2" ) );
+      assertTrue( attributes.containsKey( "attribute the third" ) );
+      assertEquals( "replacement value", attributes.get( "attribute1" ) );
+      assertEquals( "another value", attributes.get( "attribute2" ) );
+      assertEquals( "some value", attributes.get( "attribute the third" ) );
+      
+      // Restore the original attributes and re-save
+      attributes.put( "attribute1", "some random value" );
+      attributes.remove( "attribute the third" );
+      m_db.save( profile );
+  }
+
   public void testFindByEmail()
   {
     try
     {
         UserProfile profile = m_db.findByEmail("janne@ecyrd.com");
+        assertEquals( -7739839977499061014L, profile.getUid() );
         assertEquals("janne",           profile.getLoginName());
         assertEquals("Janne Jalkanen",  profile.getFullname());
         assertEquals("JanneJalkanen",   profile.getWikiName());
-        assertEquals("{SHA}457b08e825da547c3b77fbc1ff906a1d00a7daee", profile.getPassword());
+        assertEquals("{SSHA}1WFv9OV11pD5IySgVH3sFa2VlCyYjbLrcVT/qw==", profile.getPassword());
         assertEquals("janne@ecyrd.com", profile.getEmail());
     }
     catch (NoSuchPrincipalException e)
@@ -88,15 +125,76 @@
     }
   }
 
+  public void testFindByFullName()
+  {
+      try
+      {
+          UserProfile profile = m_db.findByFullName( "Janne Jalkanen" );
+          assertEquals( -7739839977499061014L, profile.getUid() );
+          assertEquals( "janne", profile.getLoginName() );
+          assertEquals( "Janne Jalkanen", profile.getFullname() );
+          assertEquals( "JanneJalkanen", profile.getWikiName() );
+          assertEquals("{SSHA}1WFv9OV11pD5IySgVH3sFa2VlCyYjbLrcVT/qw==", profile.getPassword());
+          assertEquals( "janne@ecyrd.com", profile.getEmail() );
+          assertNotNull( profile.getCreated() );
+          assertNotNull( profile.getLastModified() );
+      }
+      catch( NoSuchPrincipalException e )
+      {
+          assertTrue( false );
+      }
+      try
+      {
+          m_db.findByEmail( "foo@bar.org" );
+          // We should never get here
+          assertTrue( false );
+      }
+      catch( NoSuchPrincipalException e )
+      {
+          assertTrue( true );
+      }
+  }
+
+  public void testFindByUid()
+  {
+      try
+      {
+          UserProfile profile = m_db.findByUid( -7739839977499061014L );
+          assertEquals( -7739839977499061014L, profile.getUid() );
+          assertEquals( "janne", profile.getLoginName() );
+          assertEquals( "Janne Jalkanen", profile.getFullname() );
+          assertEquals( "JanneJalkanen", profile.getWikiName() );
+          assertEquals("{SSHA}1WFv9OV11pD5IySgVH3sFa2VlCyYjbLrcVT/qw==", profile.getPassword());
+          assertEquals( "janne@ecyrd.com", profile.getEmail() );
+          assertNotNull( profile.getCreated() );
+          assertNotNull( profile.getLastModified() );
+      }
+      catch( NoSuchPrincipalException e )
+      {
+          assertTrue( false );
+      }
+      try
+      {
+          m_db.findByEmail( "foo@bar.org" );
+          // We should never get here
+          assertTrue( false );
+      }
+      catch( NoSuchPrincipalException e )
+      {
+          assertTrue( true );
+      }
+  }
+  
   public void testFindByWikiName()
   {
       try
       {
           UserProfile profile = m_db.findByWikiName("JanneJalkanen");
+          assertEquals( -7739839977499061014L, profile.getUid() );
           assertEquals("janne",           profile.getLoginName());
           assertEquals("Janne Jalkanen",  profile.getFullname());
           assertEquals("JanneJalkanen",   profile.getWikiName());
-          assertEquals("{SHA}457b08e825da547c3b77fbc1ff906a1d00a7daee", profile.getPassword());
+          assertEquals("{SSHA}1WFv9OV11pD5IySgVH3sFa2VlCyYjbLrcVT/qw==", profile.getPassword());
           assertEquals("janne@ecyrd.com", profile.getEmail());
       }
       catch (NoSuchPrincipalException e)
@@ -120,10 +218,11 @@
       try
       {
           UserProfile profile = m_db.findByLoginName("janne");
+          assertEquals( -7739839977499061014L, profile.getUid() );
           assertEquals("janne",           profile.getLoginName());
           assertEquals("Janne Jalkanen",  profile.getFullname());
           assertEquals("JanneJalkanen",   profile.getWikiName());
-          assertEquals("{SHA}457b08e825da547c3b77fbc1ff906a1d00a7daee", profile.getPassword());
+          assertEquals("{SSHA}1WFv9OV11pD5IySgVH3sFa2VlCyYjbLrcVT/qw==", profile.getPassword());
           assertEquals("janne@ecyrd.com", profile.getEmail());
       }
       catch (NoSuchPrincipalException e)
@@ -171,7 +270,7 @@
       }
 
       // Create new user & verify it saved ok
-      UserProfile profile = new DefaultUserProfile();
+      UserProfile profile = m_db.newProfile();
       profile.setEmail( "renamed@example.com" );
       profile.setFullname( "Renamed User" );
       profile.setLoginName( "olduser" );
@@ -210,24 +309,24 @@
       assertEquals( "renamed@example.com", profile.getEmail() );
       assertEquals( "Renamed User", profile.getFullname() );
       assertEquals( "renameduser", profile.getLoginName() );
-      assertEquals( "{SHA}5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", profile.getPassword() );
+      assertTrue( CryptoUtil.verifySaltedPassword( "password".getBytes(), profile.getPassword() ) );
 
       // Delete the user
       m_db.deleteByLoginName( "renameduser" );
   }
 
-  public void testSave()
+  public void testSave() throws Exception
   {
       try
       {
-          UserProfile profile = new DefaultUserProfile();
+          UserProfile profile = m_db.newProfile();
           profile.setEmail("user@example.com");
           profile.setLoginName("user");
           profile.setPassword("password");
           m_db.save(profile);
           profile = m_db.findByEmail("user@example.com");
           assertEquals("user@example.com", profile.getEmail());
-          assertEquals("{SHA}5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", profile.getPassword());
+          assertTrue( CryptoUtil.verifySaltedPassword( "password".getBytes(), profile.getPassword() ) );
       }
       catch (NoSuchPrincipalException e)
       {

Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/AllTests.java?rev=682151&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/AllTests.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/AllTests.java Sun Aug  3 05:28:09 2008
@@ -0,0 +1,23 @@
+
+package com.ecyrd.jspwiki.content;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class AllTests extends TestCase
+{
+    public AllTests( String s )
+    {
+        super( s );
+    }
+
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite("JSPWiki Content Unit Tests");
+
+        suite.addTest( PageRenamerTest.suite() );
+        
+        return suite;
+    }
+}

Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java?rev=682151&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java Sun Aug  3 05:28:09 2008
@@ -0,0 +1,436 @@
+package com.ecyrd.jspwiki.content;
+
+import java.util.Collection;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import com.ecyrd.jspwiki.*;
+import com.ecyrd.jspwiki.attachment.Attachment;
+
+public class PageRenamerTest extends TestCase
+{
+    TestEngine m_engine;
+    
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        
+        Properties props = new Properties();
+        
+        props.load( TestEngine.findTestProperties() );
+
+        props.setProperty( WikiEngine.PROP_MATCHPLURALS, "true" );
+        
+        TestEngine.emptyWorkDir();
+        m_engine = new TestEngine(props);  
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        
+        TestEngine.deleteTestPage("TestPage");
+        TestEngine.deleteTestPage("TestPage2");
+        TestEngine.deleteTestPage("FooTest");
+        TestEngine.deleteTestPage("Test");
+        TestEngine.deleteTestPage("CdauthNew");
+        TestEngine.deleteTestPage("Cdauth");
+
+        TestEngine.emptyWorkDir();
+    }
+
+    public void testSimpleRename()
+        throws Exception
+    {
+        // Count the numberof existing references
+        int refCount = m_engine.getReferenceManager().findCreated().size();
+        
+        m_engine.saveText("TestPage", "the big lazy dog thing" );
+        
+        WikiPage p = m_engine.getPage("TestPage");
+        
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
+        
+        m_engine.renamePage(context, "TestPage", "FooTest", false);
+        
+        WikiPage newpage = m_engine.getPage("FooTest");
+        
+        assertNotNull( "no new page", newpage );
+        assertNull( "old page not gone", m_engine.getPage("TestPage") );
+        
+        // Refmgr
+        
+        Collection refs = m_engine.getReferenceManager().findCreated();
+        
+        assertTrue( "FooTest does not exist", refs.contains("FooTest") );
+        assertFalse( "TestPage exists", refs.contains("TestPage") );
+        assertEquals( "wrong list size", refCount+1, refs.size() );
+    }
+    
+    public void testReferrerChange()
+       throws Exception
+    {
+        m_engine.saveText("TestPage", "foofoo" );
+        m_engine.saveText("TestPage2", "[TestPage]");
+        
+        WikiPage p = m_engine.getPage("TestPage");
+        
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean(null, null,  p );
+        
+        m_engine.renamePage(context, "TestPage", "FooTest", true);
+        
+        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+        
+        assertEquals( "no rename", "[FooTest]", data.trim() );
+        
+        Collection refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        
+        assertNull( "oldpage", refs );
+        
+        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        assertEquals( "new size", 1, refs.size() );
+        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+    }
+
+    public void testReferrerChangeCC()
+        throws Exception
+    {
+        m_engine.saveText("TestPage", "foofoo" );
+        m_engine.saveText("TestPage2", "TestPage");
+     
+        WikiPage p = m_engine.getPage("TestPage");
+     
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
+     
+        m_engine.renamePage(context, "TestPage", "FooTest", true);
+     
+        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+     
+        assertEquals( "no rename", "FooTest", data.trim() );
+        Collection refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        
+        assertNull( "oldpage", refs );
+        
+        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        assertEquals( "new size", 1, refs.size() );
+        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+    }
+    
+    public void testReferrerChangeAnchor()
+        throws Exception
+    {
+        m_engine.saveText("TestPage", "foofoo" );
+        m_engine.saveText("TestPage2", "[TestPage#heading1]");
+     
+        WikiPage p = m_engine.getPage("TestPage");
+     
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
+     
+        m_engine.renamePage(context, "TestPage", "FooTest", true);
+     
+        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+     
+        assertEquals( "no rename", "[FooTest#heading1]", data.trim() );
+        Collection refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        
+        assertNull( "oldpage", refs );
+        
+        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        assertEquals( "new size", 1, refs.size() );
+        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+    }
+    
+    public void testReferrerChangeMultilink()
+        throws Exception
+    {
+        m_engine.saveText("TestPage", "foofoo" );
+        m_engine.saveText("TestPage2", "[TestPage] [TestPage] [linktext|TestPage] TestPage [linktext|TestPage] [TestPage#Anchor] [TestPage] TestPage [TestPage]");
+     
+        WikiPage p = m_engine.getPage("TestPage");
+     
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
+     
+        m_engine.renamePage(context, "TestPage", "FooTest", true);
+     
+        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+     
+        assertEquals( "no rename", 
+                      "[FooTest] [FooTest] [linktext|FooTest] FooTest [linktext|FooTest] [FooTest#Anchor] [FooTest] FooTest [FooTest]", 
+                      data.trim() );
+
+        Collection refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        
+        assertNull( "oldpage", refs );
+        
+        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        assertEquals( "new size", 1, refs.size() );
+        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+    }
+    
+    public void testReferrerNoWikiName()
+        throws Exception
+    {
+        m_engine.saveText("Test","foo");
+        m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
+        
+        WikiPage p = m_engine.getPage("TestPage");
+        
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
+     
+        m_engine.renamePage(context, "Test", "TestPage", true);
+        
+        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION );
+        
+        assertEquals( "wrong data", "[TestPage] [TestPage#anchor] test Test [TestPage] [link|TestPage] [link|TestPage]", data.trim() );
+    }
+
+    public void testAttachmentChange()
+        throws Exception
+    {
+        m_engine.saveText("TestPage", "foofoo" );
+        m_engine.saveText("TestPage2", "[TestPage/foo.txt] [linktext|TestPage/bar.jpg]");
+ 
+        m_engine.addAttachment("TestPage", "foo.txt", "testing".getBytes() );
+        m_engine.addAttachment("TestPage", "bar.jpg", "pr0n".getBytes() );
+        WikiPage p = m_engine.getPage("TestPage");
+ 
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
+ 
+        m_engine.renamePage(context, "TestPage", "FooTest", true);
+ 
+        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+ 
+        assertEquals( "no rename", 
+                      "[FooTest/foo.txt] [linktext|FooTest/bar.jpg]", 
+                      data.trim() );
+
+        Attachment att = m_engine.getAttachmentManager().getAttachmentInfo("FooTest/foo.txt");
+        assertNotNull("footext",att);
+        
+        att = m_engine.getAttachmentManager().getAttachmentInfo("FooTest/bar.jpg");
+        assertNotNull("barjpg",att);
+        
+        att = m_engine.getAttachmentManager().getAttachmentInfo("TestPage/bar.jpg");
+        assertNull("testpage/bar.jpg exists",att);
+        
+        att = m_engine.getAttachmentManager().getAttachmentInfo("TestPage/foo.txt");
+        assertNull("testpage/foo.txt exists",att);
+        
+        Collection refs = m_engine.getReferenceManager().findReferrers("TestPage/bar.jpg");
+    
+        assertNull( "oldpage", refs );
+    
+        refs = m_engine.getReferenceManager().findReferrers( "FooTest/bar.jpg" );
+        assertEquals( "new size", 1, refs.size() );
+        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+    }
+
+    public void testSamePage() throws Exception
+    {
+        m_engine.saveText( "TestPage", "[TestPage]");
+        
+        rename( "TestPage", "FooTest" );
+
+        WikiPage p = m_engine.getPage( "FooTest" );
+        
+        assertNotNull( "no page", p );
+        
+        assertEquals("[FooTest]", m_engine.getText("FooTest").trim() );
+    }
+
+    public void testBrokenLink1() throws Exception
+    {
+        m_engine.saveText( "TestPage", "hubbub");
+        m_engine.saveText( "TestPage2", "[TestPage|]" );
+        
+        rename( "TestPage", "FooTest" );
+
+        WikiPage p = m_engine.getPage( "FooTest" );
+        
+        assertNotNull( "no page", p );
+        
+        // Should be no change
+        assertEquals("[TestPage|]", m_engine.getText("TestPage2").trim() );
+    }
+
+    public void testBrokenLink2() throws Exception
+    {
+        m_engine.saveText( "TestPage", "hubbub");
+        m_engine.saveText( "TestPage2", "[|TestPage]" );
+        
+        WikiPage p;
+        rename( "TestPage", "FooTest" );
+
+        p = m_engine.getPage( "FooTest" );
+        
+        assertNotNull( "no page", p );
+        
+        assertEquals("[|FooTest]", m_engine.getText("TestPage2").trim() );
+    }
+
+    private void rename( String src, String dst ) throws WikiException
+    {
+        WikiPage p = m_engine.getPage(src);
+
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
+        
+        m_engine.renamePage(context, src, dst, true);
+    }
+
+    public void testBug25() throws Exception
+    {
+        String src = "[Cdauth/attach.txt] [link|Cdauth/attach.txt] [cdauth|Cdauth/attach.txt]"+
+                     "[CDauth/attach.txt] [link|CDauth/attach.txt] [cdauth|CDauth/attach.txt]"+
+                     "[cdauth/attach.txt] [link|cdauth/attach.txt] [cdauth|cdauth/attach.txt]";
+        
+        String dst = "[CdauthNew/attach.txt] [link|CdauthNew/attach.txt] [cdauth|CdauthNew/attach.txt]"+
+                     "[CDauth/attach.txt] [link|CDauth/attach.txt] [cdauth|CDauth/attach.txt]"+
+                     "[CdauthNew/attach.txt] [link|CdauthNew/attach.txt] [cdauth|CdauthNew/attach.txt]";
+        
+        m_engine.saveText( "Cdauth", "xxx" );
+        m_engine.saveText( "TestPage", src );
+        
+        m_engine.addAttachment( "Cdauth", "attach.txt", "Puppua".getBytes() );
+        
+        rename( "Cdauth", "CdauthNew" );
+        
+        assertEquals( dst, m_engine.getText("TestPage").trim() );
+    }
+    
+    public void testBug21() throws Exception
+    {
+        String src = "[Link to TestPage2|TestPage2]";
+        
+        m_engine.saveText( "TestPage", src );
+        m_engine.saveText( "TestPage2", "foo" );
+        
+        rename ("TestPage2", "Test");
+        
+        assertEquals( "[Link to Test|Test]", m_engine.getText( "TestPage" ).trim() );
+    }
+
+    public void testExtendedLinks() throws Exception
+    {
+        String src = "[Link to TestPage2|TestPage2|target='_new']";
+        
+        m_engine.saveText( "TestPage", src );
+        m_engine.saveText( "TestPage2", "foo" );
+        
+        rename ("TestPage2", "Test");
+        
+        assertEquals( "[Link to Test|Test|target='_new']", m_engine.getText( "TestPage" ).trim() );
+    }
+    
+    public void testBug85_case1() throws Exception 
+    {
+        // renaming a non-existing page
+        // This fails under 2.5.116, cfr. with http://bugs.jspwiki.org/show_bug.cgi?id=85
+        // m_engine.saveText( "TestPage", "blablahblahbla" );
+        try
+        {
+            rename("TestPage123", "Main8887");
+            rename("Main8887", "TestPage123"); 
+        }
+        catch (NullPointerException npe)
+        {
+            npe.printStackTrace();
+            System.out.println("NPE: Bug 85 caught?");
+            fail();
+        }
+        catch( WikiException e )
+        {
+            // Expected
+        }
+    }
+   
+    public void testBug85_case2() throws Exception 
+    {
+        try
+        {
+            // renaming a non-existing page, but we call m_engine.saveText() before renaming 
+            // this does not fail under 2.5.116
+            m_engine.saveText( "TestPage1234", "blablahblahbla" );
+            rename("TestPage1234", "Main8887");
+            rename("Main8887", "TestPage1234");
+        }
+        catch (NullPointerException npe)
+        {
+            npe.printStackTrace();
+            System.out.println("NPE: Bug 85 caught?");
+            fail();
+        }
+    }
+    
+    public void testBug85_case3() throws Exception 
+    {
+        try
+        {
+            // renaming an existing page
+            // this does not fail under 2.5.116
+            // m_engine.saveText( "Main", "blablahblahbla" );
+            rename("Main", "Main8887");
+            rename("Main8887", "Main");
+        }
+        catch (NullPointerException npe)
+        {
+            npe.printStackTrace();
+            System.out.println("NPE: Bug 85 caught?");
+            fail();
+        }
+        catch( WikiException e )
+        {
+            // Expected
+        }
+    }
+    
+    public void testBug85_case4() throws Exception 
+    {
+        try
+        {
+            // renaming an existing page, and we call m_engine.saveText() before renaming
+            // this does not fail under 2.5.116
+            m_engine.saveText( "Main", "blablahblahbla" );
+            rename("Main", "Main8887");
+            rename("Main8887", "Main");
+        }
+        catch (NullPointerException npe)
+        {
+            npe.printStackTrace();
+            System.out.println("NPE: Bug 85 caught?");
+            fail();
+        }
+    }
+    
+    public void testRenameOfEscapedLinks() throws Exception
+    {
+        String src = "[[Link to TestPage2|TestPage2|target='_new']";
+        
+        m_engine.saveText( "TestPage", src );
+        m_engine.saveText( "TestPage2", "foo" );
+        
+        rename ("TestPage2", "Test");
+        
+        assertEquals( "[[Link to TestPage2|TestPage2|target='_new']", m_engine.getText( "TestPage" ).trim() );
+    }
+
+    public void testRenameOfEscapedLinks2() throws Exception
+    {
+        String src = "~[Link to TestPage2|TestPage2|target='_new']";
+        
+        m_engine.saveText( "TestPage", src );
+        m_engine.saveText( "TestPage2", "foo" );
+        
+        rename ("TestPage2", "Test");
+        
+        assertEquals( "~[Link to TestPage2|TestPage2|target='_new']", m_engine.getText( "TestPage" ).trim() );
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite( PageRenamerTest.class );
+    }
+
+}

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/diff/ContextualDiffProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/diff/ContextualDiffProviderTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/diff/ContextualDiffProviderTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/diff/ContextualDiffProviderTest.java Sun Aug  3 05:28:09 2008
@@ -182,7 +182,7 @@
         PropertyConfigurator.configure(props);
         TestEngine engine = new TestEngine(props);
         
-        WikiContext ctx = engine.getWikiActionBeanFactory().newViewActionBean( new WikiPage(engine,"Dummy") );
+        WikiContext ctx = engine.getWikiActionBeanFactory().newViewActionBean( null, null, new WikiPage(engine,"Dummy") );
         String actualDiff = diff.makeDiffHtml( ctx, oldText, newText);
 
         assertEquals(expectedDiff, actualDiff);

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/CreoleToJSPWikiTranslatorTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/CreoleToJSPWikiTranslatorTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/CreoleToJSPWikiTranslatorTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/CreoleToJSPWikiTranslatorTest.java Sun Aug  3 05:28:09 2008
@@ -1,3 +1,23 @@
+/* 
+    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 com.ecyrd.jspwiki.parser;
 
 import java.io.FileInputStream;
@@ -480,10 +500,10 @@
             "//Comment\r\n" +
             "}]\r\n" +
             "\r\n" +
-            "[http://www.xyz.com/]";
+            "[http://www.xyz.com/]\r\n";
         
-        System.out.println(src);
-        System.out.println(translate(src));
+        //System.out.println(src);
+        //System.out.println(translate(src));
         
         assertEquals(target, translate(src));
     }
@@ -822,6 +842,6 @@
 
     public static Test suite()
     {
-        return new TestSuite( JSPWikiMarkupParserTest.class );
+        return new TestSuite( CreoleToJSPWikiTranslatorTest.class );
     }
 }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/JSPWikiMarkupParserTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/JSPWikiMarkupParserTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/JSPWikiMarkupParserTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/JSPWikiMarkupParserTest.java Sun Aug  3 05:28:09 2008
@@ -24,7 +24,7 @@
 public class JSPWikiMarkupParserTest extends TestCase
 {
     Properties props = new Properties();
-    Vector     created = new Vector();
+    Vector<String>     created = new Vector<String>();
 
     static final String PAGE_NAME = "testpage";
 
@@ -101,8 +101,8 @@
                NoRequiredPropertyException,
                ServletException
     {
-        WikiContext context = e.getWikiActionBeanFactory().newViewActionBean( p );
-        JSPWikiMarkupParser tr = new JSPWikiMarkupParser( context, 
+        WikiContext context = e.getWikiActionBeanFactory().newViewActionBean( null, null, p );
+        JSPWikiMarkupParser tr = new JSPWikiMarkupParser( context,
                                                           new BufferedReader( new StringReader(src)) );
 
         XHTMLRenderer conv = new XHTMLRenderer( context, tr.parse() );
@@ -121,7 +121,7 @@
         props.setProperty( "jspwiki.translatorReader.useRelNofollow", "true" );
         TestEngine testEngine2 = new TestEngine( props );
 
-        WikiContext context = testEngine2.getWikiActionBeanFactory().newViewActionBean(
+        WikiContext context = testEngine2.getWikiActionBeanFactory().newViewActionBean( null, null,
                                                new WikiPage(testEngine2, PAGE_NAME) );
         JSPWikiMarkupParser r = new JSPWikiMarkupParser( context,
                                                          new BufferedReader( new StringReader(src)) );
@@ -539,7 +539,7 @@
 
         String src = "Onko t\u00e4m\u00e4 hyperlinkki: \u00c4itiSy\u00f6\u00d6ljy\u00e4?";
 
-        assertEquals( "Onko t\u00e4m\u00e4 hyperlinkki: <a class=\"wikipage\" href=\"/Wiki.jsp?page=%C3%84itiSy%C3%B6%C3%96ljy%C3%A4\">\u00c4itiSy\u00f6\u00d6ljy\u00e4</a>?",
+        assertEquals( "Onko t\u00e4m\u00e4 hyperlinkki: <a class=\"wikipage\" href=\"/Wiki.jsp?page=%C4itiSy%F6%D6ljy%E4\">\u00c4itiSy\u00f6\u00d6ljy\u00e4</a>?",
                       translate(src) );
     }
 
@@ -657,7 +657,7 @@
         String src = "This should be an [attachment link|Test/TestAtt.txt]";
 
         assertEquals( "This should be an <a class=\"attachment\" href=\"/attach/Test/TestAtt.txt\">attachment link</a>"+
-                      "<a href=\"/PageInfo.jsp?page=Test/TestAtt.txt\"><img src=\"/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
+                      "<a href=\"/PageInfo.jsp?page=Test/TestAtt.txt\" class=\"infolink\"><img src=\"/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
                       translate(src));
     }
 
@@ -680,7 +680,7 @@
         String src = "This should be an [attachment link|Test/TestAtt.txt]";
 
         assertEquals( "This should be an <a class=\"attachment\" href=\"/attach/Test/TestAtt.txt\">attachment link</a>"+
-                      "<a href=\"/PageInfo.jsp?page=Test/TestAtt.txt\"><img src=\"/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
+                      "<a href=\"/PageInfo.jsp?page=Test/TestAtt.txt\" class=\"infolink\"><img src=\"/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
                       translate(testEngine2,src));
     }
 
@@ -703,7 +703,7 @@
         String src = "[Test page/TestAtt.txt]";
 
         assertEquals( "<a class=\"attachment\" href=\"/attach/TestPage/TestAtt.txt\">Test page/TestAtt.txt</a>"+
-                      "<a href=\"/PageInfo.jsp?page=TestPage/TestAtt.txt\"><img src=\"/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
+                      "<a href=\"/PageInfo.jsp?page=TestPage/TestAtt.txt\" class=\"infolink\"><img src=\"/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
                       translate(testEngine2,src));
     }
 
@@ -723,7 +723,7 @@
         String src = "["+testEngine2.beautifyTitle("TestPage/TestAtt.txt")+"]";
 
         assertEquals( "<a class=\"attachment\" href=\"/attach/TestPage/TestAtt.txt\">Test Page/TestAtt.txt</a>"+
-                      "<a href=\"/PageInfo.jsp?page=TestPage/TestAtt.txt\"><img src=\"/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
+                      "<a href=\"/PageInfo.jsp?page=TestPage/TestAtt.txt\" class=\"infolink\"><img src=\"/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
                       translate(testEngine2,src));
     }
 
@@ -889,7 +889,7 @@
 
         newPage("\u00C5\u00E4Test"); // FIXME: Should be capital
 
-        assertEquals("Link <a class=\"wikipage\" href=\"/Wiki.jsp?page=%C3%85%C3%A4Test\">\u00c5\u00e4Test</a>",
+        assertEquals("Link <a class=\"wikipage\" href=\"/Wiki.jsp?page=%C5%E4Test\">\u00c5\u00e4Test</a>",
                      translate(src));
     }
 
@@ -1355,6 +1355,190 @@
                       result );
     }
 
+    /**
+     * <pre>
+     *   * bullet A
+     *   ** bullet A_1
+     *   *# number A_1
+     *   * bullet B
+     * </pre>
+     * 
+     * would come out as:
+     * 
+     * <ul>
+     *   <li>bullet A
+     *     <ul>
+     *       <li>bullet A_1</li>
+     *     </ul>
+     *     <ol>
+     *       <li>number A_1</li>
+     *     </ol>
+     *   </li>
+     *   <li>bullet B</li>
+     * </ul>
+     *  
+     */
+
+    public void testMixedListOnSameLevel()
+    throws Exception
+    {
+        String src="* bullet A\n** bullet A_1\n*# number A_1\n* bullet B\n";
+
+        String result = translate(src);
+
+        // Remove newlines for easier parsing.
+        result = TextUtil.replaceString( result, "\n", "" );
+
+        assertEquals( "<ul>"+
+                      "<li>bullet A"+
+                      "<ul>"+
+                      "<li>bullet A_1</li>"+
+                      "</ul>"+
+                      "<ol>"+
+                      "<li>number A_1</li>"+
+                      "</ol>"+
+                      "</li>"+
+                      "<li>bullet B</li>"+
+                      "</ul>"
+                      ,
+                      result );
+    }
+    /**
+     * <pre>
+     *   * bullet A
+     *   ** bullet A_1
+     *   ## number A_1
+     *   * bullet B
+     * </pre>
+     * 
+     * would come out as:
+     * 
+     * <ul>
+     *   <li>bullet A
+     *     <ul>
+     *       <li>bullet A_1</li>
+     *     </ul>
+     *     <ol>
+     *       <li>number A_1</li>
+     *     </ol>
+     *   </li>
+     *   <li>bullet B</li>
+     * </ul>
+     *  
+     */
+
+    public void testMixedListOnSameLevel2()
+    throws Exception
+    {
+        String src="* bullet A\n** bullet A_1\n## number A_1\n* bullet B\n";
+
+        String result = translate(src);
+
+        // Remove newlines for easier parsing.
+        result = TextUtil.replaceString( result, "\n", "" );
+
+        assertEquals( "<ul>"+
+                      "<li>bullet A"+
+                      "<ul>"+
+                      "<li>bullet A_1</li>"+
+                      "</ul>"+
+                      "<ol>"+
+                      "<li>number A_1</li>"+
+                      "</ol>"+
+                      "</li>"+
+                      "<li>bullet B</li>"+
+                      "</ul>"
+                      ,
+                      result );
+    }
+
+    /**
+     * <pre>
+     *   * bullet 1
+     *   ## number 2
+     *   ** bullet 3
+     *   ## number 4
+     *   * bullet 5 
+     * </pre>
+     * 
+     * would come out as:
+     * 
+     *   <ul>
+     *       <li>bullet 1
+     *           <ol><li>number 2</li></ol>
+     *           <ul><li>bullet 3</li></ul>
+     *           <ol><li>number 4</li></ol>
+     *       </li>
+     *       <li>bullet 5</li>
+     *   </ul>
+     *  
+     */
+
+    public void testMixedListOnSameLevel3()
+    throws Exception
+    {
+        String src="* bullet 1\n## number 2\n** bullet 3\n## number 4\n* bullet 5\n";
+
+        String result = translate(src);
+
+        // Remove newlines for easier parsing.
+        result = TextUtil.replaceString( result, "\n", "" );
+
+        assertEquals( "<ul>"+
+                      "<li>bullet 1"+
+                      "<ol><li>number 2</li></ol>"+
+                      "<ul><li>bullet 3</li></ul>"+
+                      "<ol><li>number 4</li></ol>"+
+                      "</li>"+
+                      "<li>bullet 5</li>"+
+                      "</ul>"
+                      ,
+                      result );
+    }
+    /**
+     * <pre>
+     *   # number 1
+     *   ** bullet 2
+     *   ## number 3
+     *   ** bullet 4
+     *   # number 5 
+     * </pre>
+     * 
+     * would come out as:
+     * 
+     *   <ol>
+     *       <li>number 1
+     *           <ul><li>bullet 2</li></ul>
+     *           <ol><li>number 3</li></ol>
+     *           <ul><li>bullet 4</li></ul>
+     *       </li>
+     *       <li>number 5</li>
+     *   </ol>
+     *  
+     */
+
+    public void testMixedListOnSameLevel4()
+    throws Exception
+    {
+        String src="# number 1\n** bullet 2\n## number 3\n** bullet 4\n# number 5\n";
+
+        String result = translate(src);
+
+        // Remove newlines for easier parsing.
+        result = TextUtil.replaceString( result, "\n", "" );
+
+        assertEquals( "<ol>"+
+                      "<li>number 1"+
+                      "<ul><li>bullet 2</li></ul>"+
+                      "<ol><li>number 3</li></ol>"+
+                      "<ul><li>bullet 4</li></ul>"+
+                      "</li>"+
+                      "<li>number 5</li>"+
+                      "</ol>"
+                      ,
+                      result );
+    }
+
     public void testNestedList()
     throws Exception
     {
@@ -2115,7 +2299,7 @@
     {
         LinkCollector coll = new LinkCollector();
         String src = "[Test]";
-        WikiContext context = testEngine.getWikiActionBeanFactory().newViewActionBean(
+        WikiContext context = testEngine.getWikiActionBeanFactory().newViewActionBean( null, null,
                                                new WikiPage(testEngine,PAGE_NAME) );
 
         MarkupParser p = new JSPWikiMarkupParser( context,
@@ -2138,7 +2322,7 @@
         LinkCollector coll = new LinkCollector();
         String src = "["+PAGE_NAME+"/Test.txt]";
 
-        WikiContext context = testEngine.getWikiActionBeanFactory().newViewActionBean(
+        WikiContext context = testEngine.getWikiActionBeanFactory().newViewActionBean( null, null,
                                                new WikiPage(testEngine,PAGE_NAME) );
 
         MarkupParser p = new JSPWikiMarkupParser( context,
@@ -2163,6 +2347,7 @@
 
         try
         {
+            testEngine.saveText( PAGE_NAME, "content" );
             Attachment att = new Attachment( testEngine, PAGE_NAME, "TestAtt.txt" );
             att.setAuthor( "FirstPost" );
             testEngine.getAttachmentManager().storeAttachment( att, testEngine.makeAttachmentFile() );
@@ -2171,7 +2356,7 @@
             LinkCollector coll_others = new LinkCollector();
 
             String src = "[TestAtt.txt]";
-            WikiContext context = testEngine.getWikiActionBeanFactory().newViewActionBean( 
+            WikiContext context = testEngine.getWikiActionBeanFactory().newViewActionBean( null, null,
                                                    new WikiPage(testEngine,PAGE_NAME) );
 
             MarkupParser p = new JSPWikiMarkupParser( context,

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/CounterPluginTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/CounterPluginTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/CounterPluginTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/CounterPluginTest.java Sun Aug  3 05:28:09 2008
@@ -48,7 +48,7 @@
                NoRequiredPropertyException,
                ServletException
     {
-        WikiContext context = testEngine.getWikiActionBeanFactory().newViewActionBean(
+        WikiContext context = testEngine.getWikiActionBeanFactory().newViewActionBean( null, null,
                                                new WikiPage(testEngine, "TestPage") );
         
         MarkupParser p = new JSPWikiMarkupParser( context, new StringReader(src) );
@@ -87,6 +87,41 @@
                       translate(src) );
     }
 
+    public void testIncrement()
+        throws Exception
+    {
+        String src = "[{Counter}], [{Counter increment=9}]";
+
+        assertEquals( "1, 10", translate(src) );
+
+        src = "[{Counter}],[{Counter}], [{Counter increment=-8}]";
+
+        assertEquals( "1,2, -6", translate(src) );
+    }
+
+    public void testIncrement2() throws Exception
+    {
+        String src = "[{Counter start=5}], [{Counter increment=-1}], [{Counter increment=-1}]";
+
+        assertEquals( "5, 4, 3", translate(src) );
+
+        src = "[{Counter}],[{Counter start=11}], [{Counter increment=-8}]";
+
+        assertEquals( "1,11, 3", translate(src) );
+    }
+
+    public void testShow()
+        throws Exception
+    {
+        String src = "[{Counter}],[{Counter showResult=false}],[{Counter}]";
+
+        assertEquals( "1,,3", translate(src) );
+
+        src = "[{Counter}],[{Counter showResult=true}],[{Counter}]";
+
+        assertEquals( "1,2,3", translate(src) );
+    }
+
     public static Test suite()
     {
         return new TestSuite( CounterPluginTest.class );

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/GroupsTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/GroupsTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/GroupsTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/GroupsTest.java Sun Aug  3 05:28:09 2008
@@ -42,10 +42,10 @@
         
         String res = testEngine.getHTML( "Test" );
         
-        assertEquals( "<a href=\"/Group.action?group=Admin\">Admin</a>, " 
-                + "<a href=\"/Group.action?group=Art\">Art</a>, "
-                + "<a href=\"/Group.action?group=Literature\">Literature</a>, "
-                + "<a href=\"/Group.action?group=TV\">TV</a>\n"
+        assertEquals( "<a href=\"/Group.jsp?group=Admin\">Admin</a>, " 
+                + "<a href=\"/Group.jsp?group=Art\">Art</a>, "
+                + "<a href=\"/Group.jsp?group=Literature\">Literature</a>, "
+                + "<a href=\"/Group.jsp?group=TV\">TV</a>\n"
                 , res );
     }
 

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/PluginManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/PluginManagerTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/PluginManagerTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/PluginManagerTest.java Sun Aug  3 05:28:09 2008
@@ -36,7 +36,7 @@
         props.load( TestEngine.findTestProperties() );
 
         engine = new TestEngine(props);
-        context = engine.getWikiActionBeanFactory().newViewActionBean( new WikiPage(engine, "Testpage") );
+        context = engine.getWikiActionBeanFactory().newViewActionBean( null, null, new WikiPage(engine, "Testpage") );
         manager = new PluginManager( engine, props );
     }
 

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/ReferringPagesPluginTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/ReferringPagesPluginTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/ReferringPagesPluginTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/ReferringPagesPluginTest.java Sun Aug  3 05:28:09 2008
@@ -1,6 +1,7 @@
 
 package com.ecyrd.jspwiki.plugin;
 
+import java.text.SimpleDateFormat;
 import java.util.Properties;
 
 import junit.framework.Test;
@@ -40,7 +41,7 @@
         engine.saveText( "Foobar6", "Reference to [TestPage]." );
         engine.saveText( "Foobar7", "Reference to [TestPage]." );
 
-        context = engine.getWikiActionBeanFactory().newViewActionBean( new WikiPage(engine,"TestPage") );
+        context = engine.getWikiActionBeanFactory().newViewActionBean( null, null, new WikiPage(engine,"TestPage") );
         manager = new PluginManager( engine, props );
     }
 
@@ -69,7 +70,7 @@
     public void testSingleReferral()
         throws Exception
     {
-        WikiContext context2 = engine.getWikiActionBeanFactory().newViewActionBean( new WikiPage(engine, "Foobar") );
+        WikiContext context2 = engine.getWikiActionBeanFactory().newViewActionBean( null, null, new WikiPage(engine, "Foobar") );
 
         String res = manager.execute( context2,
                                       "{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=5}");
@@ -83,30 +84,34 @@
     {
         String res = manager.execute( context,
                                       "{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=5}");
-
+    
         int count = 0;
         int index = -1;
-
+    
         // Count the number of hyperlinks.  We could check their
         // correctness as well, though.
-
+    
         while( (index = res.indexOf("<a",index+1)) != -1 )
         {
             count++;
         }
-
-        assertEquals( 5, count );
-
-        String expected = "...and 2 more<br />";
-
-        assertEquals( "End", expected,
-                      res.substring( res.length()-expected.length() ) );
+    
+        // there is one extra "<a" in the result 
+        assertEquals( 5+1, count );
+    
+        String expected = ">...and 2 more</a>";
+        count =0;
+        while( (index = res.indexOf(expected,index+1)) != -1 )
+        {
+            count++;
+        }
+        assertEquals("End", 1, count );
     }
 
     public void testReferenceWidth()
         throws Exception
     {
-        WikiContext context2 = engine.getWikiActionBeanFactory().newViewActionBean( new WikiPage(engine, "Foobar") );
+        WikiContext context2 = engine.getWikiActionBeanFactory().newViewActionBean( null, null, new WikiPage(engine, "Foobar") );
 
         String res = manager.execute( context2,
                                       "{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE maxwidth=5}");
@@ -162,6 +167,38 @@
         assertTrue( "2", res.indexOf("Foobar2") != -1 );
     }
 
+    public void testCount() throws Exception
+    {
+        String result = null;
+        result = manager.execute(context, "{ReferringPagesPlugin show=count}");
+        assertEquals("7",result);
+        
+        result = manager.execute(context, "{ReferringPagesPlugin,exclude='*7',show=count}");
+        assertEquals("6",result);
+        
+        result = manager.execute(context, "{ReferringPagesPlugin,exclude='*7',show=count,showLastModified=true}");
+        String numberResult=result.substring(0,result.indexOf(" "));
+        assertEquals("6",numberResult);
+        
+        String dateString = result.substring(result.indexOf("(")+1,result.indexOf(")"));
+        // the date should be parseable:
+        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss dd-MMM-yyyy zzz");
+        df.parse(dateString);
+
+        // test if the proper exception is thrown:
+        String expectedExceptionString = "showLastModified=true is only valid if show=count is also specified";
+        String exceptionString = null;
+        try
+        {
+            result = manager.execute(context, "{ReferringPagesPlugin,showLastModified=true}");
+        }
+        catch (PluginException pe)
+        {
+            exceptionString = pe.getMessage();
+        }
+
+        assertEquals(expectedExceptionString, exceptionString);
+    }
 
     public static Test suite()
     {

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/TableOfContentsTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/TableOfContentsTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/TableOfContentsTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/TableOfContentsTest.java Sun Aug  3 05:28:09 2008
@@ -7,13 +7,13 @@
 import java.util.Properties;
 
 import com.ecyrd.jspwiki.TestEngine;
+import com.ecyrd.jspwiki.WikiException;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 /**
- *  @author jalkanen
  *
  *  @since 
  */
@@ -217,6 +217,21 @@
         
     }
     
+    public void testSimilarNames() throws WikiException
+    {
+        String src = "[{TableOfContents}]\n\n!Test\n\n!Test\n\n";
+        
+        testEngine.saveText( "Test", src );
+        
+        String res = testEngine.getHTML( "Test" );
+
+        assertTrue( "Final HTML 1", res.indexOf(  "id=\"section-Test-Test\"" ) != -1 );
+        assertTrue( "Final HTML 2", res.indexOf(  "id=\"section-Test-Test-2\"" ) != -1 );
+
+        assertTrue( "First test", res.indexOf( "Wiki.jsp?page=Test#section-Test-Test" ) != -1 );
+        assertTrue( "2nd test",   res.indexOf( "Wiki.jsp?page=Test#section-Test-Test-2" ) != -1 );
+        
+    }
     public static Test suite()
     {
         return new TestSuite( TableOfContentsTest.class );

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/UndefinedPagesPluginTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/UndefinedPagesPluginTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/UndefinedPagesPluginTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/UndefinedPagesPluginTest.java Sun Aug  3 05:28:09 2008
@@ -33,7 +33,7 @@
         engine.saveText( "TestPage", "Reference to [Foobar]." );
         engine.saveText( "Foobar", "Reference to [Foobar 2], [Foobars]" );
 
-        context = engine.getWikiActionBeanFactory().newViewActionBean( new WikiPage(engine, "TestPage") );
+        context = engine.getWikiActionBeanFactory().newViewActionBean( null, null, new WikiPage(engine, "TestPage") );
         manager = new PluginManager( engine, props );
     }
 
@@ -41,7 +41,6 @@
     {
         TestEngine.deleteTestPage( "TestPage" );
         TestEngine.deleteTestPage( "Foobar" );
-        TestEngine.emptyPageDir();
         TestEngine.emptyWorkDir();
     }
 
@@ -58,7 +57,7 @@
     public void testSimpleUndefined()
         throws Exception
     {
-        WikiContext context2 = engine.getWikiActionBeanFactory().newViewActionBean( new WikiPage(engine, "Foobar") );
+        WikiContext context2 = engine.getWikiActionBeanFactory().newViewActionBean( null, null, new WikiPage(engine, "Foobar") );
 
         String res = manager.execute( context2,
                                       "{INSERT com.ecyrd.jspwiki.plugin.UndefinedPagesPlugin");
@@ -68,6 +67,27 @@
         assertEquals( wikitize(exp), res );
     }
 
+    public void testCount() throws Exception
+    {
+        String result = null;
+        result = manager.execute(context, "{UndefinedPagesPlugin show=count}");
+        assertEquals("1", result);
+
+        // test if the proper exception is thrown:
+        String expectedExceptionString = "parameter showLastModified is not valid for the UndefinedPagesPlugin";
+        String exceptionString = null;
+        try
+        {
+            result = manager.execute(context, "{UndefinedPagesPlugin,show=count,showLastModified=true}");
+        }
+        catch (PluginException pe)
+        {
+            exceptionString = pe.getMessage();
+        }
+
+        assertEquals(expectedExceptionString, exceptionString);
+    }
+
     public static Test suite()
     {
         return new TestSuite( UndefinedPagesPluginTest.class );

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/BasicAttachmentProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/BasicAttachmentProviderTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/BasicAttachmentProviderTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/BasicAttachmentProviderTest.java Sun Aug  3 05:28:09 2008
@@ -36,6 +36,8 @@
 
         m_engine  = new TestEngine(props);
 
+        TestEngine.deleteAll( new File(TestEngine.getRequiredProperty( props, BasicAttachmentProvider.PROP_STORAGEDIR )) );
+        
         m_provider = new BasicAttachmentProvider();
         m_provider.initialize( m_engine, props );
 

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/CounterProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/CounterProvider.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/CounterProvider.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/CounterProvider.java Sun Aug  3 05:28:09 2008
@@ -1,21 +1,22 @@
 /*
     JSPWiki - a JSP-based WikiWiki clone.
 
-    Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU Lesser General Public License as published by
-    the Free Software Foundation; either version 2.1 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    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 com.ecyrd.jspwiki.providers;
 
@@ -114,7 +115,7 @@
     {
         m_getAllPagesCalls++;
 
-        Vector v = new Vector();
+        Vector<WikiPage> v = new Vector<WikiPage>();
 
         for( int i = 0; i < m_pages.length; i++ )
         {

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/FileSystemProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/FileSystemProviderTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/FileSystemProviderTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/FileSystemProviderTest.java Sun Aug  3 05:28:09 2008
@@ -125,6 +125,22 @@
         assertEquals("Wrong contents", contents, "test");
     }
 
+    public void testDotsInBeginning()
+       throws Exception
+    {
+        WikiPage page = new WikiPage(m_engine, ".Test");
+
+        m_provider.putPageText( page, "test" );
+
+        File resultfile = new File( m_pagedir, "%2ETest.txt" );
+
+        assertTrue("No such file", resultfile.exists());
+
+        String contents = FileUtil.readContents( new FileInputStream(resultfile), "ISO-8859-1" );
+
+        assertEquals("Wrong contents", contents, "test");
+    }
+    
     public void testAuthor()
         throws Exception
     {

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/RCSFileProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/RCSFileProviderTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/RCSFileProviderTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/RCSFileProviderTest.java Sun Aug  3 05:28:09 2008
@@ -10,7 +10,6 @@
  *  Tests the RCSFileProvider.  If you are getting strange errors, please check that you
  *  actually <i>have</i> RCS installed and in your path...
  * 
- *  @author jalkanen
  *
  *  @since forever
  */
@@ -201,7 +200,7 @@
     {
         WikiPage p = new WikiPage( engine, NAME1 );
         p.setAttribute(WikiPage.CHANGENOTE, "Test change" );
-        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean(p);
+        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean(null, null, p);
         
         engine.saveText( context, "test" );
         
@@ -214,7 +213,7 @@
         throws Exception
     {
         WikiPage p = new WikiPage( engine, NAME1 );
-        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean(p);
+        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean(null, null, p);
 
         context.getPage().setAttribute(WikiPage.CHANGENOTE, "Test change" );
         engine.saveText( context, "test" );

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VersioningFileProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VersioningFileProviderTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VersioningFileProviderTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VersioningFileProviderTest.java Sun Aug  3 05:28:09 2008
@@ -272,7 +272,7 @@
     {
         WikiPage p = new WikiPage( engine, NAME1 );
         p.setAttribute(WikiPage.CHANGENOTE, "Test change" );
-        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean(p);
+        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean(null, null, p);
         
         engine.saveText( context, "test" );
         
@@ -286,7 +286,8 @@
     {
         WikiPage p = new WikiPage( engine, NAME1 );
         
-        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean(p);
+        
+        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean(null, null, p);
 
         context.getPage().setAttribute(WikiPage.CHANGENOTE, "Test change" );
         engine.saveText( context, "test" );
@@ -307,7 +308,7 @@
     {
         WikiPage p = new WikiPage( engine, NAME1 );
     
-        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean( p );
+        WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
 
         context.getPage().setAttribute( WikiPage.CHANGENOTE, "Test change" );
         

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VerySimpleProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VerySimpleProvider.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VerySimpleProvider.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VerySimpleProvider.java Sun Aug  3 05:28:09 2008
@@ -78,7 +78,7 @@
      */
     public Collection getAllPages()
     {
-        Vector v = new Vector();
+        Vector<WikiPage> v = new Vector<WikiPage>();
         v.add( getPageInfo( PAGENAME, 5 ) );
         return v;
     }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/CreoleRendererTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/CreoleRendererTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/CreoleRendererTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/CreoleRendererTest.java Sun Aug  3 05:28:09 2008
@@ -29,7 +29,7 @@
     private String render(String s) throws IOException
     {
         WikiPage dummyPage = new WikiPage(m_testEngine,"TestPage");
-        WikiContext ctx = m_testEngine.getWikiActionBeanFactory().newViewActionBean( dummyPage );
+        WikiContext ctx = m_testEngine.getWikiActionBeanFactory().newViewActionBean( null, null, dummyPage );
         
         StringReader in = new StringReader(s);
         

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/RenderingManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/RenderingManagerTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/RenderingManagerTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/RenderingManagerTest.java Sun Aug  3 05:28:09 2008
@@ -55,7 +55,7 @@
             WikiPage page = m_engine.getPage( "TestPage" );
             String pagedata = m_engine.getPureText( page );
             
-            WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( page );
+            WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, page );
             
             MarkupParser p = m_manager.getParser( context, pagedata );
             
@@ -78,7 +78,7 @@
             WikiPage page = m_engine.getPage( "TestPage" );
             String pagedata = m_engine.getPureText( page );
             
-            WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( page );
+            WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, page );
             
             String html = m_manager.getHTML( context, pagedata );
             

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/WysiwygEditingRendererTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/WysiwygEditingRendererTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/WysiwygEditingRendererTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/WysiwygEditingRendererTest.java Sun Aug  3 05:28:09 2008
@@ -38,7 +38,7 @@
     private String render(String s) throws IOException
     {
         WikiPage dummyPage = new WikiPage(m_testEngine,"TestPage");
-        WikiContext ctx = m_testEngine.getWikiActionBeanFactory().newViewActionBean( dummyPage );
+        WikiContext ctx = m_testEngine.getWikiActionBeanFactory().newViewActionBean( null, null, dummyPage );
 
         StringReader in = new StringReader(s);
 

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/AllTests.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/AllTests.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/AllTests.java Sun Aug  3 05:28:09 2008
@@ -9,7 +9,6 @@
 import junit.framework.TestSuite;
 
 /**
- *  @author jalkanen
  *
  *  @since 
  */

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/RSSGeneratorTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/RSSGeneratorTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/RSSGeneratorTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/RSSGeneratorTest.java Sun Aug  3 05:28:09 2008
@@ -21,7 +21,6 @@
 import junit.framework.TestSuite;
 
 /**
- *  @author jalkanen
  *
  *  @since
  */
@@ -63,7 +62,7 @@
 
         RSSGenerator gen = m_testEngine.getRSSGenerator();
 
-        WikiContext context = m_testEngine.getWikiActionBeanFactory().newViewActionBean( m_testEngine.getPage("TestBlog") );
+        WikiContext context = m_testEngine.getWikiActionBeanFactory().newViewActionBean( null, null, m_testEngine.getPage("TestBlog") );
 
         WeblogPlugin blogplugin = new WeblogPlugin();
 
@@ -93,7 +92,7 @@
 
         RSSGenerator gen = m_testEngine.getRSSGenerator();
 
-        WikiContext context = m_testEngine.getWikiActionBeanFactory().newViewActionBean( m_testEngine.getPage("TestBlog") );
+        WikiContext context = m_testEngine.getWikiActionBeanFactory().newViewActionBean( null, null, m_testEngine.getPage("TestBlog") );
 
         WeblogPlugin blogplugin = new WeblogPlugin();
 

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/search/SearchManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/search/SearchManagerTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/search/SearchManagerTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/search/SearchManagerTest.java Sun Aug  3 05:28:09 2008
@@ -4,18 +4,15 @@
 import java.util.Collection;
 import java.util.Properties;
 
+import net.sourceforge.stripes.mock.MockHttpServletRequest;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import net.sourceforge.stripes.mock.MockHttpServletRequest;
-import net.sourceforge.stripes.mock.MockHttpServletResponse;
-import net.sourceforge.stripes.mock.MockRoundtrip;
 
 import com.ecyrd.jspwiki.SearchResult;
 import com.ecyrd.jspwiki.TestEngine;
 import com.ecyrd.jspwiki.WikiContext;
-import com.ecyrd.jspwiki.action.EditActionBean;
-import com.ecyrd.jspwiki.action.ViewActionBean;
 
 public class SearchManagerTest extends TestCase
 {
@@ -64,7 +61,7 @@
 
         Thread.yield();
 
-        Thread.sleep( 2000L ); // Should cover for both index and initial delay
+        Thread.sleep( 5000L ); // Should cover for both index and initial delay
         
         Collection res = m_mgr.findPages( "mankind" );
      
@@ -100,12 +97,10 @@
     {
         String txt = "It was the dawn of the third age of mankind, ten years after the Earth-Minbari War.";
  
-        MockRoundtrip trip = m_engine.guestTrip( ViewActionBean.class );
-        MockHttpServletRequest request = trip.getRequest();
-        MockHttpServletResponse response = trip.getResponse();
-        request.getParameterMap().put("page",new String[]{ "TestPage" });
+        MockHttpServletRequest request = m_engine.newHttpRequest();
+        request.getParameterMap().put( "page", new String[]{ "TestPage" } );
         
-        WikiContext ctx = (WikiContext)m_engine.getWikiActionBeanFactory().newActionBean( request, response, EditActionBean.class );
+        WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
         
         m_engine.saveText( ctx, txt );
 

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/InputValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/InputValidatorTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/InputValidatorTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/InputValidatorTest.java Sun Aug  3 05:28:09 2008
@@ -13,7 +13,6 @@
 
 import com.ecyrd.jspwiki.TestEngine;
 import com.ecyrd.jspwiki.WikiSession;
-import com.ecyrd.jspwiki.action.ViewActionBean;
 
 public class InputValidatorTest extends TestCase
 {
@@ -28,7 +27,7 @@
         Properties props = new Properties();
         props.load( TestEngine.findTestProperties() );
         testEngine = new TestEngine( props );
-        WikiSession session = WikiSession.getWikiSession( testEngine, testEngine.guestTrip( ViewActionBean.class ).getRequest() );
+        WikiSession session = WikiSession.getWikiSession( testEngine, testEngine.newHttpRequest() );
         val = new InputValidator( TEST, session );
     }
 

Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/AllTests.java?rev=682151&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/AllTests.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/AllTests.java Sun Aug  3 05:28:09 2008
@@ -0,0 +1,24 @@
+/*
+ * (C) Janne Jalkanen 2005
+ * 
+ */
+package com.ecyrd.jspwiki.url;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class AllTests extends TestCase
+{
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite("URL constructor tests");
+
+        suite.addTest( ShortViewURLConstructorTest.suite() );
+        suite.addTest( ShortURLConstructorTest.suite() );
+        suite.addTest( DefaultURLConstructorTest.suite() );
+
+        return suite;
+    }
+
+}

Propchange: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/AllTests.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/DefaultURLConstructorTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/DefaultURLConstructorTest.java?rev=682151&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/DefaultURLConstructorTest.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/DefaultURLConstructorTest.java Sun Aug  3 05:28:09 2008
@@ -0,0 +1,143 @@
+/*
+ * (C) Janne Jalkanen 2005
+ * 
+ */
+package com.ecyrd.jspwiki.url;
+
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import com.ecyrd.jspwiki.TestEngine;
+import com.ecyrd.jspwiki.WikiContext;
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.WikiException;
+
+public class DefaultURLConstructorTest extends TestCase
+{
+    TestEngine testEngine;
+
+    Properties props = new Properties();
+    
+    protected void setUp() throws Exception
+    {
+        props.load( TestEngine.findTestProperties() );
+    }
+
+    private URLConstructor getConstructor( String baseURL, String prefix )
+        throws WikiException
+    {
+        props.setProperty( WikiEngine.PROP_BASEURL, baseURL );
+        if( prefix != null ) props.setProperty( ShortViewURLConstructor.PROP_PREFIX, prefix );
+        
+        testEngine = new TestEngine(props);
+        URLConstructor constr = new DefaultURLConstructor();
+        
+        constr.initialize( testEngine, props );
+        
+        return constr;
+    }
+    
+    public void testViewURL1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/", "wiki/" );
+        
+        assertEquals( "http://localhost/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testViewURL2()
+       throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+    
+        assertEquals( "http://localhost/mywiki/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testViewURL3()
+       throws Exception
+    { 
+        URLConstructor c = getConstructor( "http://localhost:8080/", null );
+ 
+        assertEquals( "http://localhost:8080/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testViewURL4()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+ 
+        assertEquals( "/mywiki/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",false,null) );
+    }
+
+    public void testViewURL5()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/", "" );
+ 
+        assertEquals( "http://localhost/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+    
+    public void testViewURL6()
+       throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/app1/", null );
+ 
+        assertEquals( "http://localhost/mywiki/app1/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testViewURL7()
+       throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/app1/", "view/" );
+
+        assertEquals( "http://localhost/mywiki/app1/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testEditURL1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+ 
+        assertEquals( "http://localhost/mywiki/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",true,null) );
+    }
+
+    public void testAttachURL1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+
+        assertEquals( "http://localhost/mywiki/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",true,null) );
+    }
+
+    public void testAttachURLRelative1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+
+        assertEquals( "/mywiki/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",false,null) );
+    }
+
+    public void testOtherURL1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+
+        assertEquals( "http://localhost/mywiki/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",true,null) );
+    }
+    
+    public void testOtherURL2()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/dobble/", null );
+    
+        assertEquals( "http://localhost/mywiki/dobble/foo.jsp?a=1&amp;b=2", c.makeURL(WikiContext.NONE,"foo.jsp",true,"a=1&amp;b=2") );
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite( DefaultURLConstructorTest.class );
+    }
+}

Propchange: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/DefaultURLConstructorTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/ShortURLConstructorTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/ShortURLConstructorTest.java?rev=682151&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/ShortURLConstructorTest.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/ShortURLConstructorTest.java Sun Aug  3 05:28:09 2008
@@ -0,0 +1,144 @@
+/*
+ * (C) Janne Jalkanen 2005
+ * 
+ */
+package com.ecyrd.jspwiki.url;
+
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import com.ecyrd.jspwiki.TestEngine;
+import com.ecyrd.jspwiki.WikiContext;
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.WikiException;
+
+public class ShortURLConstructorTest extends TestCase
+{
+    TestEngine testEngine;
+
+    Properties props = new Properties();
+    
+    protected void setUp() throws Exception
+    {
+        props.load( TestEngine.findTestProperties() );
+    }
+
+    private URLConstructor getConstructor( String baseURL, String prefix )
+        throws WikiException
+    {
+        props.setProperty( WikiEngine.PROP_BASEURL, baseURL );
+        if( prefix != null ) props.setProperty( ShortURLConstructor.PROP_PREFIX, prefix );
+        
+        testEngine = new TestEngine(props);
+        URLConstructor constr = new ShortURLConstructor();
+        
+        constr.initialize( testEngine, props );
+        
+        return constr;
+    }
+    
+    public void testViewURL1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/", "wiki/" );
+        
+        assertEquals( "http://localhost/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testViewURL2()
+       throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+    
+        assertEquals( "http://localhost/mywiki/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testViewURL3()
+       throws Exception
+    { 
+        URLConstructor c = getConstructor( "http://localhost:8080/", null );
+ 
+        assertEquals( "http://localhost:8080/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testViewURL4()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+ 
+        assertEquals( "/mywiki/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",false,null) );
+    }
+
+    public void testViewURL5()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/", "" );
+ 
+        assertEquals( "http://localhost/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+    
+    public void testViewURL6()
+       throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/app1/", null );
+ 
+        assertEquals( "http://localhost/mywiki/app1/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testViewURL7()
+       throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/app1/", "view/" );
+
+        assertEquals( "http://localhost/mywiki/app1/view/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+    }
+
+    public void testEditURL1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+ 
+        assertEquals( "http://localhost/mywiki/wiki/Main?do=Edit", c.makeURL(WikiContext.EDIT,"Main",true,null) );
+    }
+
+    public void testAttachURL1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+
+        assertEquals( "http://localhost/mywiki/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",true,null) );
+    }
+
+    public void testAttachURLRelative1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+
+        assertEquals( "/mywiki/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",false,null) );
+    }
+
+    public void testOtherURL1()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/", null );
+
+        assertEquals( "http://localhost/mywiki/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",true,null) );
+    }
+    
+    public void testOtherURL2()
+        throws Exception
+    {
+        URLConstructor c = getConstructor( "http://localhost/mywiki/dobble/", null );
+    
+        assertEquals( "http://localhost/mywiki/dobble/foo.jsp?a=1&amp;b=2", c.makeURL(WikiContext.NONE,"foo.jsp",true,"a=1&amp;b=2") );
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite( ShortURLConstructorTest.class );
+    }
+}
+

Propchange: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/ShortURLConstructorTest.java
------------------------------------------------------------------------------
    svn:executable = *