struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-struts/src/test/org/apache/struts/util TestRequestUtils.java
Date Sat, 27 Jul 2002 23:26:10 GMT
craigmcc    2002/07/27 16:26:09

  Modified:    .        STATUS
               src/share/org/apache/struts/util RequestUtils.java
               src/test/org/apache/struts/mock TestMockBase.java
               src/test/org/apache/struts/util TestRequestUtils.java
  Log:
  Fixed computeURL() so that it supports absolute and relative URLs again.  This
  fixes the bug in <html:link> that Ted reported, but I don't know what it does
  to forwards that are actually tiles definitions -- can someone please check
  that I didn't break this?
  
  PR: Bugzilla #11021
  Submitted by:	Ted Husted <husted at apache.org>
  
  Revision  Changes    Path
  1.44      +2 -3      jakarta-struts/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/STATUS,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- STATUS	27 Jul 2002 22:50:38 -0000	1.43
  +++ STATUS	27 Jul 2002 23:26:08 -0000	1.44
  @@ -6,12 +6,11 @@
               OUTSTANDING BUGS IN STRUTS 1.1-b1 AND NIGHTLY BUILDS
               ====================================================
   
  -                           13 open bugs to swat!!
  +                           12 open bugs to swat!!
   
   
   Controller:
   ----------
  -11021 ActionForward or <html:link> tag does not support absolute URIs
   11089 Data source keys are global, even when using application modules
   
   
  
  
  
  1.51      +10 -6     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.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- RequestUtils.java	27 Jul 2002 18:55:56 -0000	1.50
  +++ RequestUtils.java	27 Jul 2002 23:26:08 -0000	1.51
  @@ -412,8 +412,12 @@
               if (fc.getRedirect()) {
                   redirect = true;
               }
  -            url.append(request.getContextPath());
  -            url.append(forwardURL(request, fc));
  +            if (fc.getPath().startsWith("/")) {
  +                url.append(request.getContextPath());
  +                url.append(forwardURL(request, fc));
  +            } else {
  +                url.append(fc.getPath());
  +            }
           } else if (href != null) {
               url.append(href);
           } else /* if (page != null) */ {
  
  
  
  1.5       +14 -4     jakarta-struts/src/test/org/apache/struts/mock/TestMockBase.java
  
  Index: TestMockBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/test/org/apache/struts/mock/TestMockBase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestMockBase.java	10 Jul 2002 20:36:23 -0000	1.4
  +++ TestMockBase.java	27 Jul 2002 23:26:09 -0000	1.5
  @@ -160,6 +160,11 @@
           appConfig = new ApplicationConfig("");
           context.setAttribute(Action.APPLICATION_KEY, appConfig);
   
  +        // Forward "external" to "http://jakarta.apache.org/"
  +        appConfig.addForwardConfig
  +            (new ActionForward("external", "http://jakarta.apache.org/",
  +                               false, false));
  +
           // Forward "foo" to "/bar.jsp"
           appConfig.addForwardConfig
               (new ActionForward("foo", "/bar.jsp", false, false));
  @@ -223,6 +228,11 @@
   
           appConfig2 = new ApplicationConfig("/2");
           context.setAttribute(Action.APPLICATION_KEY + "/2", appConfig2);
  +
  +        // Forward "external" to "http://jakarta.apache.org/"
  +        appConfig2.addForwardConfig
  +            (new ActionForward("external", "http://jakarta.apache.org/",
  +                               false, false));
   
           // Forward "foo" to "/baz.jsp" (different from default)
           appConfig2.addForwardConfig
  
  
  
  1.10      +53 -8     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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestRequestUtils.java	24 Jul 2002 13:01:46 -0000	1.9
  +++ TestRequestUtils.java	27 Jul 2002 23:26:09 -0000	1.10
  @@ -605,7 +605,8 @@
           }
           assertNotNull("url present", url);
           assertEquals("url value",
  -                     "/myapp/relative.jsp",
  +                     //                     "/myapp/relative.jsp",
  +                     "relative.jsp",
                        url);
       }
   
  @@ -625,7 +626,28 @@
           }
           assertNotNull("url present", url);
           assertEquals("url value",
  -                     "/myapp/relative.jsp",
  +                     //                     "/myapp/relative.jsp",
  +                     "relative.jsp",
  +                     url);
  +    }
  +
  +
  +    // Default subapp -- Forward with external path
  +    public void testComputeURL1h() {
  +
  +        request.setPathElements("/myapp", "/action.do", null, null);
  +        String url = null;
  +        try {
  +            url = RequestUtils.computeURL
  +                (page, "external",
  +                 null, null,
  +                 null, null, false);
  +        } catch (MalformedURLException e) {
  +            fail("MalformedURLException: " + e);
  +        }
  +        assertNotNull("url present", url);
  +        assertEquals("url value",
  +                     "http://jakarta.apache.org/",
                        url);
       }
   
  @@ -760,7 +782,8 @@
           }
           assertNotNull("url present", url);
           assertEquals("url value",
  -                     "/myapp/2/relative.jsp",
  +                     //                     "/myapp/2/relative.jsp",
  +                     "relative.jsp",
                        url);
       }
   
  @@ -781,7 +804,29 @@
           }
           assertNotNull("url present", url);
           assertEquals("url value",
  -                     "/myapp/relative.jsp",
  +                     //                     "/myapp/relative.jsp",
  +                     "relative.jsp",
  +                     url);
  +    }
  +
  +
  +    // Second subapp -- Forward with external path
  +    public void testComputeURL2h() {
  +
  +        request.setAttribute(Action.APPLICATION_KEY, appConfig2);
  +        request.setPathElements("/myapp", "/2/action.do", null, null);
  +        String url = null;
  +        try {
  +            url = RequestUtils.computeURL
  +                (page, "external",
  +                 null, null,
  +                 null, null, false);
  +        } catch (MalformedURLException e) {
  +            fail("MalformedURLException: " + e);
  +        }
  +        assertNotNull("url present", url);
  +        assertEquals("url value",
  +                     "http://jakarta.apache.org/",
                        url);
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message