jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jalka...@apache.org
Subject svn commit: r760372 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/content/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/render/ tests/java/org/apache/wiki/ tests/java/org/apache/wiki/action/ tests/jav...
Date Tue, 31 Mar 2009 08:57:44 GMT
Author: jalkanen
Date: Tue Mar 31 08:57:39 2009
New Revision: 760372

URL: http://svn.apache.org/viewvc?rev=760372&view=rev
Log:
Continued fixing ReferenceManager.  The API of ReferenceManager
is changing slightly to use WikiNames instead of Strings to reflect
the new multi-wiki capabilities.  This needs some fixes to tests as
well.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/render/RenderingManager.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/RenameActionBeanTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/PageRenamerTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Tue Mar 31 08:57:39 2009
@@ -1,3 +1,14 @@
+2009-03-31  Janne Jalkanen <jalkanen@apache.org>
+
+        * 3.0.0-svn-91
+        
+        * Continued fixing ReferenceManager.  The API of ReferenceManager
+        is changing slightly to use WikiNames instead of Strings to reflect
+        the new multi-wiki capabilities.  This needs some fixes to tests as
+        well.
+        
+        * WikiName.equals() enhanced to manage also String comparisons.
+        
 2009-03-29  Janne Jalkanen <jalkanen@apache.org>
 
         * 3.0.0-svn-90

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java Tue Mar 31 08:57:39
2009
@@ -64,9 +64,6 @@
 
     private static Logger log = LoggerFactory.getLogger(ReferenceManager.class);
 
-    private static final String SERIALIZATION_FILE = "refmgr.ser";
-    private static final String SERIALIZATION_DIR  = "refmgr-attr";
-
     /** We use this also a generic serialization id */
     private static final long serialVersionUID = 4L;
 
@@ -88,43 +85,6 @@
     }
 
     /**
-     *  Does a full reference update.  Does not sync; assumes that you do it afterwards.
-     */
-    @SuppressWarnings("unchecked")
-    private void updatePageReferences( WikiPage page )
-        throws ProviderException
-    {
-        String content;
-
-        content = page.getContentAsString();
-
-        TreeSet<WikiName> res = new TreeSet<WikiName>();
-        Collection<WikiName> links = m_engine.scanWikiLinks( page, content );
-
-        // This makes sure all duplicates are removed.
-        
-        res.addAll( links );
-        
-        // FIXME: I am not sure whether it makes sense to add all attachments here as well.
-        /*
-        Collection attachments = m_engine.getAttachmentManager().listAttachments( page );
-
-        for( Iterator atti = attachments.iterator(); atti.hasNext(); )
-        {
-            res.add( ((WikiPage)(atti.next())).getName() );
-        }
-         */
-        try
-        {
-            internalUpdateReferences( (JCRWikiPage)page, res );
-        }
-        catch( RepositoryException e )
-        {
-            throw new ProviderException("Unable to store internal references",e);
-        }
-    }
-
-    /**
      *  Initializes the entire reference manager with the initial set of pages
      *  from the collection.
      *
@@ -133,7 +93,7 @@
      *  @since 2.2
      *  @throws ProviderException If reading of pages fail.
      */
-    public void initialize( Collection pages )
+    public void initialize( Collection<WikiPage> pages )
         throws ProviderException
     {
         try
@@ -282,7 +242,7 @@
      * can have more than one value we have to delete just the key-value-pair
      * referring page:deleted page.
      *
-     *  @param page Name of the page to remove from the maps.
+     *  @param pageName Name of the page to remove from the maps.
      * @throws PageNotFoundException 
      * @throws ProviderException 
      */
@@ -295,7 +255,7 @@
         for( WikiName referred : refTo )
         {
             log.debug( "Removing references to page %s from page %s", page.getQualifiedName(),
referred );
-            Set<WikiName> referredBy = getReferredBy(referred);
+            Set<WikiName> referredBy = findReferrers(referred);
             
             referredBy.remove( page.getQualifiedName() );
             
@@ -311,12 +271,24 @@
 
     }
 
-    private String getReferredByJCRPath(WikiName name)
+    /**
+     *  Build the path which is used to store the ReferredBy data  
+     */
+    private final String getReferredByJCRPath(WikiName name)
     {
         return "/wiki:references/"+name.getSpace()+"/"+name.getPath();
     }
     
-    private Set<WikiName> getReferredBy(WikiName name) throws ProviderException
+    /**
+     *  Finds all the pages which are referenced by the given page.
+     *  
+     *  @param name The WikiName to find.
+     *  @return A set of WikiNames. If the page in question does not exist, returns
+     *          an empty set.
+     *  @throws ProviderException If something goes wrong.
+     *  @since 3.0
+     */
+    public Set<WikiName> findReferrers(WikiName name) throws ProviderException
     {
         String jcrPath = getReferredByJCRPath( name );
         
@@ -345,7 +317,7 @@
             throw new ProviderException("Unable to get the referred-by list",e);
         }
     }
-    
+        
     /**
      *  Set the referredBy attribute set.
      *  
@@ -462,7 +434,7 @@
             {
                 // A page is no longer referenced, so this page is removed from its
                 // referencedBy list.
-                Set<WikiName> refs = getReferredBy( name );
+                Set<WikiName> refs = findReferrers( name );
                 refs.remove( page.getQualifiedName() );
                 setReferredBy( name, refs );
             }
@@ -474,7 +446,7 @@
             {
                 // There is a new reference which is not in the old references list,
                 // so we will need to add it to the new page's referencedBy list.
-                Set<WikiName> refs = getReferredBy( name );
+                Set<WikiName> refs = findReferrers( name );
                 refs.add( page.getQualifiedName() );
                 setReferredBy( name, refs );
             }
@@ -550,32 +522,6 @@
         return uncreated;
     }
 
-
-    /**
-     * Find all pages that refer to this page. Returns null if the page
-     * does not exist or is not referenced at all, otherwise returns a
-     * collection containing page names (String) that refer to this one.
-     * <p>
-     * @param pagename The page to find referrers for.
-     * @return A Collection of Strings.  (This is, in fact, a Set, and is likely
-     *         to change at some point to a Set).  May return null, if the page
-     *         does not exist, or if it has no references.
-     * @throws ProviderException 
-     * @deprecated
-     */
-    // FIXME: Return a Set instead of a Collection.
-    public synchronized Collection<String> findReferrers( String pagename ) throws
ProviderException
-    {
-        Set<String> refs = new TreeSet<String>();
-
-        Set<WikiName> r = getReferredBy( WikiName.valueOf( pagename ) );
-
-        for( WikiName wn : r )
-            refs.add( wn.toString() );
-        
-        return refs;
-    }
-
     /**
      *  Returns all pages that this page refers to.  You can use this as a quick
      *  way of getting the links from a page, but note that it does not link any

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Tue Mar 31 08:57:39 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "90";
+    public static final String     BUILD         = "91";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java Tue Mar 31 08:57:39
2009
@@ -128,7 +128,7 @@
                                                    JSPWikiMarkupParser.PROP_CAMELCASELINKS,

                                                    m_camelCase );
 
-        Set<String> referrers = getReferencesToChange( fromPage, engine );
+        Set<WikiName> referrers = getReferencesToChange( fromPage, engine );
 
         //
         //  Do the actual rename by changing from the frompage to the topage, including
@@ -203,24 +203,24 @@
      *  @param fromPage The old page
      *  @param toPage The new page
      */
-    private void updateReferrers( WikiContext context, WikiPage fromPage, WikiPage toPage,
Set<String>referrers )
+    private void updateReferrers( WikiContext context, WikiPage fromPage, WikiPage toPage,
Set<WikiName>referrers )
     {
         WikiEngine engine = context.getEngine();
         
         if( referrers.isEmpty() ) return; // No referrers
         
-        for( String pageName : referrers )
+        for( WikiName pageName : referrers )
         {
             //  In case the page was just changed from under us, let's do this
             //  small kludge.
-            if( pageName.equals( fromPage.getName() ) )
+            if( pageName.equals( fromPage.getQualifiedName() ) )
             {
-                pageName = toPage.getName();
+                pageName = toPage.getQualifiedName();
             }
             
             try
             {
-                WikiPage p = engine.getPage( pageName );
+                WikiPage p = engine.getContentManager().getPage( pageName );
             
                 String sourceText = engine.getPureText( p );
             
@@ -254,15 +254,15 @@
     }
 
     @SuppressWarnings("unchecked")
-    private Set<String> getReferencesToChange( WikiPage fromPage, WikiEngine engine
)
+    private Set<WikiName> getReferencesToChange( WikiPage fromPage, WikiEngine engine
)
     {
-        Set<String> referrers = new TreeSet<String>();
+        Set<WikiName> referrers = new TreeSet<WikiName>();
         
         try
         {
-            Collection<String> r = engine.getReferenceManager().findReferrers( fromPage.getName()
);
+            Collection<WikiName> r = engine.getReferenceManager().findReferrers( fromPage.getQualifiedName()
);
             if( r != null ) referrers.addAll( r );
-            
+            /*
             Collection<Attachment> attachments = engine.getAttachmentManager().listAttachments(
fromPage );
 
             for( WikiPage att : attachments  )
@@ -271,6 +271,7 @@
 
                 if( c != null ) referrers.addAll(c);
             }
+            */
         }
         catch( ProviderException e )
         {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java Tue
Mar 31 08:57:39 2009
@@ -21,6 +21,7 @@
 package org.apache.wiki.plugin;
 
 import java.text.MessageFormat;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
 import java.util.ResourceBundle;
@@ -30,6 +31,7 @@
 import org.apache.wiki.api.PluginException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.content.PageNotFoundException;
+import org.apache.wiki.content.WikiName;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.providers.ProviderException;
@@ -92,7 +94,7 @@
         {
             WikiPage page = context.getEngine().getPage( pageName );
         
-            Collection   links  = refmgr.findReferrers( page.getName() );
+            Collection<WikiName> links = refmgr.findReferrers( page.getQualifiedName()
);
             String       wikitext = "";
 
             super.initialize( context, params );
@@ -110,14 +112,19 @@
         
             if( links != null && links.size() > 0 )
             {
-                links = filterCollection( links );
-                wikitext = wikitizeCollection( links, m_separator, items );
+                // FIXME: Having to copy all of these is kinda stupid.
+                ArrayList<String> tmpList = new ArrayList<String>();
+                
+                for( WikiName wn : links ) tmpList.add( wn.toString() );
+                
+                links = filterCollection( tmpList );
+                wikitext = wikitizeCollection( tmpList, m_separator, items );
 
                 result.append( makeHTML( context, wikitext ) );
                 
-                if( items < links.size() && items > 0 )
+                if( items < tmpList.size() && items > 0 )
                 {
-                    Object[] args = { "" + ( links.size() - items) };
+                    Object[] args = { "" + ( tmpList.size() - items) };
                     extras = MessageFormat.format(extras, args);
                     
                     result.append( "<br />" );

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/render/RenderingManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/render/RenderingManager.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/render/RenderingManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/render/RenderingManager.java Tue Mar
31 08:57:39 2009
@@ -30,6 +30,7 @@
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiException;
+import org.apache.wiki.content.WikiName;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventUtils;
@@ -344,7 +345,7 @@
                 m_documentCache.flushPattern( pageName );
                 try
                 {
-                    Collection referringPages = m_engine.getReferenceManager().findReferrers(
pageName );
+                    Collection<WikiName> referringPages = m_engine.getReferenceManager().findReferrers(
WikiName.valueOf(pageName) );
 
                     //
                     //  Flush also those pages that refer to this page (if an nonexistant
page
@@ -355,9 +356,9 @@
                         Iterator i = referringPages.iterator();
                         while (i.hasNext())
                         {
-                            String page = (String) i.next();
+                            WikiName page = (WikiName) i.next();
                             if( log.isDebugEnabled() ) log.debug( "Flushing " + page );
-                            m_documentCache.flushPattern( page );
+                            m_documentCache.flushPattern( page.toString() );
                         }
                     }
                 }

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java Tue Mar 31
08:57:39 2009
@@ -32,6 +32,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.wiki.api.WikiException;
+import org.apache.wiki.content.WikiName;
 import org.apache.wiki.providers.AbstractFileProvider;
 import org.apache.wiki.providers.ProviderException;
 
@@ -96,37 +97,43 @@
         engine.shutdown();
     }
 
+    /** Shortcut to help testing. */
+    private Set<WikiName> findReferrers( String path ) throws ProviderException
+    {
+        return mgr.findReferrers(  WikiName.valueOf(path) );
+    }
+    
     public void testNonExistant1()
         throws Exception
     {
-        Collection c = mgr.findReferrers("Foobar2");
+        Collection<WikiName> c = mgr.findReferrers( WikiName.valueOf("Foobar2") );
         
-        assertTrue( c.size() == 1 && c.contains("Foobar") );
+        assertTrue( c.size() == 1 && c.contains( WikiName.valueOf("Foobar") ) );
     }
     
     public void testNonExistant2() throws ProviderException
     {
-        Collection c = mgr.findReferrers("TestBug");
+        Collection<WikiName> c = findReferrers("TestBug");
         
-        assertNull( c );
+        assertTrue( c.size() == 0 );
     }
     
     public void testRemove()
         throws Exception
     {
-        Collection c = mgr.findReferrers("Foobar2");
+        Collection<WikiName> c = findReferrers("Foobar2");
         
         assertTrue( c.size() == 1 && c.contains("Foobar") );
 
         engine.deletePage( "Foobar" );
         
-        c = mgr.findReferrers("Foobar2");
+        c = findReferrers("Foobar2");
         
         assertNull( c );
         
         engine.saveText( "Foobar", "[Foobar2]");
         
-        c = mgr.findReferrers("Foobar2");
+        c = findReferrers("Foobar2");
         
         assertTrue( c.size() == 1 && c.contains("Foobar") );        
     }
@@ -168,16 +175,16 @@
     public void testReferrers()
         throws Exception
     {
-        Collection c = mgr.findReferrers( "TestPage" );
+        Collection<WikiName> c = findReferrers( "TestPage" );
         assertNull( "TestPage referrers", c );
 
-        c = mgr.findReferrers( "Foobar" );
+        c = findReferrers( "Foobar" );
         assertTrue( "Foobar referrers", c.size()==2  );
 
-        c = mgr.findReferrers( "Foobar2" );
-        assertTrue( "Foobar2 referrers", c.size()==1 && ((String) c.iterator().next()).equals("Foobar")
);
+        c = findReferrers( "Foobar2" );
+        assertTrue( "Foobar2 referrers", c.size()==1 && ((WikiName) c.iterator().next()).equals("Foobar")
);
 
-        c = mgr.findReferrers( "Foobars" );
+        c = findReferrers( "Foobars" );
         assertEquals( "Foobars referrers", 2, c.size() );
         //assertEquals( "Foobars referrer 'TestPage'", "TestPage", (String) c.iterator().next()
);
     }
@@ -203,7 +210,7 @@
         engine.saveText( "FatalBugs", "<foo>" );
         engine.saveText( "BugCommentPreviewDeletesAllComments", "FatalBug" );
         
-        Collection c = mgr.findReferrers( "FatalBugs" );
+        Collection<WikiName> c = findReferrers( "FatalBugs" );
         
         assertEquals( "FatalBugs referrers number", 2, c.size()  );
     }
@@ -222,7 +229,7 @@
         Collection c = mgr.findUnreferenced();
         assertTrue( "Foobar unreferenced", c.size()==1 && ((String) c.iterator().next()).equals("TestPage")
);
 
-        c = mgr.findReferrers( "Foobar" );
+        c = findReferrers( "Foobar" );
         assertTrue( "Foobar referrers", 
                     c.size()==2 );
     }
@@ -239,7 +246,7 @@
         engine.saveText( "Foobar2s", "qwertz" );
         assertTrue( "no uncreated", mgr.findUncreated().size()==0 );
 
-        Collection c = mgr.findReferrers( "Foobar2s" );
+        Collection c = findReferrers( "Foobar2s" );
         assertTrue( "referrers", c!=null && c.size()==1 && ((String) c.iterator().next()).equals("Foobar")
);
     }
 
@@ -247,7 +254,7 @@
         throws Exception
     {
         engine.saveText( "Foobars", "qwertz" );
-        Collection c = mgr.findReferrers( "Foobars" );
+        Collection c = findReferrers( "Foobars" );
         assertEquals( "Foobars referrers", 2, c.size() );
         assertTrue( "Foobars referrer is not TestPage", c.contains( "TestPage" ) &&
c.contains("Foobar"));
     }
@@ -258,7 +265,7 @@
         engine.saveText( "Foobars", "qwertz" );
         engine.saveText( "TestPage", "Reference to [Foobar], [Foobars]." );
         
-        Collection c = mgr.findReferrers( "Foobars" );
+        Collection c = findReferrers( "Foobars" );
         assertEquals( "Foobars referrers count", 2, c.size() );
 
         assertTrue( "Foobars referrers", 
@@ -283,17 +290,17 @@
         
         engine.saveText( "BugOne", "OpenBug" );
         
-        Collection ref = mgr.findReferrers( "NewBugs" );
+        Collection ref = findReferrers( "NewBugs" );
         assertNull("newbugs",ref); // No referrers must be found
 
-        ref = mgr.findReferrers( "NewBug" );
+        ref = findReferrers( "NewBug" );
         assertNull("newbug",ref); // No referrers must be found
 
-        ref = mgr.findReferrers( "OpenBugs" );
+        ref = findReferrers( "OpenBugs" );
         assertEquals("openbugs",1,ref.size());
         assertEquals("openbugs2","BugOne",ref.iterator().next());
 
-        ref = mgr.findReferrers( "OpenBug" );
+        ref = findReferrers( "OpenBug" );
         assertEquals("openbug",1,ref.size());
         assertEquals("openbug2","BugOne",ref.iterator().next());
 
@@ -308,17 +315,17 @@
     
         engine.saveText( "BugOne", "OpenBug" );
     
-        Collection ref = mgr.findReferrers( "NewBugs" );
+        Collection ref = findReferrers( "NewBugs" );
         assertNull("newbugs",ref); // No referrers must be found
 
-        ref = mgr.findReferrers( "NewBug" );
+        ref = findReferrers( "NewBug" );
         assertNull("newbug",ref); // No referrers must be found
 
-        ref = mgr.findReferrers( "OpenBugs" );
+        ref = findReferrers( "OpenBugs" );
         assertEquals("openbugs",1,ref.size());
         assertEquals("openbugs2","BugOne",ref.iterator().next());
 
-        ref = mgr.findReferrers( "OpenBug" );
+        ref = findReferrers( "OpenBug" );
         assertEquals("openbug",1,ref.size());
         assertEquals("openbug2","BugOne",ref.iterator().next());
 
@@ -334,19 +341,19 @@
     
         engine.saveText( "BugOne", "OpenBug" );
     
-        Collection ref = mgr.findReferrers( "NewBugs" );
+        Collection ref = findReferrers( "NewBugs" );
         assertEquals("newbugs",1,ref.size()); 
         assertEquals("newbugs2","BugTwo",ref.iterator().next()); 
 
-        ref = mgr.findReferrers( "NewBug" );
+        ref = findReferrers( "NewBug" );
         assertEquals("newbugs",1,ref.size()); 
         assertEquals("newbugs2","BugTwo",ref.iterator().next()); 
 
-        ref = mgr.findReferrers( "OpenBugs" );
+        ref = findReferrers( "OpenBugs" );
         assertEquals("openbugs",1,ref.size());
         assertEquals("openbugs2","BugOne",ref.iterator().next());
 
-        ref = mgr.findReferrers( "OpenBug" );
+        ref = findReferrers( "OpenBug" );
         assertEquals("openbug",1,ref.size());
         assertEquals("openbug2","BugOne",ref.iterator().next());
 
@@ -355,9 +362,9 @@
     public void testSelf() throws WikiException
     {
         engine.saveText( "BugOne", "BugOne" );
-        Collection ref = mgr.findReferrers( "BugOne" );
+        Collection ref = findReferrers( "BugOne" );
         assertEquals("wrong size",1,ref.size());
-        assertEquals("ref", "BugOne", ref.iterator().next());
+        assertEquals("ref", "Main:BugOne", ref.iterator().next());
     }
     
     public static Test suite()

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java Tue Mar 31 08:57:39
2009
@@ -873,7 +873,7 @@
         m_engine.saveText( "RenameBugTestPage", "Mary had a little generic object" );
         m_engine.saveText( "OldNameTestPage", "Linked to RenameBugTestPage" );
        
-        Collection pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage"
);
+        Collection pages = m_engine.getReferenceManager().findReferrers( WikiName.valueOf("RenameBugTestPage")
);
         assertEquals( "has one", "OldNameTestPage", pages.iterator().next() );
         
         WikiContext ctx = m_engine.getWikiContextFactory().newViewContext( m_engine.getPage("OldNameTestPage")
);
@@ -883,7 +883,7 @@
         assertFalse( "did not vanish", m_engine.pageExists( "OldNameTestPage") );
         assertTrue( "did not appear", m_engine.pageExists( "NewNameTestPage") );
         
-        pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage" );
+        pages = m_engine.getReferenceManager().findReferrers( WikiName.valueOf("RenameBugTestPage")
);
         
         assertEquals( "wrong # of referrers", 1, pages.size() );
         

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/RenameActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/RenameActionBeanTest.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/RenameActionBeanTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/RenameActionBeanTest.java Tue
Mar 31 08:57:39 2009
@@ -26,6 +26,7 @@
 import org.apache.wiki.action.RenameActionBean;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.auth.Users;
+import org.apache.wiki.content.WikiName;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -150,8 +151,8 @@
         m_engine.saveText("ReferstoTest", "This page refers to [Test].\n");
         WikiPage referringPage = m_engine.getPage("ReferstoTest");
         assertNotNull("Did not save page ReferstoTest!", referringPage );
-        assertNotNull( m_engine.getReferenceManager().findReferrers("Test") );
-        assertEquals( 1, m_engine.getReferenceManager().findReferrers("Test").size() );
+        assertNotNull( m_engine.getReferenceManager().findReferrers(WikiName.valueOf("Test"))
);
+        assertEquals( 1, m_engine.getReferenceManager().findReferrers(WikiName.valueOf("Test")).size()
);
         
         MockRoundtrip trip;
         ValidationErrors errors;

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/PageRenamerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/PageRenamerTest.java?rev=760372&r1=760371&r2=760372&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/PageRenamerTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/PageRenamerTest.java Tue Mar
31 08:57:39 2009
@@ -22,10 +22,12 @@
 
 import java.util.Collection;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.wiki.*;
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.providers.ProviderException;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -76,6 +78,11 @@
         m_engine.shutdown();
     }
 
+    private Set<WikiName> findReferrers(String path) throws ProviderException
+    {
+        return m_engine.getReferenceManager().findReferrers( WikiName.valueOf(path) );
+    }
+    
     public void testSimpleRename()
         throws Exception
     {
@@ -120,13 +127,13 @@
         
         assertEquals( "no rename", "[FooTest]", data.trim() );
         
-        Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        Collection<WikiName> refs = findReferrers("TestPage");
         
         assertNull( "oldpage", refs );
         
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        refs = findReferrers( "FooTest" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+        assertEquals( "wrong ref", "TestPage2", (WikiName)refs.iterator().next() );
     }
 
     public void testReferrerChangeCC()
@@ -144,13 +151,13 @@
         String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
      
         assertEquals( "no rename", "FooTest", data.trim() );
-        Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        Collection<WikiName> refs = findReferrers("TestPage");
         
         assertNull( "oldpage", refs );
         
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        refs = findReferrers( "FooTest" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+        assertEquals( "wrong ref", "TestPage2", (WikiName)refs.iterator().next() );
     }
     
     public void testReferrerChangeAnchor()
@@ -168,13 +175,13 @@
         String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
      
         assertEquals( "no rename", "[FooTest#heading1]", data.trim() );
-        Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        Collection<WikiName> refs = findReferrers("TestPage");
         
         assertNull( "oldpage", refs );
         
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        refs = findReferrers( "FooTest" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+        assertEquals( "wrong ref", "TestPage2", refs.iterator().next() );
     }
     
     public void testReferrerChangeMultilink()
@@ -195,13 +202,13 @@
                       "[FooTest] [FooTest] [linktext|FooTest] FooTest [linktext|FooTest]
[FooTest#Anchor] [FooTest] FooTest [FooTest]", 
                       data.trim() );
 
-        Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        Collection<WikiName> refs = findReferrers("TestPage");
         
         assertNull( "oldpage", refs );
         
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        refs = findReferrers( "FooTest" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+        assertEquals( "wrong ref", "TestPage2", refs.iterator().next() );
     }
     
     public void testReferrerNoWikiName()
@@ -253,13 +260,13 @@
         att = m_engine.getAttachmentManager().getAttachmentInfo("TestPage/foo.txt");
         assertNull("testpage/foo.txt exists",att);
         
-        Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage/bar.jpg");
+        Collection<WikiName> refs = findReferrers("TestPage/bar.jpg");
     
         assertNull( "oldpage", refs );
     
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest/bar.jpg" );
+        refs = findReferrers( "FooTest/bar.jpg" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", (String)refs.iterator().next() );
+        assertEquals( "wrong ref", "TestPage2", refs.iterator().next() );
     }
 
     public void testSamePage() throws Exception
@@ -477,12 +484,12 @@
         String data = m_engine.getPureText( "TestPageReferring", WikiProvider.LATEST_VERSION
);
         assertEquals( "page not renamed", "[Test Page Referred|TestPageReferredNew]", data.trim()
);
 
-        Collection refs = m_engine.getReferenceManager().findReferrers( "TestPageReferred"
);
+        Collection refs = findReferrers( "TestPageReferred" );
         assertNull( "oldpage", refs );
 
-        refs = m_engine.getReferenceManager().findReferrers( "TestPageReferredNew" );
+        refs = findReferrers( "TestPageReferredNew" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPageReferring", (String) refs.iterator().next() );
+        assertEquals( "wrong ref", "TestPageReferring", refs.iterator().next() );
     }
 
     /** https://issues.apache.org/jira/browse/JSPWIKI-398 */
@@ -497,12 +504,12 @@
         String data = m_engine.getPureText( "RenameTest", WikiProvider.LATEST_VERSION );
         assertEquals( "page not renamed", "[link one|Link uno] [link two]", data.trim() );
 
-        Collection refs = m_engine.getReferenceManager().findReferrers( "Link one" );
+        Collection refs = findReferrers( "Link one" );
         assertNull( "oldpage", refs );
 
-        refs = m_engine.getReferenceManager().findReferrers( "Link uno" );
+        refs = findReferrers( "Link uno" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "RenameTest", (String) refs.iterator().next() );
+        assertEquals( "wrong ref", "RenameTest", refs.iterator().next() );
     }
 
     public static Test suite()



Mime
View raw message