Skip to content

Commit eeb01db

Browse files
committed
Support for new ServletContext methods in Servlet 4.0 b03
Issue: SPR-12674
1 parent e61e8d5 commit eeb01db

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java

+24
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public class MockServletContext implements ServletContext {
132132

133133
private int sessionTimeout;
134134

135+
private String requestCharacterEncoding;
136+
137+
private String responseCharacterEncoding;
138+
135139

136140
/**
137141
* Create a new {@code MockServletContext}, using no base path and a
@@ -563,6 +567,26 @@ public int getSessionTimeout() {
563567
return this.sessionTimeout;
564568
}
565569

570+
// @Override - but only against Servlet 4.0
571+
public void setRequestCharacterEncoding(String requestCharacterEncoding) {
572+
this.requestCharacterEncoding = requestCharacterEncoding;
573+
}
574+
575+
// @Override - but only against Servlet 4.0
576+
public String getRequestCharacterEncoding() {
577+
return this.requestCharacterEncoding;
578+
}
579+
580+
// @Override - but only against Servlet 4.0
581+
public void setResponseCharacterEncoding(String responseCharacterEncoding) {
582+
this.responseCharacterEncoding = responseCharacterEncoding;
583+
}
584+
585+
// @Override - but only against Servlet 4.0
586+
public String getResponseCharacterEncoding() {
587+
return this.responseCharacterEncoding;
588+
}
589+
566590

567591
//---------------------------------------------------------------------
568592
// Unsupported Servlet 3.0 registration methods

spring-web/src/test/java/org/springframework/mock/web/test/MockServletContext.java

+24
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public class MockServletContext implements ServletContext {
132132

133133
private int sessionTimeout;
134134

135+
private String requestCharacterEncoding;
136+
137+
private String responseCharacterEncoding;
138+
135139

136140
/**
137141
* Create a new {@code MockServletContext}, using no base path and a
@@ -563,6 +567,26 @@ public int getSessionTimeout() {
563567
return this.sessionTimeout;
564568
}
565569

570+
// @Override - but only against Servlet 4.0
571+
public void setRequestCharacterEncoding(String requestCharacterEncoding) {
572+
this.requestCharacterEncoding = requestCharacterEncoding;
573+
}
574+
575+
// @Override - but only against Servlet 4.0
576+
public String getRequestCharacterEncoding() {
577+
return this.requestCharacterEncoding;
578+
}
579+
580+
// @Override - but only against Servlet 4.0
581+
public void setResponseCharacterEncoding(String responseCharacterEncoding) {
582+
this.responseCharacterEncoding = responseCharacterEncoding;
583+
}
584+
585+
// @Override - but only against Servlet 4.0
586+
public String getResponseCharacterEncoding() {
587+
return this.responseCharacterEncoding;
588+
}
589+
566590

567591
//---------------------------------------------------------------------
568592
// Unsupported Servlet 3.0 registration methods

0 commit comments

Comments
 (0)