You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jb...@apache.org on 2007/09/05 00:41:33 UTC

svn commit: r572828 - in /wicket/trunk/jdk-1.4/wicket/src: main/java/org/apache/wicket/markup/html/pages/ main/java/org/apache/wicket/protocol/http/ test/java/response/

Author: jbq
Date: Tue Sep  4 15:41:31 2007
New Revision: 572828

URL: http://svn.apache.org/viewvc?rev=572828&view=rev
Log:
WICKET-929 ExceptionErrorPage only works with WebResponse

Added:
    wicket/trunk/jdk-1.4/wicket/src/test/java/response/
    wicket/trunk/jdk-1.4/wicket/src/test/java/response/BrokenPage.java   (with props)
    wicket/trunk/jdk-1.4/wicket/src/test/java/response/StringResponseTest.java   (with props)
Modified:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/ExceptionErrorPage.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/ExceptionErrorPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/ExceptionErrorPage.java?rev=572828&r1=572827&r2=572828&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/ExceptionErrorPage.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/ExceptionErrorPage.java Tue Sep  4 15:41:31 2007
@@ -27,6 +27,7 @@
 import org.apache.wicket.markup.html.basic.MultiLineLabel;
 import org.apache.wicket.markup.html.debug.PageView;
 import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.protocol.http.WebResponse;
 import org.apache.wicket.util.string.Strings;
 
 
@@ -108,8 +109,12 @@
 	protected void configureResponse()
 	{
 		super.configureResponse();
-		getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus(
-				HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+		if (getWebRequestCycle().getResponse() instanceof WebResponse)
+		{
+			getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus(
+					HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+		}
 	}
 
 	/**

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java?rev=572828&r1=572827&r2=572828&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java Tue Sep  4 15:41:31 2007
@@ -395,22 +395,25 @@
 	{
 		previousRenderedPage = lastRenderedPage;
 
-		// handle redirects which are usually managed by the browser
-		// transparently
-		final MockHttpServletResponse httpResponse = (MockHttpServletResponse)cycle
-				.getWebResponse().getHttpServletResponse();
-
-		if (httpResponse.isRedirect())
+		if (cycle.getResponse() instanceof WebResponse)
 		{
-			this.lastRenderedPage = generateLastRenderedPage(cycle);
-
-			MockHttpServletRequest newHttpRequest = new MockHttpServletRequest(this.application,
-					servletSession, this.application.getServletContext());
-			newHttpRequest.setRequestToRedirectString(httpResponse.getRedirectLocation());
-			wicketRequest = this.application.newWebRequest(newHttpRequest);
-
-			cycle = createRequestCycle();
-			cycle.request();
+			// handle redirects which are usually managed by the browser
+			// transparently
+			final MockHttpServletResponse httpResponse = (MockHttpServletResponse)cycle
+					.getWebResponse().getHttpServletResponse();
+	
+			if (httpResponse.isRedirect())
+			{
+				this.lastRenderedPage = generateLastRenderedPage(cycle);
+	
+				MockHttpServletRequest newHttpRequest = new MockHttpServletRequest(this.application,
+						servletSession, this.application.getServletContext());
+				newHttpRequest.setRequestToRedirectString(httpResponse.getRedirectLocation());
+				wicketRequest = this.application.newWebRequest(newHttpRequest);
+	
+				cycle = createRequestCycle();
+				cycle.request();
+			}
 		}
 		this.lastRenderedPage = generateLastRenderedPage(cycle);
 

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/response/BrokenPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/response/BrokenPage.java?rev=572828&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/response/BrokenPage.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/response/BrokenPage.java Tue Sep  4 15:41:31 2007
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package response;
+
+import org.apache.wicket.markup.html.WebPage;
+
+public class BrokenPage extends WebPage
+{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/response/BrokenPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/response/BrokenPage.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/response/StringResponseTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/response/StringResponseTest.java?rev=572828&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/response/StringResponseTest.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/response/StringResponseTest.java Tue Sep  4 15:41:31 2007
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package response;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.protocol.http.MockWebApplication;
+import org.apache.wicket.protocol.http.WebRequestCycle;
+import org.apache.wicket.request.target.component.BookmarkablePageRequestTarget;
+import org.apache.wicket.response.StringResponse;
+import org.apache.wicket.settings.IExceptionSettings;
+
+public class StringResponseTest extends WicketTestCase
+{
+	public void testBrokenPage() {
+		tester.setupRequestAndResponse();
+		tester.getApplication().getRequestCycleSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_EXCEPTION_PAGE);
+
+		WebRequestCycle cycle = tester.createRequestCycle();
+		cycle.setResponse(new StringResponse());
+		try
+		{
+			cycle.request(new BookmarkablePageRequestTarget(BrokenPage.class));
+			Method method = MockWebApplication.class.getDeclaredMethod("generateLastRenderedPage", new Class[]{WebRequestCycle.class});
+			method.setAccessible(true);
+			Page page = (Page)method.invoke(tester, new Object[]{cycle});
+			WebRequestCycle cycle2 = tester.createRequestCycle();
+			cycle2.setResponse(new StringResponse());
+			page.render();
+		}
+		catch (IllegalArgumentException e)
+		{
+			throw new RuntimeException(e);
+		}
+		catch (IllegalAccessException e)
+		{
+			throw new RuntimeException(e);
+		}
+		catch (InvocationTargetException e)
+		{
+			throw new RuntimeException(e);
+		}
+		catch (SecurityException e)
+		{
+			throw new RuntimeException(e);
+		}
+		catch (NoSuchMethodException e)
+		{
+			throw new RuntimeException(e);
+		}
+		finally
+		{
+			cycle.getResponse().close();
+		}
+	}
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/response/StringResponseTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/response/StringResponseTest.java
------------------------------------------------------------------------------
    svn:keywords = Id