craigmcc    2003/02/08 14:12:09

  Modified:    src/share/org/apache/struts/util RequestUtils.java
               src/test/org/apache/struts/util TestRequestUtils.java
  Log:
  Unit tests for the current behavior of RequestUtils.pageURL().  We deliberately
  do *not* do slash prepending here -- the input value must start with a slash.
  (Doing '/' prepending in forwardURL() was a bad idea IMHO, but apparently it
  was needed for Tiles, and now it's too late).
  
  Revision  Changes    Path
  1.84      +6 -5      
jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
  
  Index: RequestUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- RequestUtils.java 8 Feb 2003 21:20:19 -0000       1.83
  +++ RequestUtils.java 8 Feb 2003 22:12:09 -0000       1.84
  @@ -1458,7 +1458,8 @@
        *
        * @param request The servlet request we are processing
        * @param page The module-relative URL to be substituted in
  -     *  to the <code>pagePattern</code> pattern for the current module.
  +     *  to the <code>pagePattern</code> pattern for the current module
  +     *  (<strong>MUST</strong> start with a slash)
        * @return context-relative URL
        * @since Struts 1.1b2
        */
  
  
  
  1.17      +64 -4     
jakarta-struts/src/test/org/apache/struts/util/TestRequestUtils.java
  
  Index: TestRequestUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/test/org/apache/struts/util/TestRequestUtils.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TestRequestUtils.java     8 Feb 2003 21:01:52 -0000       1.16
  +++ TestRequestUtils.java     8 Feb 2003 22:12:09 -0000       1.17
  @@ -1403,6 +1403,66 @@
       }
   
   
  +    // -------------------------------------------------------------- pageURL()
  +
  +
  +    // Default module (default pagePattern)
  +    public void testPageURL1() {
  +
  +        request.setAttribute(Action.APPLICATION_KEY, appConfig);
  +        request.setPathElements("/myapp", "/action.do", null, null);
  +        String page = null;
  +        String result = null;
  +
  +        // Straight substitution
  +        page = "/mypages/index.jsp";
  +        result = RequestUtils.pageURL(request, page);
  +        assertNotNull("straight sub found", result);
  +        assertEquals("straight sub value",
  +                     "/mypages/index.jsp", result);
  +
  +
  +    }
  +
  +
  +    // Second module (default pagePattern)
  +    public void testPageURL2() {
  +
  +        request.setAttribute(Action.APPLICATION_KEY, appConfig2);
  +        request.setPathElements("/myapp", "/2/action.do", null, null);
  +        String page = null;
  +        String result = null;
  +
  +        // Straight substitution
  +        page = "/mypages/index.jsp";
  +        result = RequestUtils.pageURL(request, page);
  +        assertNotNull("straight sub found", result);
  +        assertEquals("straight sub value",
  +                     "/2/mypages/index.jsp", result);
  +
  +
  +    }
  +
  +
  +    // Third module (custom pagePattern)
  +    public void testPageURL3() {
  +
  +        request.setAttribute(Action.APPLICATION_KEY, appConfig3);
  +        request.setPathElements("/myapp", "/3/action.do", null, null);
  +        String page = null;
  +        String result = null;
  +
  +        // Straight substitution
  +        page = "/mypages/index.jsp";
  +        result = RequestUtils.pageURL(request, page);
  +        assertNotNull("straight sub found", result);
  +        assertEquals("straight sub value",
  +                     "/paging/3/mypages/index.jsp", result);
  +
  +
  +    }
  +
  +
       // ----------------------------------------------------------- requestURL()
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to