jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jalka...@apache.org
Subject svn commit: r797223 - /incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/ContentManagerTest.java
Date Thu, 23 Jul 2009 21:07:55 GMT
Author: jalkanen
Date: Thu Jul 23 21:07:54 2009
New Revision: 797223

URL: http://svn.apache.org/viewvc?rev=797223&view=rev
Log:
Added testZillionVersions() and testDeleteAllVersions()

Modified:
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/ContentManagerTest.java

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/ContentManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/ContentManagerTest.java?rev=797223&r1=797222&r2=797223&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/ContentManagerTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/ContentManagerTest.java Thu
Jul 23 21:07:54 2009
@@ -31,6 +31,7 @@
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.providers.ProviderException;
 
 
 public class ContentManagerTest extends TestCase
@@ -184,7 +185,58 @@
         
         assertEquals( "v3 content", "Even newer Test Content", p2.getContentAsString() );
         assertEquals( "v3 version", 3, p2.getVersion() );
-}
+    }
+    
+    private void storeVersions( WikiPage p, int howMany ) throws ProviderException
+    {
+        for( int i = 1; i <= howMany; i++ )
+        {
+            p.setContent( "Test "+i );
+            p.save();
+        }        
+    }
+    
+    public void testZillionVersions() throws Exception
+    {
+        WikiPage p = m_mgr.addPage( WikiPath.valueOf( "TestPage" ), ContentManager.JSPWIKI_CONTENT_TYPE
);
+        
+        storeVersions( p, 100 );
+        
+        p = m_engine.getPage( "TestPage", 100 );
+        assertEquals( "content 100","Test 100", p.getContentAsString() );
+        assertEquals( "version 100", 100, p.getVersion() );
+        
+        p = m_engine.getPage( "TestPage", 1 );
+        assertEquals( "content 1","Test 1", p.getContentAsString() );
+        assertEquals( "version 1", 1, p.getVersion() );
+        
+        p = m_engine.getPage( "TestPage", 51 );
+        assertEquals( "content 51","Test 51", p.getContentAsString() );
+        assertEquals( "version 51", 51, p.getVersion() );
+    }
+    
+    public void testDeleteAllVersions() throws Exception
+    {
+        WikiPage p = m_engine.createPage( "TestPage" );
+        
+        storeVersions( p, 3 );
+        
+        for( int i = 1; i <= 3; i++ )
+        {
+            p = m_engine.getPage( "TestPage", i );
+            
+            m_engine.deleteVersion( p );
+        }
+    
+        assertFalse( m_engine.pageExists( "TestPage" ) );
+        
+        try
+        {
+            m_engine.getPage( "TestPage" );
+            fail("Didn't get exception!");
+        }
+        catch( PageNotFoundException e ) {} // Expected
+    }
     
     public static Test suite()
     {



Mime
View raw message