Merge branch '5.3.x'

This commit is contained in:
Sam Brannen
2022-01-04 14:09:02 +01:00
9 changed files with 118 additions and 121 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,10 +57,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 12.08.2003
* @see org.springframework.web.context.support.Spr8510Tests
*/
public class ContextLoaderTests {
class ContextLoaderTests {
@Test
public void testContextLoaderListenerWithDefaultContext() {
void contextLoaderListenerWithDefaultContext() {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"/org/springframework/web/context/WEB-INF/applicationContext.xml " +
@@ -94,8 +94,8 @@ public class ContextLoaderTests {
* context before calling refresh in ContextLoaders</em>.
*/
@Test
public void testContextLoaderListenerWithCustomizedContextLoader() {
final StringBuffer buffer = new StringBuffer();
void contextLoaderListenerWithCustomizedContextLoader() {
final StringBuilder builder = new StringBuilder();
final String expectedContents = "customizeContext() was called";
final MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
@@ -106,15 +106,15 @@ public class ContextLoaderTests {
assertThat(sc).as("The ServletContext should not be null.").isNotNull();
assertThat(sc).as("Verifying that we received the expected ServletContext.").isEqualTo(sc);
assertThat(wac.isActive()).as("The ApplicationContext should not yet have been refreshed.").isFalse();
buffer.append(expectedContents);
builder.append(expectedContents);
}
};
listener.contextInitialized(new ServletContextEvent(sc));
assertThat(buffer.toString()).as("customizeContext() should have been called.").isEqualTo(expectedContents);
assertThat(builder.toString()).as("customizeContext() should have been called.").isEqualTo(expectedContents);
}
@Test
public void testContextLoaderListenerWithLocalContextInitializers() {
void contextLoaderListenerWithLocalContextInitializers() {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -129,7 +129,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderListenerWithGlobalContextInitializers() {
void contextLoaderListenerWithGlobalContextInitializers() {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -144,7 +144,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderListenerWithMixedContextInitializers() {
void contextLoaderListenerWithMixedContextInitializers() {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -159,7 +159,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderListenerWithProgrammaticInitializers() {
void contextLoaderListenerWithProgrammaticInitializers() {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -173,7 +173,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderListenerWithProgrammaticAndLocalInitializers() {
void contextLoaderListenerWithProgrammaticAndLocalInitializers() {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -188,7 +188,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderListenerWithProgrammaticAndGlobalInitializers() {
void contextLoaderListenerWithProgrammaticAndGlobalInitializers() {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -203,7 +203,7 @@ public class ContextLoaderTests {
}
@Test
public void testRegisteredContextInitializerCanAccessServletContextParamsViaEnvironment() {
void registeredContextInitializerCanAccessServletContextParamsViaEnvironment() {
MockServletContext sc = new MockServletContext("");
// config file doesn't matter - just a placeholder
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
@@ -217,7 +217,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderListenerWithUnknownContextInitializer() {
void contextLoaderListenerWithUnknownContextInitializer() {
MockServletContext sc = new MockServletContext("");
// config file doesn't matter. just a placeholder
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
@@ -231,7 +231,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderWithCustomContext() throws Exception {
void contextLoaderWithCustomContext() throws Exception {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
"org.springframework.web.servlet.SimpleWebApplicationContext");
@@ -245,7 +245,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderWithInvalidLocation() throws Exception {
void contextLoaderWithInvalidLocation() throws Exception {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "/WEB-INF/myContext.xml");
ServletContextListener listener = new ContextLoaderListener();
@@ -256,7 +256,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderWithInvalidContext() throws Exception {
void contextLoaderWithInvalidContext() throws Exception {
MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
"org.springframework.web.context.support.InvalidWebApplicationContext");
@@ -268,7 +268,7 @@ public class ContextLoaderTests {
}
@Test
public void testContextLoaderWithDefaultLocation() throws Exception {
void contextLoaderWithDefaultLocation() throws Exception {
MockServletContext sc = new MockServletContext("");
ServletContextListener listener = new ContextLoaderListener();
ServletContextEvent event = new ServletContextEvent(sc);
@@ -280,7 +280,7 @@ public class ContextLoaderTests {
}
@Test
public void testFrameworkServletWithDefaultLocation() throws Exception {
void frameworkServletWithDefaultLocation() throws Exception {
DispatcherServlet servlet = new DispatcherServlet();
servlet.setContextClass(XmlWebApplicationContext.class);
assertThatExceptionOfType(BeanDefinitionStoreException.class)
@@ -291,7 +291,7 @@ public class ContextLoaderTests {
}
@Test
public void testFrameworkServletWithCustomLocation() throws Exception {
void frameworkServletWithCustomLocation() throws Exception {
DispatcherServlet servlet = new DispatcherServlet();
servlet.setContextConfigLocation("/org/springframework/web/context/WEB-INF/testNamespace.xml "
+ "/org/springframework/web/context/WEB-INF/context-addition.xml");
@@ -302,7 +302,7 @@ public class ContextLoaderTests {
@Test
@SuppressWarnings("resource")
public void testClassPathXmlApplicationContext() throws IOException {
void classPathXmlApplicationContext() throws IOException {
ApplicationContext context = new ClassPathXmlApplicationContext(
"/org/springframework/web/context/WEB-INF/applicationContext.xml");
assertThat(context.containsBean("father")).as("Has father").isTrue();
@@ -321,7 +321,7 @@ public class ContextLoaderTests {
@Test
@SuppressWarnings("resource")
public void testSingletonDestructionOnStartupFailure() throws IOException {
void singletonDestructionOnStartupFailure() throws IOException {
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
new ClassPathXmlApplicationContext(new String[] {
"/org/springframework/web/context/WEB-INF/applicationContext.xml",

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ package org.springframework.web.servlet.tags;
* @author Juergen Hoeller
* @since 14.01.2005
*/
public class HtmlEscapeTagOutsideDispatcherServletTests extends HtmlEscapeTagTests {
class HtmlEscapeTagOutsideDispatcherServletTests extends HtmlEscapeTagTests {
@Override
protected boolean inDispatcherServlet() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Alef Arendsen
*/
@SuppressWarnings("serial")
public class HtmlEscapeTagTests extends AbstractTagTests {
class HtmlEscapeTagTests extends AbstractTagTests {
@Test
public void htmlEscapeTag() throws JspException {
void htmlEscapeTag() throws JspException {
PageContext pc = createPageContext();
HtmlEscapeTag tag = new HtmlEscapeTag();
tag.setPageContext(pc);
@@ -87,7 +87,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void htmlEscapeTagWithContextParamTrue() throws JspException {
void htmlEscapeTagWithContextParamTrue() throws JspException {
PageContext pc = createPageContext();
MockServletContext sc = (MockServletContext) pc.getServletContext();
sc.addInitParameter(WebUtils.HTML_ESCAPE_CONTEXT_PARAM, "true");
@@ -108,7 +108,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void htmlEscapeTagWithContextParamFalse() throws JspException {
void htmlEscapeTagWithContextParamFalse() throws JspException {
PageContext pc = createPageContext();
MockServletContext sc = (MockServletContext) pc.getServletContext();
HtmlEscapeTag tag = new HtmlEscapeTag();
@@ -128,9 +128,9 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void escapeBody() throws JspException {
void escapeBody() throws JspException {
PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer();
final StringBuilder result = new StringBuilder();
EscapeBodyTag tag = new EscapeBodyTag() {
@Override
protected String readBodyContent() {
@@ -148,9 +148,9 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void escapeBodyWithHtmlEscape() throws JspException {
void escapeBodyWithHtmlEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer();
final StringBuilder result = new StringBuilder();
EscapeBodyTag tag = new EscapeBodyTag() {
@Override
protected String readBodyContent() {
@@ -169,9 +169,9 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void escapeBodyWithJavaScriptEscape() throws JspException {
void escapeBodyWithJavaScriptEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer();
final StringBuilder result = new StringBuilder();
EscapeBodyTag tag = new EscapeBodyTag() {
@Override
protected String readBodyContent() {
@@ -190,9 +190,9 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void escapeBodyWithHtmlEscapeAndJavaScriptEscape() throws JspException {
void escapeBodyWithHtmlEscapeAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer();
final StringBuilder result = new StringBuilder();
EscapeBodyTag tag = new EscapeBodyTag() {
@Override
protected String readBodyContent() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ package org.springframework.web.servlet.tags;
* @author Juergen Hoeller
* @since 14.01.2005
*/
public class MessageTagOutsideDispatcherServletTests extends MessageTagTests {
class MessageTagOutsideDispatcherServletTests extends MessageTagTests {
@Override
protected boolean inDispatcherServlet() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,12 +43,12 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Nicholas Williams
*/
@SuppressWarnings("serial")
public class MessageTagTests extends AbstractTagTests {
class MessageTagTests extends AbstractTagTests {
@Test
public void messageTagWithMessageSourceResolvable() throws JspException {
void messageTagWithMessageSourceResolvable() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -63,9 +63,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCode() throws JspException {
void messageTagWithCode() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -80,9 +80,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndArgument() throws JspException {
void messageTagWithCodeAndArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -98,9 +98,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndArguments() throws JspException {
void messageTagWithCodeAndArguments() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -116,9 +116,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndStringArgumentWithCustomSeparator() throws JspException {
void messageTagWithCodeAndStringArgumentWithCustomSeparator() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -135,9 +135,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndArrayArgument() throws JspException {
void messageTagWithCodeAndArrayArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -153,9 +153,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndObjectArgument() throws JspException {
void messageTagWithCodeAndObjectArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -171,9 +171,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -190,9 +190,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndNestedArgument() throws JspException {
void messageTagWithCodeAndNestedArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -208,9 +208,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndNestedArguments() throws JspException {
void messageTagWithCodeAndNestedArguments() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -227,9 +227,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndText() throws JspException {
void messageTagWithCodeAndText() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -245,9 +245,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithText() throws JspException {
void messageTagWithText() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -263,11 +263,11 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithTextEncodingEscaped() throws JspException {
void messageTagWithTextEncodingEscaped() throws JspException {
PageContext pc = createPageContext();
pc.getServletContext().setInitParameter(WebUtils.RESPONSE_ENCODED_HTML_ESCAPE_CONTEXT_PARAM, "true");
pc.getResponse().setCharacterEncoding("UTF-8");
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -283,9 +283,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithTextAndJavaScriptEscape() throws JspException {
void messageTagWithTextAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -301,9 +301,9 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithTextAndHtmlEscapeAndJavaScriptEscape() throws JspException {
void messageTagWithTextAndHtmlEscapeAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
@@ -320,7 +320,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageWithVarAndScope() throws JspException {
void messageWithVarAndScope() throws JspException {
PageContext pc = createPageContext();
MessageTag tag = new MessageTag();
tag.setPageContext(pc);
@@ -343,7 +343,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageWithVar() throws JspException {
void messageWithVar() throws JspException {
PageContext pc = createPageContext();
MessageTag tag = new MessageTag();
tag.setPageContext(pc);
@@ -365,7 +365,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void nullMessageSource() throws JspException {
void nullMessageSource() throws JspException {
PageContext pc = createPageContext();
ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext)
RequestContextUtils.findWebApplicationContext((HttpServletRequest) pc.getRequest(), pc.getServletContext());
@@ -381,7 +381,7 @@ public class MessageTagTests extends AbstractTagTests {
@Test
@SuppressWarnings("rawtypes")
public void requestContext() throws ServletException {
void requestContext() throws ServletException {
PageContext pc = createPageContext();
RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest(), pc.getServletContext());
assertThat(rc.getMessage("test")).isEqualTo("test message");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,13 +36,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Alef Arendsen
*/
public class ThemeTagTests extends AbstractTagTests {
class ThemeTagTests extends AbstractTagTests {
@Test
@SuppressWarnings("serial")
public void themeTag() throws JspException {
void themeTag() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
final StringBuilder message = new StringBuilder();
ThemeTag tag = new ThemeTag() {
@Override
protected void writeMessage(String msg) {
@@ -58,7 +58,7 @@ public class ThemeTagTests extends AbstractTagTests {
@Test
@SuppressWarnings("rawtypes")
public void requestContext() throws ServletException {
void requestContext() throws ServletException {
PageContext pc = createPageContext();
RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest());
assertThat(rc.getThemeMessage("themetest")).isEqualTo("theme test message");