jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r825387 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/content/ src/java/org/apache/wiki/content/resolver/ src/java/org/apache/wiki/parser/ src/java/org/apache/wiki/ui/stripes/ tests/java/org/apache/wik...
Date Thu, 15 Oct 2009 04:23:22 GMT
Author: ajaquith
Date: Thu Oct 15 04:23:21 2009
New Revision: 825387

URL: http://svn.apache.org/viewvc?rev=825387&view=rev
Log:
We are getting damned close to a nice clean build. 98%+

Added:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/IsOneOf.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/IsOneOfTest.java
Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ReferenceManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/resolver/SpecialPageNameResolver.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/RenameActionBeanTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/PageRenamerTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/AllTests.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=825387&r1=825386&r2=825387&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Thu Oct 15 04:23:21 2009
@@ -1,3 +1,9 @@
+2009-10-14 Andrew Jaquith <ajaquith AT apache DOT org>
+
+        * 3.0.0-svn-166
+
+        * We are getting damned close to a nice clean build. 98%+
+
 2009-10-14 Harry Metske <metskem@apache.org>
 
         * 3.0.0-svn-165

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=825387&r1=825386&r2=825387&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Thu Oct 15 04:23:21 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "165";
+    public static final String     BUILD         = "166";
 
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ReferenceManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ReferenceManager.java?rev=825387&r1=825386&r2=825387&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ReferenceManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ReferenceManager.java Thu Oct
15 04:23:21 2009
@@ -65,7 +65,7 @@
  * when they are saved, renamed or deleted. ReferenceManager listens for the
  * events {@link ContentEvent#NODE_SAVED}, {@link ContentEvent#NODE_RENAMED}
  * and {@link ContentEvent#NODE_DELETE_REQUEST}. When one of these events is
- * detected, ReferenceManager updates the inbound and oubound link references as
+ * detected, ReferenceManager updates the inbound and outbound link references as
  * required. The end result of these choices means that ReferenceManager is
  * relatively fast at reading references, but a bit slower at updating them.
  * Given the asymmetric nature of most wikis -- there are usually far more
@@ -365,17 +365,53 @@
                     // ========= page renamed ==============================
 
                 case (ContentEvent.NODE_RENAMED ): {
-                    // Update references from this page
                     WikiPath toPage = path;
                     WikiPath fromPage = WikiPath.valueOf( (String) ((WikiPageEvent) event).getArgs()[0]
);
                     Boolean changeReferrers = (Boolean) ((WikiPageEvent) event).getArgs()[1];
+                    List<WikiPath> referrers = getReferredBy( fromPage );
+                    
+                    // Delete all references to the old page name
                     removeLinks( fromPage );
                     setLinks( toPage, extractLinks( toPage ) );
 
-                    // Change references to the old page; use the new name
+                    // In every referrer, replace all references to the old page with the
new one
                     if( changeReferrers )
                     {
-                        renameLinksTo( fromPage, toPage );
+                        ContentManager cm = m_engine.getContentManager();
+                        for( WikiPath referrer : referrers )
+                        {
+                            // In case the page was just changed from under us, let's do
this
+                            // small kludge.
+                            if( referrer.equals( fromPage ) )
+                            {
+                                referrer = toPage;
+                            }
+
+                            try
+                            {
+                                WikiPage p = cm.getPage( referrer );
+
+                                String sourceText = m_engine.getPureText( p );
+
+                                String newText = renameLinks( sourceText, fromPage.getPath(),
toPage.getPath() );
+
+                                if( m_camelCase )
+                                    newText = renameCamelCaseLinks( newText, fromPage.getPath(),
toPage.getPath() );
+
+                                if( !sourceText.equals( newText ) )
+                                {
+                                    p.setAttribute( WikiPage.CHANGENOTE, fromPage.toString()
+ " ==> " + toPage.toString() );
+                                    p.setContent( newText );
+                                    // TODO: do we want to set the author here? (We used
to...)
+                                    cm.save( p );
+                                    setLinks( path, extractLinks( toPage ) );
+                                }
+                            }
+                            catch( PageNotFoundException e )
+                            {
+                                // Just continue
+                            }
+                        }
                     }
 
                     m_cm.getCurrentSession().save();
@@ -675,62 +711,6 @@
     }
 
     /**
-     * This method finds all the pages which refer to <code>oldPath</code> and
-     * change their references to <code>newPath</code>.
-     * 
-     * @param oldPath The old page
-     * @param newPath The new page
-     */
-    private void renameLinksTo( WikiPath oldPath, WikiPath newPath ) throws ProviderException,
RepositoryException
-    {
-        if ( oldPath == null || newPath == null )
-        {
-            throw new IllegalArgumentException( "oldPath and newPath cannot be null!" );
-        }
-        
-        List<WikiPath> referrers = getReferredBy( oldPath );
-        if( referrers.isEmpty() )
-            return; // No referrers
-
-        for( WikiPath path : referrers )
-        {
-            // In case the page was just changed from under us, let's do this
-            // small kludge.
-            if( path.equals( oldPath.getPath() ) )
-            {
-                path = newPath;
-            }
-
-            try
-            {
-                ContentManager cm = m_engine.getContentManager();
-                WikiPage p = cm.getPage( path );
-
-                String sourceText = m_engine.getPureText( p );
-
-                String newText = renameLinks( sourceText, oldPath.toString(), newPath.toString()
);
-
-                if( m_camelCase )
-                    newText = renameCamelCaseLinks( newText, oldPath.toString(), newPath.toString()
);
-
-                if( !sourceText.equals( newText ) )
-                {
-                    p.setAttribute( WikiPage.CHANGENOTE, oldPath.toString() + " ==> "
+ newPath.toString() );
-                    p.setContent( newText );
-                    // TODO: do we want to set the author here? (We used to...)
-                    cm.save( p );
-                    setLinks( path, extractLinks( newPath ) );
-                    cm.getCurrentSession().save();
-                }
-            }
-            catch( PageNotFoundException e )
-            {
-                // Just continue
-            }
-        }
-    }
-
-    /**
      * Returns a resolved WikiPath, taking into account plural variants as
      * determined by {@link WikiEngine#getFinalPageName(WikiPath)}. For
      * example, if page <code>Foobar</code> exists, and the path supplied to

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/resolver/SpecialPageNameResolver.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/resolver/SpecialPageNameResolver.java?rev=825387&r1=825386&r2=825387&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/resolver/SpecialPageNameResolver.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/resolver/SpecialPageNameResolver.java
Thu Oct 15 04:23:21 2009
@@ -71,7 +71,9 @@
 
     /**
      * Determines whether a "page" exists by examining the list of special pages
-     * and querying the page manager.
+     * and querying the page manager. The WikiPath will be tried with its qualifying
+     * space, and without. This means that if the value of {@code page} is "Main:FindPage",
+     * special pages called "FindPage" or "Main:FindPage" would match.
      * 
      * @param page the page to seek
      * @return <code>true</code> if the page exists, <code>false</code>
@@ -79,7 +81,7 @@
      */
     protected final boolean simplePageExists( WikiPath page ) throws ProviderException
     {
-        if( m_specialRedirects.containsKey( page ) )
+        if( m_specialRedirects.containsKey( page ) || m_specialRedirects.containsKey( page.getPath()
) )
         {
             return true;
         }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java?rev=825387&r1=825386&r2=825387&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java Thu Oct
15 04:23:21 2009
@@ -444,12 +444,14 @@
             if( page == null || page.length() == 0 ) return null;
 
             WikiPath path = WikiPath.valueOf( page );
-            WikiPath finalPath = m_engine.getFinalPageName( path );
-            path = finalPath != null ? finalPath : path;
-            if ( m_engine.pageExists( path.toString() ) )
+            WikiPath resolved = m_engine.getFinalPageName( path );
+            if ( resolved != null )
             {
-                String pageLink = ContentManager.DEFAULT_SPACE.equals( path.getSpace() )
? path.getPath() : path.toString();
-                return pageLink;
+                return ContentManager.DEFAULT_SPACE.equals( resolved.getSpace() ) ? resolved.getPath()
: resolved.toString();
+            }
+            else if ( m_engine.pageExists( path.toString() ) )
+            {
+                return ContentManager.DEFAULT_SPACE.equals( path.getSpace() ) ? path.getPath()
: path.toString();
             }
             return null;
         }

Added: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/IsOneOf.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/IsOneOf.java?rev=825387&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/IsOneOf.java (added)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/IsOneOf.java Thu Oct 15 04:23:21
2009
@@ -0,0 +1,53 @@
+package org.apache.wiki.ui.stripes;
+
+import net.sourceforge.stripes.util.ResolverUtil.Test;
+
+/**
+ * Implementation of {@link net.sourceforge.stripes.util.ResolverUtil.Test} used
+ * with Stripes {@link net.sourceforge.stripes.util.ResolverUtil} to discover
+ * classes.
+ */
+public class IsOneOf implements Test
+{
+    private final Class<?>[] m_parents;
+
+    /**
+     * Constructs a new IsOneOf ResolverUtil tester with a series of specified
+     * types.
+     * 
+     * @param parentTypes a series of parent types that the type under test must
+     *            match.
+     */
+    public IsOneOf( Class<?>... parentTypes )
+    {
+        super();
+        m_parents = parentTypes;
+    }
+
+    /**
+     * Returns true if type is assignable to one of the parent types supplied in
+     * the constructor.
+     */
+    @SuppressWarnings( "unchecked" )
+    public boolean matches( Class type )
+    {
+        if( type == null )
+        {
+            return false;
+        }
+        for( Class<?> parent : m_parents )
+        {
+            if( parent.isAssignableFrom( type ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "is assignable to " + m_parents;
+    }
+}

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=825387&r1=825386&r2=825387&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 Thu
Oct 15 04:23:21 2009
@@ -55,8 +55,12 @@
         }
     }
 
-    public void tearDown()
+    public void tearDown() throws Exception
     {
+        m_engine.deletePage( "ReferstoTest" );
+        m_engine.deletePage( "Test" );
+        m_engine.deletePage( "TestCollision" );
+        m_engine.deletePage( "TestRenamed" );
         m_engine.shutdown();
     }
     
@@ -87,9 +91,6 @@
         assertEquals( 1, errors.size() );
         assertTrue( errors.containsKey("renameTo") );
         assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-    
-        // Delete test page
-        m_engine.deletePage( "Test" );
     }
     
     public void testValidationWithCollision() throws Exception {
@@ -113,10 +114,6 @@
         assertEquals( 1, errors.size() );
         assertTrue ( errors.containsKey( "renameTo" ) );
         assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-    
-        // Delete test page
-        m_engine.deletePage( "Test" );
-        m_engine.deletePage( "TestCollision" );
     }
     
     public void testRename() throws Exception {
@@ -138,9 +135,6 @@
         assertEquals( "/Wiki.action?page=TestRenamed", trip.getDestination() );
         assertFalse( m_engine.pageExists( "Test" ) );
         assertTrue( m_engine.pageExists( "TestRenamed" ) );
-    
-        // Delete test page
-        m_engine.deletePage( "TestRenamed" );
     }
     
     public void testRenameReferences() throws Exception {
@@ -170,7 +164,6 @@
         assertTrue( m_engine.pageExists( "TestRenamed" ) );
         referringText = m_engine.getPureText( m_engine.getPage("ReferstoTest") );
         assertFalse( referringText.contains("[TestRenamed]"));
-        m_engine.deletePage( "TestRenamed" );
     }
     
     public void testRenameReferencesChangeRefsFalse() throws Exception {
@@ -217,9 +210,6 @@
         referringText = m_engine.getPureText( m_engine.getPage("ReferstoTest") );
         assertTrue( referringText.contains("[TestRenamed]"));
         m_engine.deletePage( "TestRenamed" );
-        
-        // Clean up
-        m_engine.deletePage( "ReferstoTest" );
     }
     
     public void testRenameToSameName() throws Exception {
@@ -235,9 +225,6 @@
         errors = trip.getValidationErrors();
         assertEquals( 1, errors.size() );
         m_engine.deletePage( "Test" );
-        
-        // Clean up
-        m_engine.deletePage( "Test" );
     }
     
     public static Test suite()

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=825387&r1=825386&r2=825387&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 Thu Oct
15 04:23:21 2009
@@ -76,20 +76,20 @@
         // Count the number of existing references
         int pageCount = m_engine.getPageCount();
         
-        m_engine.saveText("TestPage", "the big lazy dog thing" );
+        m_engine.saveText("SimpleRename", "the big lazy dog thing" );
         
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPage("SimpleRename");
         
         WikiContext context = m_engine.getWikiContextFactory().newViewContext( p );
         
-        m_engine.renamePage(context, "TestPage", "FooTest", false);
+        m_engine.renamePage(context, "SimpleRename", "FooRename", false);
         
-        WikiPage newpage = m_engine.getPage("FooTest");
+        WikiPage newpage = m_engine.getPage("FooRename");
         
         assertNotNull( "no new page", newpage );
         try
         {
-            m_engine.getPage("TestPage");
+            m_engine.getPage("SimpleRename");
         
             fail( "old page not gone" );
         }
@@ -99,34 +99,35 @@
         
         Set<String> pages = m_engine.getReferenceManager().findCreated();
         
-        assertTrue( "FooTest does not exist", pages.contains( "Main:FooTest" ) );
-        assertFalse( "TestPage exists", pages.contains( "Main:TestPage" ) );
+        assertTrue( "FooRename does not exist", pages.contains( "Main:FooRename" ) );
+        assertFalse( "SimpleRename exists", pages.contains( "Main:SimpleRename" ) );
         assertEquals( "wrong list size", pageCount+1, pages.size() );
+        m_engine.deletePage( "Main:FooRename" );
     }
     
     public void testReferrerChange()
        throws Exception
     {
-        m_engine.saveText("TestPage", "foofoo" );
-        m_engine.saveText("TestPage2", "[TestPage]");
+        m_engine.saveText("ReferrerChange", "foofoo" );
+        m_engine.saveText("ReferrerChange2", "[ReferrerChange]");
         
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPage("ReferrerChange");
         
         WikiContext context = m_engine.getWikiContextFactory().newViewContext( p );
         
-        m_engine.renamePage(context, "TestPage", "FooTest", true);
-        
-        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+        m_engine.renamePage(context, "ReferrerChange", "FooReferrerChange", true);
         
-        assertEquals( "no rename", "[FooTest]", data.trim() );
+        // Verify that reference to ReferrerChange was renamed
+        String data = m_engine.getPureText("ReferrerChange2", WikiProvider.LATEST_VERSION);
+        assertEquals( "no rename", "[FooReferrerChange]", data.trim() );
         
-        Collection<WikiPath> refs = findReferrers("TestPage");
+        Collection<WikiPath> refs = findReferrers("ReferrerChange");
         
-        assertNull( "oldpage", refs );
+        assertEquals( 0, refs.size() );
         
-        refs = findReferrers( "FooTest" );
+        refs = findReferrers( "FooReferrerChange" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", refs.iterator().next() );
+        assertEquals( "wrong ref", WikiPath.valueOf( "Main:ReferrerChange2" ), refs.iterator().next()
);
     }
 
     public void testReferrerChangeCC()
@@ -146,11 +147,11 @@
         assertEquals( "no rename", "FooTest", data.trim() );
         Collection<WikiPath> refs = findReferrers("TestPage");
         
-        assertNull( "oldpage", refs );
+        assertEquals( 0, refs.size() );
         
         refs = findReferrers( "FooTest" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", refs.iterator().next() );
+        assertEquals( "wrong ref", WikiPath.valueOf( "Main:TestPage2" ), refs.iterator().next()
);
     }
     
     public void testReferrerChangeAnchor()
@@ -170,11 +171,11 @@
         assertEquals( "no rename", "[FooTest#heading1]", data.trim() );
         Collection<WikiPath> refs = findReferrers("TestPage");
         
-        assertNull( "oldpage", refs );
+        assertEquals( 0, refs.size() );
         
         refs = findReferrers( "FooTest" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", refs.iterator().next() );
+        assertEquals( "wrong ref", WikiPath.valueOf( "Main:TestPage2" ), refs.iterator().next()
);
     }
     
     public void testReferrerChangeMultilink()
@@ -197,11 +198,11 @@
 
         Collection<WikiPath> refs = findReferrers("TestPage");
         
-        assertNull( "oldpage", refs );
+        assertEquals( 0, refs.size() );
         
         refs = findReferrers( "FooTest" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPage2", refs.iterator().next() );
+        assertEquals( "wrong ref", WikiPath.valueOf( "Main:TestPage2" ), refs.iterator().next()
);
     }
     
     public void testReferrerNoWikiName()
@@ -210,7 +211,7 @@
         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");
+        WikiPage p = m_engine.getPage("Test");
         
         WikiContext context = m_engine.getWikiContextFactory().newViewContext( p );
      
@@ -305,7 +306,7 @@
         assertEquals("[|FooTest]", m_engine.getText("TestPage2").trim() );
     }
 
-    private void rename( String src, String dst ) throws Exception
+    private void rename( String src, String dst ) throws WikiException, PageNotFoundException
     {
         WikiPage p = m_engine.getPage(src);
 
@@ -374,7 +375,7 @@
             System.out.println("NPE: Bug 85 caught?");
             fail();
         }
-        catch( WikiException e )
+        catch( PageNotFoundException e )
         {
             // Expected
         }
@@ -414,7 +415,7 @@
             System.out.println("NPE: Bug 85 caught?");
             fail();
         }
-        catch( WikiException e )
+        catch( PageNotFoundException e )
         {
             // Expected
         }
@@ -478,11 +479,11 @@
         assertEquals( "page not renamed", "[Test Page Referred|TestPageReferredNew]", data.trim()
);
 
         Collection<WikiPath> refs = findReferrers( "TestPageReferred" );
-        assertNull( "oldpage", refs );
+        assertEquals( 0, refs.size() );
 
         refs = findReferrers( "TestPageReferredNew" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "TestPageReferring", refs.iterator().next() );
+        assertEquals( "wrong ref", WikiPath.valueOf( "TestPageReferring" ), refs.iterator().next()
);
     }
 
     /** https://issues.apache.org/jira/browse/JSPWIKI-398 */
@@ -498,11 +499,11 @@
         assertEquals( "page not renamed", "[link one|Link uno] [link two]", data.trim() );
 
         Collection<WikiPath> refs = findReferrers( "Link one" );
-        assertNull( "oldpage", refs );
+        assertEquals( 0, refs.size() );
 
         refs = findReferrers( "Link uno" );
         assertEquals( "new size", 1, refs.size() );
-        assertEquals( "wrong ref", "RenameTest", refs.iterator().next() );
+        assertEquals( "wrong ref", WikiPath.valueOf( "RenameTest" ), refs.iterator().next()
);
     }
 
     public static Test suite()

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/AllTests.java?rev=825387&r1=825386&r2=825387&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/AllTests.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/AllTests.java Thu Oct 15
04:23:21 2009
@@ -31,6 +31,7 @@
         TestSuite suite = new TestSuite("Stripes UI tests");
         suite.addTest( FileBasedActionResolverTest.suite() );
         suite.addTest( HandlerInfoTest.suite() );
+        suite.addTest( IsOneOfTest.suite() );
         suite.addTest( ShortUrlRedirectFilterTest.suite() );
         suite.addTest( SpamInterceptorTest.suite() );
         return suite;

Added: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/IsOneOfTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/IsOneOfTest.java?rev=825387&view=auto
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/IsOneOfTest.java (added)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/IsOneOfTest.java Thu Oct
15 04:23:21 2009
@@ -0,0 +1,76 @@
+/*
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.    
+ */
+package org.apache.wiki.ui.stripes;
+
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import net.sourceforge.stripes.util.ResolverUtil;
+
+import org.apache.wiki.action.WikiActionBean;
+import org.apache.wiki.filters.PageFilter;
+import org.apache.wiki.plugin.WikiPlugin;
+
+public class IsOneOfTest extends TestCase
+{
+    public void testCoreMatches()
+    {
+        ResolverUtil<Object> resolver = new ResolverUtil<Object>();
+        ResolverUtil.Test test = new IsOneOf( WikiActionBean.class, PageFilter.class, WikiPlugin.class
);
+        resolver.find( test, "org.apache.wiki" );
+        Set<Class<? extends Object>> matches = resolver.getClasses();
+        assertEquals( 71, matches.size() );
+    }
+
+    public void testActionBeanMatches()
+    {
+        ResolverUtil<Object> resolver = new ResolverUtil<Object>();
+        ResolverUtil.Test test = new IsOneOf( WikiActionBean.class );
+        resolver.find( test, "org.apache.wiki.action" );
+        Set<Class<? extends Object>> matches = resolver.getClasses();
+        assertEquals( 24, matches.size() );
+    }
+
+    public void testPageFilterMatches()
+    {
+        ResolverUtil<Object> resolver = new ResolverUtil<Object>();
+        ResolverUtil.Test test = new IsOneOf( PageFilter.class );
+        resolver.find( test, "org.apache.wiki.filters" );
+        Set<Class<? extends Object>> matches = resolver.getClasses();
+        assertEquals( 7, matches.size() );
+    }
+
+    public void testWikiPluginMatches()
+    {
+        ResolverUtil<Object> resolver = new ResolverUtil<Object>();
+        ResolverUtil.Test test = new IsOneOf( WikiPlugin.class );
+        resolver.find( test, "org.apache.wiki.plugin" );
+        Set<Class<? extends Object>> matches = resolver.getClasses();
+        assertEquals( 30, matches.size() );
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite( IsOneOfTest.class );
+    }
+}



Mime
View raw message