jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r730429 - in /incubator/jspwiki/trunk: src/com/ecyrd/jspwiki/action/ tests/com/ecyrd/jspwiki/action/ tests/com/ecyrd/jspwiki/ui/migrator/ tests/com/ecyrd/jspwiki/ui/stripes/
Date Wed, 31 Dec 2008 17:41:01 GMT
Author: ajaquith
Date: Wed Dec 31 09:41:01 2008
New Revision: 730429

URL: http://svn.apache.org/viewvc?rev=730429&view=rev
Log:
Fixed failing unit tests. With one exception, we now run 99.8% clean.

Modified:
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java
    incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/LoginActionBeanTest.java
    incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java
    incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/migrator/JspParserTest.java
    incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/stripes/HandlerInfoTest.java

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java?rev=730429&r1=730428&r2=730429&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java Wed
Dec 31 09:41:01 2008
@@ -77,7 +77,6 @@
     @HandlerPermission( permissionClass = WikiPermission.class, target = "${context.engine.applicationName}",
actions = WikiPermission.EDIT_PREFERENCES_ACTION )
     public Resolution createAssertedName()
     {
-        // FIXME: should reload preferences (see Preferences.reloadPreferences)
         if( !getContext().getWikiSession().isAuthenticated() )
         {
             HttpServletRequest request = getContext().getRequest();

Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/LoginActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/LoginActionBeanTest.java?rev=730429&r1=730428&r2=730429&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/LoginActionBeanTest.java (original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/LoginActionBeanTest.java Wed Dec
31 09:41:01 2008
@@ -169,7 +169,7 @@
         // Log in
         trip.setParameter( "j_username", Users.JANNE );
         trip.setParameter( "j_password", Users.JANNE_PASS );
-        trip.setParameter( "j_remember", "true" );
+        trip.setParameter( "remember", "true" );
         trip.execute( "login" );
 
         // Verify we logged in correctly

Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java?rev=730429&r1=730428&r2=730429&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java
(original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java
Wed Dec 31 09:41:01 2008
@@ -39,97 +39,94 @@
 public class UserPreferencesActionBeanTest extends TestCase
 {
     TestEngine m_engine;
-    
+
     public void setUp()
     {
         // Start the WikiEngine, and stash reference
         Properties props = new Properties();
-        try 
+        try
         {
             props.load( TestEngine.findTestProperties() );
             m_engine = new TestEngine( props );
         }
-        catch (Exception e)
+        catch( Exception e )
         {
-            throw new RuntimeException("Could not set up TestEngine: " + e.getMessage());
+            throw new RuntimeException( "Could not set up TestEngine: " + e.getMessage()
);
         }
     }
-    
+
     public void testCreateAssertedName() throws Exception
     {
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
-        
+
         // Create session; set 'assertion' param; verify it got saved
-        trip = m_engine.guestTrip( "/UserPreferences.action");
-        trip.setParameter("assertedName", "MyAssertedIdentity");
-        trip.setParameter("createAssertedName", "true");
-        trip.execute();
-        bean = trip.getActionBean(UserPreferencesActionBean.class);
-        assertEquals("/", trip.getDestination());
-        
+        trip = m_engine.guestTrip( "/UserPreferences.action" );
+        trip.setParameter( "assertedName", "MyAssertedIdentity" );
+        trip.execute( "createAssertedName" );
+        bean = trip.getActionBean( UserPreferencesActionBean.class );
+        assertEquals( "/Wiki.action", trip.getDestination() );
+
         // Verify that the asserted name cookie is present in the Response
-        MockHttpServletResponse response = (MockHttpServletResponse)bean.getContext().getResponse();
+        MockHttpServletResponse response = (MockHttpServletResponse) bean.getContext().getResponse();
         Cookie[] cookies = response.getCookies();
-        assertEquals(1, cookies.length);
+        assertEquals( 1, cookies.length );
         Cookie cookie = cookies[0];
-        assertEquals(CookieAssertionLoginModule.PREFS_COOKIE_NAME,cookie.getName());
-        assertEquals("MyAssertedIdentity",cookie.getValue());
+        assertEquals( CookieAssertionLoginModule.PREFS_COOKIE_NAME, cookie.getName() );
+        assertEquals( "MyAssertedIdentity", cookie.getValue() );
     }
-    
+
     public void testCreateAssertedNameAfterLogin() throws Exception
     {
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
-        
+
         // Create session; login in as Janne
-        trip = m_engine.guestTrip( "/UserPreferences.action");
+        trip = m_engine.guestTrip( "/UserPreferences.action" );
         MockHttpServletRequest request = trip.getRequest();
-        WikiSession wikiSession = WikiSession.getWikiSession(m_engine, request);
-        boolean login = m_engine.getAuthenticationManager().login(wikiSession, Users.JANNE,Users.JANNE_PASS);
-        assertTrue("Could not log in.", login);
-        
+        WikiSession wikiSession = WikiSession.getWikiSession( m_engine, request );
+        boolean login = m_engine.getAuthenticationManager().login( wikiSession, Users.JANNE,
Users.JANNE_PASS );
+        assertTrue( "Could not log in.", login );
+
         // Set 'assertion' param; verify redirect to front page
-        trip.setParameter("assertedName", "MyAssertedIdentity");
-        trip.setParameter("createAssertedName", "true");
-        trip.execute();
-        bean = trip.getActionBean(UserPreferencesActionBean.class);
-        assertEquals("/", trip.getDestination());
-        
+        trip.setParameter( "assertedName", "MyAssertedIdentity" );
+        trip.execute( "createAssertedName" );
+        bean = trip.getActionBean( UserPreferencesActionBean.class );
+        assertEquals( "/Wiki.action", trip.getDestination() );
+
         // Verify that the asserted name cookie is NOT present in the Response
         // (authenticated users cannot set the assertion cookie)
-        MockHttpServletResponse response = (MockHttpServletResponse)bean.getContext().getResponse();
+        MockHttpServletResponse response = (MockHttpServletResponse) bean.getContext().getResponse();
         Cookie[] cookies = response.getCookies();
-        assertEquals(0, cookies.length);
+        assertEquals( 0, cookies.length );
     }
-    
+
     public void testClearAssertedName() throws Exception
     {
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
-        
+
         // Create session; set 'assertion' param; verify it got saved
-        trip = m_engine.guestTrip( "/UserPreferences.action");
+        trip = m_engine.guestTrip( "/UserPreferences.action" );
         MockHttpServletRequest request = trip.getRequest();
-        Cookie cookie = new Cookie(CookieAssertionLoginModule.PREFS_COOKIE_NAME, "MyAssertedIdentity");
-        request.setCookies(new Cookie[]{cookie});
-        trip.setParameter("clearAssertedName", "true");
-        trip.execute();
-        bean = trip.getActionBean(UserPreferencesActionBean.class);
-        assertEquals("/Logout.jsp", trip.getDestination());
-        
+        Cookie cookie = new Cookie( CookieAssertionLoginModule.PREFS_COOKIE_NAME, "MyAssertedIdentity"
);
+        request.setCookies( new Cookie[] { cookie } );
+        trip.execute( "clearAssertedName" );
+        bean = trip.getActionBean( UserPreferencesActionBean.class );
+        assertEquals( "/Login.action?logout=", trip.getDestination() );
+
         // Verify that the asserted name cookie is gone from the Response
-        MockHttpServletResponse response = (MockHttpServletResponse)bean.getContext().getResponse();
+        MockHttpServletResponse response = (MockHttpServletResponse) bean.getContext().getResponse();
         Cookie[] cookies = response.getCookies();
-        assertEquals(1, cookies.length);
+        assertEquals( 1, cookies.length );
         cookie = cookies[0];
-        assertEquals(CookieAssertionLoginModule.PREFS_COOKIE_NAME,cookie.getName());
-        assertEquals("",cookie.getValue());
+        assertEquals( CookieAssertionLoginModule.PREFS_COOKIE_NAME, cookie.getName() );
+        assertEquals( "", cookie.getValue() );
     }
-    
+
     public static Test suite()
     {
         return new TestSuite( UserPreferencesActionBeanTest.class );
     }
-    
+
 }

Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/migrator/JspParserTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/migrator/JspParserTest.java?rev=730429&r1=730428&r2=730429&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/migrator/JspParserTest.java (original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/migrator/JspParserTest.java Wed Dec
31 09:41:01 2008
@@ -340,12 +340,12 @@
         JspParser parser = new JspParser();
         JspDocument doc = parser.parse( s );
 
-        // Should result in 18 nodes parsed (10 tags/directives + 8
+        // Should result in 14 nodes parsed (7 tags/directives + 7
         // text/whitespace nodes
         Node node;
         Node attribute;
         List<Node> nodes = doc.getNodes();
-        assertEquals( 20, nodes.size() );
+        assertEquals( 14, nodes.size() );
         int i = 0;
 
         // Test line 1 aka nodes 0+1
@@ -353,26 +353,29 @@
         assertEquals( 1, node.getLine() );
         assertEquals( 1, node.getColumn() );
         assertEquals( 0, node.getStart() );
-        assertEquals( 49, node.getEnd() );
+        assertEquals( 79, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.JSP_DIRECTIVE, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "page", node.getName() );
-        assertEquals( 1, ((Tag) node).getAttributes().size() );
+        assertEquals( 6, node.getSiblings().size() );
+        assertEquals( "taglib", node.getName() );
+        assertEquals( 2, ((Tag) node).getAttributes().size() );
         attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "import", attribute.getName() );
-        assertEquals( "com.ecyrd.jspwiki.log.Logger", attribute.getValue() );
+        assertEquals( "uri", attribute.getName() );
+        assertEquals( "http://stripes.sourceforge.net/stripes.tld", attribute.getValue()
);
+        attribute = ((Tag) node).getAttributes().get( 1 );
+        assertEquals( "prefix", attribute.getName() );
+        assertEquals( "stripes", attribute.getValue() );
         i++;
         node = nodes.get( i );
         assertEquals( 1, node.getLine() );
-        assertEquals( 50, node.getColumn() );
-        assertEquals( 49, node.getStart() );
-        assertEquals( 50, node.getEnd() );
+        assertEquals( 80, node.getColumn() );
+        assertEquals( 79, node.getStart() );
+        assertEquals( 80, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
+        assertEquals( 6, node.getSiblings().size() );
         assertEquals( "(TEXT)", node.getName() );
         i++;
 
@@ -380,27 +383,27 @@
         node = nodes.get( i );
         assertEquals( 2, node.getLine() );
         assertEquals( 1, node.getColumn() );
-        assertEquals( 50, node.getStart() );
-        assertEquals( 106, node.getEnd() );
+        assertEquals( 80, node.getStart() );
+        assertEquals( 191, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.JSP_DIRECTIVE, node.getType() );
+        assertEquals( NodeType.EMPTY_ELEMENT_TAG, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "page", node.getName() );
-        assertEquals( 1, ((Tag) node).getAttributes().size() );
+        assertEquals( 6, node.getSiblings().size() );
+        assertEquals( "stripes:useActionBean", node.getName() );
+        assertEquals( 3, ((Tag) node).getAttributes().size() );
         attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "import", attribute.getName() );
-        assertEquals( "com.ecyrd.jspwiki.log.LoggerFactory", attribute.getValue() );
+        assertEquals( "beanclass", attribute.getName() );
+        assertEquals( "com.ecyrd.jspwiki.action.LoginActionBean", attribute.getValue() );
         i++;
         node = nodes.get( i );
         assertEquals( 2, node.getLine() );
-        assertEquals( 57, node.getColumn() );
-        assertEquals( 106, node.getStart() );
-        assertEquals( 107, node.getEnd() );
+        assertEquals( 112, node.getColumn() );
+        assertEquals( 191, node.getStart() );
+        assertEquals( 192, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
+        assertEquals( 6, node.getSiblings().size() );
         assertEquals( "(TEXT)", node.getName() );
         i++;
 
@@ -408,114 +411,108 @@
         node = nodes.get( i );
         assertEquals( 3, node.getLine() );
         assertEquals( 1, node.getColumn() );
-        assertEquals( 107, node.getStart() );
-        assertEquals( 147, node.getEnd() );
-        assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.JSP_DIRECTIVE, node.getType() );
+        assertEquals( 192, node.getStart() );
+        assertEquals( 256, node.getEnd() );
+        assertEquals( 4, node.getChildren().size() );
+        assertEquals( NodeType.START_TAG, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "page", node.getName() );
+        assertEquals( 6, node.getSiblings().size() );
+        assertEquals( "stripes:layout-render", node.getName() );
         assertEquals( 1, ((Tag) node).getAttributes().size() );
         attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "import", attribute.getName() );
-        assertEquals( "com.ecyrd.jspwiki.*", attribute.getValue() );
+        assertEquals( "name", attribute.getName() );
+        assertEquals( "/templates/default/ViewLayout.jsp", attribute.getValue() );
         i++;
         node = nodes.get( i );
         assertEquals( 3, node.getLine() );
-        assertEquals( 41, node.getColumn() );
-        assertEquals( 147, node.getStart() );
-        assertEquals( 148, node.getEnd() );
+        assertEquals( 65, node.getColumn() );
+        assertEquals( 256, node.getStart() );
+        assertEquals( 259, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
+        assertEquals( NodeType.START_TAG, node.getParent().getType() );
+        assertEquals( 3, node.getSiblings().size() );
         assertEquals( "(TEXT)", node.getName() );
         i++;
 
         // Test line 4 aka nodes 6+7
         node = nodes.get( i );
         assertEquals( 4, node.getLine() );
-        assertEquals( 1, node.getColumn() );
-        assertEquals( 148, node.getStart() );
-        assertEquals( 195, node.getEnd() );
-        assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.JSP_DIRECTIVE, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "page", node.getName() );
+        assertEquals( 3, node.getColumn() );
+        assertEquals( 259, node.getStart() );
+        assertEquals( 300, node.getEnd() );
+        assertEquals( 3, node.getChildren().size() );
+        assertEquals( NodeType.START_TAG, node.getType() );
+        assertEquals( NodeType.START_TAG, node.getParent().getType() );
+        assertEquals( 3, node.getSiblings().size() );
+        assertEquals( "stripes:layout-component", node.getName() );
         assertEquals( 1, ((Tag) node).getAttributes().size() );
         attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "import", attribute.getName() );
-        assertEquals( "com.ecyrd.jspwiki.action.*", attribute.getValue() );
+        assertEquals( "name", attribute.getName() );
+        assertEquals( "content", attribute.getValue() );
         i++;
         node = nodes.get( i );
         assertEquals( 4, node.getLine() );
-        assertEquals( 48, node.getColumn() );
-        assertEquals( 195, node.getStart() );
-        assertEquals( 196, node.getEnd() );
+        assertEquals( 44, node.getColumn() );
+        assertEquals( 300, node.getStart() );
+        assertEquals( 305, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
+        assertEquals( NodeType.START_TAG, node.getParent().getType() );
+        assertEquals( 2, node.getSiblings().size() );
         assertEquals( "(TEXT)", node.getName() );
         i++;
 
         // Test line 5 aka nodes 8+9
         node = nodes.get( i );
         assertEquals( 5, node.getLine() );
-        assertEquals( 1, node.getColumn() );
-        assertEquals( 196, node.getStart() );
-        assertEquals( 230, node.getEnd() );
+        assertEquals( 5, node.getColumn() );
+        assertEquals( 305, node.getStart() );
+        assertEquals( 363, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.JSP_DIRECTIVE, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "page", node.getName() );
+        assertEquals( NodeType.EMPTY_ELEMENT_TAG, node.getType() );
+        assertEquals( NodeType.START_TAG, node.getParent().getType() );
+        assertEquals( 2, node.getSiblings().size() );
+        assertEquals( "jsp:include", node.getName() );
         assertEquals( 1, ((Tag) node).getAttributes().size() );
         attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "errorPage", attribute.getName() );
-        assertEquals( "/Error.jsp", attribute.getValue() );
+        assertEquals( "page", attribute.getName() );
+        assertEquals( "/templates/default/LoginContent.jsp", attribute.getValue() );
         i++;
         node = nodes.get( i );
         assertEquals( 5, node.getLine() );
-        assertEquals( 35, node.getColumn() );
-        assertEquals( 230, node.getStart() );
-        assertEquals( 231, node.getEnd() );
+        assertEquals( 63, node.getColumn() );
+        assertEquals( 363, node.getStart() );
+        assertEquals( 366, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
+        assertEquals( NodeType.START_TAG, node.getParent().getType() );
+        assertEquals( 2, node.getSiblings().size() );
         assertEquals( "(TEXT)", node.getName() );
         i++;
         
         // Test line 6 aka nodes 10+11
         node = nodes.get( i );
         assertEquals( 6, node.getLine() );
-        assertEquals( 1, node.getColumn() );
-        assertEquals( 231, node.getStart() );
-        assertEquals( 285, node.getEnd() );
+        assertEquals( 3, node.getColumn() );
+        assertEquals( 366, node.getStart() );
+        assertEquals( 393, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.JSP_DIRECTIVE, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "taglib", node.getName() );
-        assertEquals( 2, ((Tag) node).getAttributes().size() );
-        attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "uri", attribute.getName() );
-        assertEquals( "/WEB-INF/jspwiki.tld", attribute.getValue() );
-        attribute = ((Tag) node).getAttributes().get( 1 );
-        assertEquals( "prefix", attribute.getName() );
-        assertEquals( "wiki", attribute.getValue() );
+        assertEquals( NodeType.END_TAG, node.getType() );
+        assertEquals( NodeType.START_TAG, node.getParent().getType() );
+        assertEquals( 3, node.getSiblings().size() );
+        assertEquals( "stripes:layout-component", node.getName() );
+        assertEquals( 0, ((Tag) node).getAttributes().size() );
         i++;
         node = nodes.get( i );
         assertEquals( 6, node.getLine() );
-        assertEquals( 55, node.getColumn() );
-        assertEquals( 285, node.getStart() );
-        assertEquals( 286, node.getEnd() );
+        assertEquals( 30, node.getColumn() );
+        assertEquals( 393, node.getStart() );
+        assertEquals( 394, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
+        assertEquals( NodeType.START_TAG, node.getParent().getType() );
+        assertEquals( 3, node.getSiblings().size() );
         assertEquals( "(TEXT)", node.getName() );
         i++;
 
@@ -523,126 +520,26 @@
         node = nodes.get( i );
         assertEquals( 7, node.getLine() );
         assertEquals( 1, node.getColumn() );
-        assertEquals( 286, node.getStart() );
-        assertEquals( 343, node.getEnd() );
+        assertEquals( 394, node.getStart() );
+        assertEquals( 418, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.JSP_DIRECTIVE, node.getType() );
+        assertEquals( NodeType.END_TAG, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "taglib", node.getName() );
-        assertEquals( 2, ((Tag) node).getAttributes().size() );
-        attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "uri", attribute.getName() );
-        assertEquals( "http://stripes.sourceforge.net/stripes.tld", attribute.getValue()
);
-        attribute = ((Tag) node).getAttributes().get( 1 );
-        assertEquals( "prefix", attribute.getName() );
-        assertEquals( "stripes", attribute.getValue() );
+        assertEquals( 6, node.getSiblings().size() );
+        assertEquals( "stripes:layout-render", node.getName() );
+        assertEquals( 0, ((Tag) node).getAttributes().size() );
         i++;
         node = nodes.get( i );
         assertEquals( 7, node.getLine() );
-        assertEquals( 58, node.getColumn() );
-        assertEquals( 343, node.getStart() );
-        assertEquals( 344, node.getEnd() );
-        assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.TEXT, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "(TEXT)", node.getName() );
-        i++;
-
-        // Test line 8 aka nodes 14+15
-        node = nodes.get( i );
-        assertEquals( 8, node.getLine() );
-        assertEquals( 1, node.getColumn() );
-        assertEquals( 344, node.getStart() );
-        assertEquals( 422, node.getEnd() );
-        assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.EMPTY_ELEMENT_TAG, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "stripes:useActionBean", node.getName() );
-
-        // Node 14 should have 1 attribute:
-        // beanclass="com.ecyrd.jspwiki.action.LoginActionBean"
-        assertEquals( 1, ((Tag) node).getAttributes().size() );
-        attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "beanclass", attribute.getName() );
-        assertEquals( NodeType.ATTRIBUTE, attribute.getType() );
-        assertEquals( "com.ecyrd.jspwiki.action.LoginActionBean", attribute.getValue() );
-        assertEquals( 'c', ((Tag) node).getAttributes().get( 0 ).getValue().charAt( 0 ) );
-        i++;
-
-        // Test line 8, node 15 (line break)
-        node = nodes.get( i );
-        assertEquals( 8, node.getLine() );
-        assertEquals( 79, node.getColumn() );
-        assertEquals( 422, node.getStart() );
-        assertEquals( 423, node.getEnd() );
+        assertEquals( 25, node.getColumn() );
+        assertEquals( 418, node.getStart() );
+        assertEquals( 419, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
+        assertEquals( 6, node.getSiblings().size() );
         assertEquals( "(TEXT)", node.getName() );
         i++;
-
-        // Test lines 9-20 aka nodes 16+17
-        node = nodes.get( i );
-        assertEquals( 9, node.getLine() );
-        assertEquals( 1, node.getColumn() );
-        assertEquals( 423, node.getStart() );
-        assertEquals( 842, node.getEnd() );
-        assertEquals( NodeType.JSP_DECLARATION, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "(TEXT)", node.getName() );
-        i++;
-        node = nodes.get( i );
-        assertEquals( 20, node.getLine() );
-        assertEquals( 3, node.getColumn() );
-        assertEquals( 842, node.getStart() );
-        assertEquals( 843, node.getEnd() );
-        assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.TEXT, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "(TEXT)", node.getName() );
-        i++;
-
-        // Test line 21-34 aka node 18
-        node = nodes.get( i );
-        assertEquals( 21, node.getLine() );
-        assertEquals( 1, node.getColumn() );
-        assertEquals( 843, node.getStart() );
-        assertEquals( 1583, node.getEnd() );
-        assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.SCRIPTLET, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "(TEXT)", node.getName() );
-        i++;
-
-        // Test second tag on line 34 aka node 19
-        node = nodes.get( i );
-        assertEquals( 34, node.getLine() );
-        assertEquals( 3, node.getColumn() );
-        assertEquals( 1583, node.getStart() );
-        assertEquals( 1623, node.getEnd() );
-        assertEquals( 0, node.getChildren().size() );
-        assertEquals( NodeType.EMPTY_ELEMENT_TAG, node.getType() );
-        assertEquals( NodeType.ROOT, node.getParent().getType() );
-        assertEquals( 19, node.getSiblings().size() );
-        assertEquals( "wiki:Include", node.getName() );
-
-        // AbstractNode 19 should have 1 attribute: page="<%=contentPage%>"
-        assertEquals( 1, ((Tag) node).getAttributes().size() );
-        attribute = ((Tag) node).getAttributes().get( 0 );
-        assertEquals( "page", attribute.getName() );
-        assertEquals( NodeType.ATTRIBUTE, attribute.getType() );
-        assertEquals( "<%=contentPage%>", attribute.getValue() );
-        assertEquals( 1, attribute.getChildren().size() );
-        assertEquals( NodeType.JSP_EXPRESSION, attribute.getChildren().get( 0 ).getType()
);
-        assertEquals( "contentPage", attribute.getChildren().get( 0 ).getValue() );
-        i++;
     }
 
     public void testParseNestedTags()

Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/stripes/HandlerInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/stripes/HandlerInfoTest.java?rev=730429&r1=730428&r2=730429&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/stripes/HandlerInfoTest.java (original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/ui/stripes/HandlerInfoTest.java Wed Dec
31 09:41:01 2008
@@ -32,9 +32,9 @@
 
 import com.ecyrd.jspwiki.TestEngine;
 import com.ecyrd.jspwiki.action.GroupActionBean;
+import com.ecyrd.jspwiki.action.ViewActionBean;
 import com.ecyrd.jspwiki.auth.permissions.GroupPermission;
 import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
-import com.ecyrd.jspwiki.ui.stripes.HandlerInfo;
 
 public class HandlerInfoTest extends TestCase
 {
@@ -66,7 +66,7 @@
     public void testPermissionAnnotations() throws Exception
     {
         Map<Method, HandlerInfo> map = HandlerInfo.getHandlerInfoCollection( GroupActionBean.class
);
-        assertEquals( 4, map.size() );
+        assertEquals( 5, map.size() );
 
         Method method = GroupActionBean.class.getMethod( "view", new Class[0] );
         assertTrue( map.containsKey( method ) );
@@ -86,6 +86,15 @@
         assertEquals( "edit", handlerInfo.getPermissionActions() );
         assertNull( handlerInfo.getActionsExpression() );
 
+        method = GroupActionBean.class.getMethod( "saveNew", new Class[0] );
+        assertTrue( map.containsKey( method ) );
+        handlerInfo = map.get( method );
+        assertEquals( WikiPermission.class, handlerInfo.getPermissionClass() );
+        assertEquals( "*", handlerInfo.getPermissionTarget() );
+        assertNull( handlerInfo.getPermissionTargetExpression() );
+        assertEquals( WikiPermission.CREATE_GROUPS_ACTION, handlerInfo.getPermissionActions()
);
+        assertNull( handlerInfo.getActionsExpression() );
+        
         method = GroupActionBean.class.getMethod( "delete", new Class[0] );
         assertTrue( map.containsKey( method ) );
         handlerInfo = map.get( method );
@@ -99,9 +108,9 @@
         assertTrue( map.containsKey( method ) );
         handlerInfo = map.get( method );
         assertEquals( WikiPermission.class, handlerInfo.getPermissionClass() );
-        assertEquals( WikiPermission.CREATE_GROUPS_ACTION, handlerInfo.getPermissionTarget()
);
+        assertEquals( "*", handlerInfo.getPermissionTarget() );
         assertNull( handlerInfo.getPermissionTargetExpression() );
-        assertNull( handlerInfo.getPermissionActions() );
+        assertEquals( WikiPermission.CREATE_GROUPS_ACTION, handlerInfo.getPermissionActions()
);
         assertNull( handlerInfo.getActionsExpression() );
     }
 
@@ -173,22 +182,25 @@
     public void testNotEvaluatedPermissionAnnotation() throws Exception
     {
         MockRoundtrip trip;
-        GroupActionBean bean;
+        ViewActionBean bean;
         Method method;
         HandlerInfo handlerInfo;
         Permission perm;
 
-        // Set up a new GroupActionBean with the non-existent group Foo
-        trip = m_engine.guestTrip( "/Group.action" );
-        trip.addParameter( "group", "Foo" );
+        // Set up a new ViewActionBean with the non-existent page Foobar
+        trip = m_engine.guestTrip( "/Wiki.action" );
+        trip.addParameter( "page", "Foobar" );
         trip.execute( "view" );
-        bean = trip.getActionBean( GroupActionBean.class );
+        bean = trip.getActionBean( ViewActionBean.class );
         assertNotNull( bean );
+        
+        // The Page should not exist
+        assertNull( bean.getPage() );
 
-        // The view handler should NOT return a "view" GroupPermission (because
+        // The view handler should NOT return a "view" PagePermission (because
         // EL can't evaluate)
-        method = GroupActionBean.class.getMethod( "view", new Class[0] );
-        Map<Method,HandlerInfo> handlerInfos = HandlerInfo.getHandlerInfoCollection(
GroupActionBean.class );
+        method = ViewActionBean.class.getMethod( "view", new Class[0] );
+        Map<Method,HandlerInfo> handlerInfos = HandlerInfo.getHandlerInfoCollection(
ViewActionBean.class );
         handlerInfo = handlerInfos.get( method );
         assertNotNull( handlerInfo );
         perm = handlerInfo.getPermission( bean );



Mime
View raw message