Oops...I forgot to mention the JIRA ticket this resolves. Anyone know how to go back and add a log entry for a commit?
James On Mon Aug 13 16:00 , [EMAIL PROTECTED] sent: >Author: jholmes >Date: Mon Aug 13 13:00:08 2007 >New Revision: 565492 > >URL: http://svn.apache.org/viewvc\?view=rev&rev=565492 >Log: (empty) > >Modified: > struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java > struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java > >Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java >URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java\?view=diff&rev=565492&r1=565491&r2=565492 >============================================================================== >--- struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java (original) >+++ struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java Mon Aug 13 13:00:08 2007 >@@ -67,6 +67,7 @@ > private static int httpsPort = DEFAULT_HTTPS_PORT; > private static String customEncoding; > >+ > @Inject(StrutsConstants.STRUTS_URL_HTTP_PORT) > public static void setHttpPort(String val) { > httpPort = Integer.parseInt(val); >@@ -109,22 +110,30 @@ > link.append(request.getServerName()); > > if (scheme != null) { >- if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT)) >- { >- link.append(":"); >- link.append(scheme.equals("http") ? httpPort : httpsPort); >+ // If switching schemes, use the configured port for the particular scheme. >+ if (!scheme.equals(reqScheme)) { >+ if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT)) { >+ link.append(":"); >+ link.append(scheme.equals("http") ? httpPort : >httpsPort); >+ } >+ // Else use the port from the current request. >+ } else { >+ int reqPort = request.getServerPort(); >+ >+ if ((scheme.equals("http") && (reqPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && reqPort != DEFAULT_HTTPS_PORT)) { >+ link.append(":"); >+ link.append(reqPort); >+ } > } > } > } >- else if ( >- (scheme != null) && !scheme.equals(request.getScheme())) { >+ else if ((scheme != null) && !scheme.equals(request.getScheme())) { > changedScheme = true; > link.append(scheme); > link.append("://"); > link.append(request.getServerName()); > >- if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT)) >- { >+ if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT)) { > link.append(":"); > link.append(scheme.equals("http") ? httpPort : httpsPort); > } > >Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java >URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java\?view=diff&rev=565492&r1=565491&r2=565492 >============================================================================== >--- struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java (original) >+++ struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java Mon Aug 13 13:00:08 2007 >@@ -40,8 +40,6 @@ > */ > public class UrlHelperTest extends StrutsTestCase { > >- >- > public void testForceAddSchemeHostAndPort() throws Exception { > String expectedUrl = "http://localhost/contextPath/path1/path2/myAction.action"; > >@@ -49,7 +47,8 @@ > mockHttpServletRequest.expectAndReturn("getScheme", "http"); > mockHttpServletRequest.expectAndReturn("getServerName", "localhost"); > mockHttpServletRequest.expectAndReturn("getContextPath", > "/contextPath"); >- >+ mockHttpServletRequest.expectAndReturn("getServerPort", 80); >+ > Mock mockHttpServletResponse = new Mock(HttpServletResponse.class); > mockHttpServletResponse.expectAndReturn("encodeURL", expectedUrl, expectedUrl); > >@@ -74,14 +73,30 @@ > assertEquals(expectedUrl, result); > } > >+ public void testForceAddSchemeHostAndPortWithNonStandardPort() throws Exception { >+ String expectedUrl = "http://localhost:9090/contextPath/path1/path2/myAction.action"; >+ >+ Mock mockHttpServletRequest = new Mock(HttpServletRequest.class); >+ mockHttpServletRequest.expectAndReturn("getScheme", "http"); >+ mockHttpServletRequest.expectAndReturn("getServerName", "localhost"); >+ mockHttpServletRequest.expectAndReturn("getContextPath", >"/contextPath"); >+ mockHttpServletRequest.expectAndReturn("getServerPort", 9090); >+ >+ Mock mockHttpServletResponse = new Mock(HttpServletResponse.class); >+ mockHttpServletResponse.expectAndReturn("encodeURL", expectedUrl, expectedUrl); >+ >+ String result = UrlHelper.buildUrl("/path1/path2/myAction.action", (HttpServletRequest) mockHttpServletRequest.proxy(), (HttpServletResponse)mockHttpServletResponse.proxy(), null, "http", true, true, true); >+ assertEquals(expectedUrl, result); >+ mockHttpServletRequest.verify(); >+ } >+ > public void testForceAddNullSchemeHostAndPort() throws Exception { > String expectedUrl = "http://localhost/contextPath/path1/path2/myAction.action"; > > Mock mockHttpServletRequest = new Mock(HttpServletRequest.class); > mockHttpServletRequest.expectAndReturn("getScheme", "http"); > mockHttpServletRequest.expectAndReturn("getServerName", "localhost"); >- mockHttpServletRequest.expectAndReturn("getContextPath", >- "/contextPath"); >+ mockHttpServletRequest.expectAndReturn("getContextPath", >"/contextPath"); > > Mock mockHttpServletResponse = new Mock(HttpServletResponse.class); > mockHttpServletResponse.expectAndReturn("encodeURL", expectedUrl, > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]