You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2008/11/23 13:27:19 UTC
svn commit: r719983 - in /incubator/click/trunk/click/framework:
src/net/sf/click/ test/net/sf/click/ test/net/sf/click/pages/ test/web/
Author: sabob
Date: Sun Nov 23 04:27:18 2008
New Revision: 719983
URL: http://svn.apache.org/viewvc?rev=719983&view=rev
Log:
Fix CLK-141 regression and add more tests for CLK-141 and CLK468
Added:
incubator/click/trunk/click/framework/test/net/sf/click/pages/RedirectToSelfPage.java
incubator/click/trunk/click/framework/test/net/sf/click/pages/SetPathToJspPage.java
incubator/click/trunk/click/framework/test/web/redirect-to-self.htm
incubator/click/trunk/click/framework/test/web/set-path-to-jsp.htm
Modified:
incubator/click/trunk/click/framework/src/net/sf/click/ClickServlet.java
incubator/click/trunk/click/framework/test/net/sf/click/PageTest.java
Modified: incubator/click/trunk/click/framework/src/net/sf/click/ClickServlet.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/net/sf/click/ClickServlet.java?rev=719983&r1=719982&r2=719983&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/net/sf/click/ClickServlet.java (original)
+++ incubator/click/trunk/click/framework/src/net/sf/click/ClickServlet.java Sun Nov 23 04:27:18 2008
@@ -649,7 +649,7 @@
String pagePath = page.getPath();
// Check if request is a JSP page
- if (configService.isJspPage(pagePath)) {
+ if (pagePath.endsWith(".jsp") || configService.isJspPage(pagePath)) {
// CLK-141. Set pagePath as the forward value.
page.setForward(StringUtils.replace(pagePath, ".htm", ".jsp"));
Modified: incubator/click/trunk/click/framework/test/net/sf/click/PageTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/net/sf/click/PageTest.java?rev=719983&r1=719982&r2=719983&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/test/net/sf/click/PageTest.java (original)
+++ incubator/click/trunk/click/framework/test/net/sf/click/PageTest.java Sun Nov 23 04:27:18 2008
@@ -4,6 +4,8 @@
import net.sf.click.pages.JspRedirectPage;
import net.sf.click.pages.RedirectToHtm;
import net.sf.click.pages.RedirectToJsp;
+import net.sf.click.pages.RedirectToSelfPage;
+import net.sf.click.pages.SetPathToJspPage;
/**
* Tests for the Page class.
@@ -18,7 +20,7 @@
container.start();
String contextPath = container.getRequest().getContextPath();
container.getRequest().setMethod("GET");
-
+
RedirectToHtm page = (RedirectToHtm) container.testPage(RedirectToHtm.class);
// assert that the Page successfully redirected to test.htm
@@ -55,7 +57,7 @@
container.start();
String contextPath = container.getRequest().getContextPath();
container.getRequest().setMethod("GET");
-
+
JspRedirectPage page = (JspRedirectPage) container.testPage(JspRedirectPage.class);
// assert that the Page successfully redirected to test.jsp, meaning
@@ -80,10 +82,43 @@
String expected = contextPath + redirect;
page.setRedirect(redirect);
assertEquals(expected, page.getRedirect());
-
+
// assert that setting redirect to a path already prefixed with contextPath
// won't add a second contextPath
page.setRedirect(contextPath + "/test.htm");
assertEquals(expected, page.getRedirect());
}
+
+ /**
+ * Test that Page.setRedirect properly adds context path even if the page
+ * path and context path have the same prefix.
+ * CLK-468
+ */
+ public void testRedirectWherePageAndContextPathAreTheSame() {
+ MockContainer container = new MockContainer("web");
+ container.start();
+ container.getRequest().setMethod("GET");
+
+ RedirectToSelfPage page = (RedirectToSelfPage) container.testPage(RedirectToSelfPage.class);
+
+ assertEquals(RedirectToSelfPage.class.getName(), container.getRedirectPageClass().getName());
+
+ container.stop();
+ }
+
+ /**
+ * Test that Page.setPath(path), where path is a JSP, works properly. Click
+ * should set the request to forward to the JSP page.
+ * CLK-141
+ */
+ public void testSetPathToJSP() {
+ MockContainer container = new MockContainer("web");
+ container.start();
+ container.getRequest().setMethod("GET");
+
+ SetPathToJspPage page = (SetPathToJspPage) container.testPage(SetPathToJspPage.class);
+ assertEquals(SetPathToJspPage.PATH, container.getForward());
+
+ container.stop();
+ }
}
Added: incubator/click/trunk/click/framework/test/net/sf/click/pages/RedirectToSelfPage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/net/sf/click/pages/RedirectToSelfPage.java?rev=719983&view=auto
==============================================================================
--- incubator/click/trunk/click/framework/test/net/sf/click/pages/RedirectToSelfPage.java (added)
+++ incubator/click/trunk/click/framework/test/net/sf/click/pages/RedirectToSelfPage.java Sun Nov 23 04:27:18 2008
@@ -0,0 +1,17 @@
+package net.sf.click.pages;
+
+import net.sf.click.Page;
+
+/**
+ * This page redirects to itself.
+ */
+public class RedirectToSelfPage extends Page {
+
+ /**
+ * Redirect to self.
+ */
+ public void onInit() {
+ // Redirect to self
+ setRedirect(RedirectToSelfPage.class);
+ }
+}
Added: incubator/click/trunk/click/framework/test/net/sf/click/pages/SetPathToJspPage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/net/sf/click/pages/SetPathToJspPage.java?rev=719983&view=auto
==============================================================================
--- incubator/click/trunk/click/framework/test/net/sf/click/pages/SetPathToJspPage.java (added)
+++ incubator/click/trunk/click/framework/test/net/sf/click/pages/SetPathToJspPage.java Sun Nov 23 04:27:18 2008
@@ -0,0 +1,18 @@
+package net.sf.click.pages;
+
+import net.sf.click.Page;
+
+/**
+ * This page sets its path to a JSP.
+ */
+public class SetPathToJspPage extends Page {
+
+ public static final String PATH = "dummy.jsp";
+
+ /**
+ * Set path to non-existent dummy.jsp
+ */
+ public void onInit() {
+ setPath(PATH);
+ }
+}
Added: incubator/click/trunk/click/framework/test/web/redirect-to-self.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/web/redirect-to-self.htm?rev=719983&view=auto
==============================================================================
--- incubator/click/trunk/click/framework/test/web/redirect-to-self.htm (added)
+++ incubator/click/trunk/click/framework/test/web/redirect-to-self.htm Sun Nov 23 04:27:18 2008
@@ -0,0 +1 @@
+test
\ No newline at end of file
Added: incubator/click/trunk/click/framework/test/web/set-path-to-jsp.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/web/set-path-to-jsp.htm?rev=719983&view=auto
==============================================================================
--- incubator/click/trunk/click/framework/test/web/set-path-to-jsp.htm (added)
+++ incubator/click/trunk/click/framework/test/web/set-path-to-jsp.htm Sun Nov 23 04:27:18 2008
@@ -0,0 +1 @@
+test
\ No newline at end of file