You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by re...@apache.org on 2023/08/18 14:26:56 UTC
[wicket] branch master updated (a15fbea9be -> 096966363e)
This is an automated email from the ASF dual-hosted git repository.
reiern70 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
from a15fbea9be [WICKET-7064] commons-fileupload2 is back (#597)
new 02488e52ac [WICKET-7067] WebSocketResponse does not allow setting a header thus, disableCaching fails with an UnsupportedOperationException
new 096966363e [WICKET-7067] fix broken test + add new test
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/wicket/DefaultExceptionMapper.java | 5 +--
.../apache/wicket/DefaultExceptionMapperTest.java | 42 +++++++++++++++++++---
2 files changed, 41 insertions(+), 6 deletions(-)
[wicket] 02/02: [WICKET-7067] fix broken test + add new test
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reiern70 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 096966363ea3fbbc8bf779971921121a7a60a389
Author: reiern70 <re...@gmail.com>
AuthorDate: Fri Aug 18 09:24:03 2023 -0500
[WICKET-7067] fix broken test + add new test
---
.../apache/wicket/DefaultExceptionMapperTest.java | 42 +++++++++++++++++++---
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/wicket-core/src/test/java/org/apache/wicket/DefaultExceptionMapperTest.java b/wicket-core/src/test/java/org/apache/wicket/DefaultExceptionMapperTest.java
index e213989312..bd2b4f24c6 100644
--- a/wicket-core/src/test/java/org/apache/wicket/DefaultExceptionMapperTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/DefaultExceptionMapperTest.java
@@ -18,7 +18,6 @@ package org.apache.wicket;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import jakarta.servlet.http.HttpServletResponse;
@@ -26,13 +25,14 @@ import org.apache.wicket.markup.IMarkupResourceStreamProvider;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.mock.MockApplication;
+import org.apache.wicket.mock.MockWebResponse;
import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.settings.ExceptionSettings;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.StringResourceStream;
import org.apache.wicket.util.tester.WicketTestCase;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -53,6 +53,19 @@ class DefaultExceptionMapperTest extends WicketTestCase
}
};
}
+ private static class TestWebResponse extends MockWebResponse {
+ boolean disableCaching = false;
+
+ @Override
+ public final void disableCaching() {
+ super.disableCaching();
+ disableCaching = true;
+ }
+
+ public boolean isDisableCaching() {
+ return disableCaching;
+ }
+ }
/**
* <a href="https://issues.apache.org/jira/browse/WICKET-4659">WICKET-4659</a>
@@ -60,10 +73,31 @@ class DefaultExceptionMapperTest extends WicketTestCase
@Test
void shouldDisableCaching()
{
- WebResponse response = mock(WebResponse.class);
+ TestWebResponse response = new TestWebResponse();
+ tester.getRequestCycle().setResponse(response);
+ new DefaultExceptionMapper().map(mock(Exception.class));
+ Assertions.assertTrue(response.isDisableCaching());
+ tester.destroy();
+ }
+
+ private static class TestNoHeadersWebResponse extends TestWebResponse {
+ @Override
+ public boolean isHeaderSupported() {
+ return false;
+ }
+ }
+
+ /**
+ * <a href="https://issues.apache.org/jira/browse/WICKET-4659">WICKET-7067</a>
+ */
+ @Test
+ void shouldNotDisableCaching()
+ {
+ // this request does not support headers
+ TestNoHeadersWebResponse response = new TestNoHeadersWebResponse();
tester.getRequestCycle().setResponse(response);
new DefaultExceptionMapper().map(mock(Exception.class));
- verify(response).disableCaching();
+ Assertions.assertFalse(response.isDisableCaching());
tester.destroy();
}
[wicket] 01/02: [WICKET-7067] WebSocketResponse does not allow setting a header thus, disableCaching fails with an UnsupportedOperationException
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reiern70 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 02488e52aca8faad50c08da8617bf6c326b6fe2a
Author: reiern70 <re...@gmail.com>
AuthorDate: Thu Aug 17 11:58:20 2023 -0500
[WICKET-7067] WebSocketResponse does not allow setting a header thus, disableCaching fails with an UnsupportedOperationException
---
.../src/main/java/org/apache/wicket/DefaultExceptionMapper.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java b/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
index a26a882c43..54346d587e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
@@ -54,10 +54,11 @@ public class DefaultExceptionMapper implements IExceptionMapper
try
{
Response response = RequestCycle.get().getResponse();
- if (response instanceof WebResponse)
+ // WICKET-7067 WebSocketResponse doesn't allow setting headers
+ if (response instanceof WebResponse && ((WebResponse) response).isHeaderSupported())
{
// we don't want to cache an exceptional reply in the browser
- ((WebResponse)response).disableCaching();
+ ((WebResponse) response).disableCaching();
}
return internalMap(e);
}