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:58 UTC
[wicket] 02/02: [WICKET-7067] fix broken test + add new test
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();
}