Merge branch '5.3.x'

This commit is contained in:
Sam Brannen 2022-01-04 14:09:02 +01:00
commit 61c3d7a989
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -322,7 +322,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
int b = 12; int b = 12;
int c = 25; int c = 25;
String d = "d"; String d = "d";
StringBuffer e = new StringBuffer("stringbuf"); StringBuilder e = new StringBuilder("stringbuf");
String expectedResult = a + b+ c + d + e; String expectedResult = a + b+ c + d + e;
assertThat(mva.mungeArgs(a, b, c, d, e)).isEqualTo(expectedResult); assertThat(mva.mungeArgs(a, b, c, d, e)).isEqualTo(expectedResult);
} }
@ -728,12 +728,12 @@ abstract class AbstractAspectJAdvisorFactoryTests {
@Aspect @Aspect
static class ManyValuedArgs { static class ManyValuedArgs {
String mungeArgs(String a, int b, int c, String d, StringBuffer e) { String mungeArgs(String a, int b, int c, String d, StringBuilder e) {
return a + b + c + d + e; return a + b + c + d + e;
} }
@Around(value="execution(String mungeArgs(..)) && args(a, b, c, d, e)", argNames="b,c,d,e,a") @Around(value="execution(String mungeArgs(..)) && args(a, b, c, d, e)", argNames="b,c,d,e,a")
String reverseAdvice(ProceedingJoinPoint pjp, int b, int c, String d, StringBuffer e, String a) throws Throwable { String reverseAdvice(ProceedingJoinPoint pjp, int b, int c, String d, StringBuilder e, String a) throws Throwable {
assertThat(pjp.proceed()).isEqualTo(a + b+ c+ d+ e); assertThat(pjp.proceed()).isEqualTo(a + b+ c+ d+ e);
return a + b + c + d + e; return a + b + c + d + e;
} }

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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,10 +54,10 @@ import static org.assertj.core.api.Assertions.assertThat;
class DirtiesContextWithContextHierarchyTests { class DirtiesContextWithContextHierarchyTests {
@Autowired @Autowired
private StringBuffer foo; private StringBuilder foo;
@Autowired @Autowired
private StringBuffer baz; private StringBuilder baz;
@Autowired @Autowired
private ApplicationContext context; private ApplicationContext context;
@ -74,7 +74,7 @@ class DirtiesContextWithContextHierarchyTests {
@Order(1) @Order(1)
void verifyOriginalStateAndDirtyContexts() { void verifyOriginalStateAndDirtyContexts() {
assertOriginalState(); assertOriginalState();
reverseStringBuffers(); reverseStringBuilders();
} }
@Test @Test
@ -90,7 +90,7 @@ class DirtiesContextWithContextHierarchyTests {
@DirtiesContext(hierarchyMode = HierarchyMode.CURRENT_LEVEL) @DirtiesContext(hierarchyMode = HierarchyMode.CURRENT_LEVEL)
void verifyOriginalStateWasReinstatedAndDirtyContextsAndTriggerCurrentLevelCacheClearing() { void verifyOriginalStateWasReinstatedAndDirtyContextsAndTriggerCurrentLevelCacheClearing() {
assertOriginalState(); assertOriginalState();
reverseStringBuffers(); reverseStringBuilders();
} }
@Test @Test
@ -100,7 +100,7 @@ class DirtiesContextWithContextHierarchyTests {
assertCleanChildContext(); assertCleanChildContext();
} }
private void reverseStringBuffers() { private void reverseStringBuilders() {
foo.reverse(); foo.reverse();
baz.reverse(); baz.reverse();
} }
@ -131,13 +131,13 @@ class DirtiesContextWithContextHierarchyTests {
static class ParentConfig { static class ParentConfig {
@Bean @Bean
StringBuffer foo() { StringBuilder foo() {
return new StringBuffer("foo"); return new StringBuilder("foo");
} }
@Bean @Bean
StringBuffer baz() { StringBuilder baz() {
return new StringBuffer("baz-parent"); return new StringBuilder("baz-parent");
} }
} }
@ -145,8 +145,8 @@ class DirtiesContextWithContextHierarchyTests {
static class ChildConfig { static class ChildConfig {
@Bean @Bean
StringBuffer baz() { StringBuilder baz() {
return new StringBuffer("baz-child"); return new StringBuilder("baz-child");
} }
} }

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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,62 +34,59 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Sam Brannen * @author Sam Brannen
* @since 09.04.2003 * @since 09.04.2003
*/ */
public class RollbackRuleTests { class RollbackRuleTests {
@Test @Test
public void foundImmediatelyWithString() { void foundImmediatelyWithString() {
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Exception.class.getName()); RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class.getName());
assertThat(rr.getDepth(new Exception())).isEqualTo(0); assertThat(rr.getDepth(new Exception())).isEqualTo(0);
} }
@Test @Test
public void foundImmediatelyWithClass() { void foundImmediatelyWithClass() {
RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class); RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class);
assertThat(rr.getDepth(new Exception())).isEqualTo(0); assertThat(rr.getDepth(new Exception())).isEqualTo(0);
} }
@Test @Test
public void notFound() { void notFound() {
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.io.IOException.class.getName()); RollbackRuleAttribute rr = new RollbackRuleAttribute(java.io.IOException.class.getName());
assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(-1); assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(-1);
} }
@Test @Test
public void ancestry() { void ancestry() {
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Exception.class.getName()); RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class.getName());
// Exception -> Runtime -> NestedRuntime -> MyRuntimeException // Exception -> Runtime -> NestedRuntime -> MyRuntimeException
assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(3); assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(3);
} }
@Test @Test
public void alwaysTrueForThrowable() { void alwaysTrueForThrowable() {
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Throwable.class.getName()); RollbackRuleAttribute rr = new RollbackRuleAttribute(Throwable.class.getName());
assertThat(rr.getDepth(new MyRuntimeException("")) > 0).isTrue(); assertThat(rr.getDepth(new MyRuntimeException(""))).isGreaterThan(0);
assertThat(rr.getDepth(new IOException()) > 0).isTrue(); assertThat(rr.getDepth(new IOException())).isGreaterThan(0);
assertThat(rr.getDepth(new FatalBeanException(null,null)) > 0).isTrue(); assertThat(rr.getDepth(new FatalBeanException(null, null))).isGreaterThan(0);
assertThat(rr.getDepth(new RuntimeException()) > 0).isTrue(); assertThat(rr.getDepth(new RuntimeException())).isGreaterThan(0);
} }
@Test @Test
public void ctorArgMustBeAThrowableClassWithNonThrowableType() { void ctorArgMustBeAThrowableClassWithNonThrowableType() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute(Object.class));
new RollbackRuleAttribute(StringBuffer.class));
} }
@Test @Test
public void ctorArgMustBeAThrowableClassWithNullThrowableType() { void ctorArgMustBeAThrowableClassWithNullThrowableType() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute((Class<?>) null));
new RollbackRuleAttribute((Class<?>) null));
} }
@Test @Test
public void ctorArgExceptionStringNameVersionWithNull() { void ctorArgExceptionStringNameVersionWithNull() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute((String) null));
new RollbackRuleAttribute((String) null));
} }
@Test @Test
public void foundEnclosedExceptionWithEnclosingException() { void foundEnclosedExceptionWithEnclosingException() {
RollbackRuleAttribute rr = new RollbackRuleAttribute(EnclosingException.class); RollbackRuleAttribute rr = new RollbackRuleAttribute(EnclosingException.class);
assertThat(rr.getDepth(new EnclosingException.EnclosedException())).isEqualTo(0); assertThat(rr.getDepth(new EnclosingException.EnclosedException())).isEqualTo(0);
} }

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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @since 12.08.2003
* @see org.springframework.web.context.support.Spr8510Tests * @see org.springframework.web.context.support.Spr8510Tests
*/ */
public class ContextLoaderTests { class ContextLoaderTests {
@Test @Test
public void testContextLoaderListenerWithDefaultContext() { void contextLoaderListenerWithDefaultContext() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"/org/springframework/web/context/WEB-INF/applicationContext.xml " + "/org/springframework/web/context/WEB-INF/applicationContext.xml " +
@ -94,8 +94,8 @@ public class ContextLoaderTests {
* context before calling refresh in ContextLoaders</em>. * context before calling refresh in ContextLoaders</em>.
*/ */
@Test @Test
public void testContextLoaderListenerWithCustomizedContextLoader() { void contextLoaderListenerWithCustomizedContextLoader() {
final StringBuffer buffer = new StringBuffer(); final StringBuilder builder = new StringBuilder();
final String expectedContents = "customizeContext() was called"; final String expectedContents = "customizeContext() was called";
final MockServletContext sc = new MockServletContext(""); final MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, 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("The ServletContext should not be null.").isNotNull();
assertThat(sc).as("Verifying that we received the expected ServletContext.").isEqualTo(sc); 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(); assertThat(wac.isActive()).as("The ApplicationContext should not yet have been refreshed.").isFalse();
buffer.append(expectedContents); builder.append(expectedContents);
} }
}; };
listener.contextInitialized(new ServletContextEvent(sc)); 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 @Test
public void testContextLoaderListenerWithLocalContextInitializers() { void contextLoaderListenerWithLocalContextInitializers() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml"); "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@ -129,7 +129,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderListenerWithGlobalContextInitializers() { void contextLoaderListenerWithGlobalContextInitializers() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml"); "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@ -144,7 +144,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderListenerWithMixedContextInitializers() { void contextLoaderListenerWithMixedContextInitializers() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml"); "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@ -159,7 +159,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderListenerWithProgrammaticInitializers() { void contextLoaderListenerWithProgrammaticInitializers() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml"); "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@ -173,7 +173,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderListenerWithProgrammaticAndLocalInitializers() { void contextLoaderListenerWithProgrammaticAndLocalInitializers() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml"); "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@ -188,7 +188,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderListenerWithProgrammaticAndGlobalInitializers() { void contextLoaderListenerWithProgrammaticAndGlobalInitializers() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml"); "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@ -203,7 +203,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testRegisteredContextInitializerCanAccessServletContextParamsViaEnvironment() { void registeredContextInitializerCanAccessServletContextParamsViaEnvironment() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
// config file doesn't matter - just a placeholder // config file doesn't matter - just a placeholder
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
@ -217,7 +217,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderListenerWithUnknownContextInitializer() { void contextLoaderListenerWithUnknownContextInitializer() {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
// config file doesn't matter. just a placeholder // config file doesn't matter. just a placeholder
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
@ -231,7 +231,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderWithCustomContext() throws Exception { void contextLoaderWithCustomContext() throws Exception {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM, sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
"org.springframework.web.servlet.SimpleWebApplicationContext"); "org.springframework.web.servlet.SimpleWebApplicationContext");
@ -245,7 +245,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderWithInvalidLocation() throws Exception { void contextLoaderWithInvalidLocation() throws Exception {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "/WEB-INF/myContext.xml"); sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "/WEB-INF/myContext.xml");
ServletContextListener listener = new ContextLoaderListener(); ServletContextListener listener = new ContextLoaderListener();
@ -256,7 +256,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderWithInvalidContext() throws Exception { void contextLoaderWithInvalidContext() throws Exception {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM, sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
"org.springframework.web.context.support.InvalidWebApplicationContext"); "org.springframework.web.context.support.InvalidWebApplicationContext");
@ -268,7 +268,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testContextLoaderWithDefaultLocation() throws Exception { void contextLoaderWithDefaultLocation() throws Exception {
MockServletContext sc = new MockServletContext(""); MockServletContext sc = new MockServletContext("");
ServletContextListener listener = new ContextLoaderListener(); ServletContextListener listener = new ContextLoaderListener();
ServletContextEvent event = new ServletContextEvent(sc); ServletContextEvent event = new ServletContextEvent(sc);
@ -280,7 +280,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testFrameworkServletWithDefaultLocation() throws Exception { void frameworkServletWithDefaultLocation() throws Exception {
DispatcherServlet servlet = new DispatcherServlet(); DispatcherServlet servlet = new DispatcherServlet();
servlet.setContextClass(XmlWebApplicationContext.class); servlet.setContextClass(XmlWebApplicationContext.class);
assertThatExceptionOfType(BeanDefinitionStoreException.class) assertThatExceptionOfType(BeanDefinitionStoreException.class)
@ -291,7 +291,7 @@ public class ContextLoaderTests {
} }
@Test @Test
public void testFrameworkServletWithCustomLocation() throws Exception { void frameworkServletWithCustomLocation() throws Exception {
DispatcherServlet servlet = new DispatcherServlet(); DispatcherServlet servlet = new DispatcherServlet();
servlet.setContextConfigLocation("/org/springframework/web/context/WEB-INF/testNamespace.xml " servlet.setContextConfigLocation("/org/springframework/web/context/WEB-INF/testNamespace.xml "
+ "/org/springframework/web/context/WEB-INF/context-addition.xml"); + "/org/springframework/web/context/WEB-INF/context-addition.xml");
@ -302,7 +302,7 @@ public class ContextLoaderTests {
@Test @Test
@SuppressWarnings("resource") @SuppressWarnings("resource")
public void testClassPathXmlApplicationContext() throws IOException { void classPathXmlApplicationContext() throws IOException {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"/org/springframework/web/context/WEB-INF/applicationContext.xml"); "/org/springframework/web/context/WEB-INF/applicationContext.xml");
assertThat(context.containsBean("father")).as("Has father").isTrue(); assertThat(context.containsBean("father")).as("Has father").isTrue();
@ -321,7 +321,7 @@ public class ContextLoaderTests {
@Test @Test
@SuppressWarnings("resource") @SuppressWarnings("resource")
public void testSingletonDestructionOnStartupFailure() throws IOException { void singletonDestructionOnStartupFailure() throws IOException {
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
new ClassPathXmlApplicationContext(new String[] { new ClassPathXmlApplicationContext(new String[] {
"/org/springframework/web/context/WEB-INF/applicationContext.xml", "/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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Juergen Hoeller
* @since 14.01.2005 * @since 14.01.2005
*/ */
public class HtmlEscapeTagOutsideDispatcherServletTests extends HtmlEscapeTagTests { class HtmlEscapeTagOutsideDispatcherServletTests extends HtmlEscapeTagTests {
@Override @Override
protected boolean inDispatcherServlet() { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Alef Arendsen
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class HtmlEscapeTagTests extends AbstractTagTests { class HtmlEscapeTagTests extends AbstractTagTests {
@Test @Test
public void htmlEscapeTag() throws JspException { void htmlEscapeTag() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
HtmlEscapeTag tag = new HtmlEscapeTag(); HtmlEscapeTag tag = new HtmlEscapeTag();
tag.setPageContext(pc); tag.setPageContext(pc);
@ -87,7 +87,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
} }
@Test @Test
public void htmlEscapeTagWithContextParamTrue() throws JspException { void htmlEscapeTagWithContextParamTrue() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
MockServletContext sc = (MockServletContext) pc.getServletContext(); MockServletContext sc = (MockServletContext) pc.getServletContext();
sc.addInitParameter(WebUtils.HTML_ESCAPE_CONTEXT_PARAM, "true"); sc.addInitParameter(WebUtils.HTML_ESCAPE_CONTEXT_PARAM, "true");
@ -108,7 +108,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
} }
@Test @Test
public void htmlEscapeTagWithContextParamFalse() throws JspException { void htmlEscapeTagWithContextParamFalse() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
MockServletContext sc = (MockServletContext) pc.getServletContext(); MockServletContext sc = (MockServletContext) pc.getServletContext();
HtmlEscapeTag tag = new HtmlEscapeTag(); HtmlEscapeTag tag = new HtmlEscapeTag();
@ -128,9 +128,9 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
} }
@Test @Test
public void escapeBody() throws JspException { void escapeBody() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
EscapeBodyTag tag = new EscapeBodyTag() { EscapeBodyTag tag = new EscapeBodyTag() {
@Override @Override
protected String readBodyContent() { protected String readBodyContent() {
@ -148,9 +148,9 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
} }
@Test @Test
public void escapeBodyWithHtmlEscape() throws JspException { void escapeBodyWithHtmlEscape() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
EscapeBodyTag tag = new EscapeBodyTag() { EscapeBodyTag tag = new EscapeBodyTag() {
@Override @Override
protected String readBodyContent() { protected String readBodyContent() {
@ -169,9 +169,9 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
} }
@Test @Test
public void escapeBodyWithJavaScriptEscape() throws JspException { void escapeBodyWithJavaScriptEscape() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
EscapeBodyTag tag = new EscapeBodyTag() { EscapeBodyTag tag = new EscapeBodyTag() {
@Override @Override
protected String readBodyContent() { protected String readBodyContent() {
@ -190,9 +190,9 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
} }
@Test @Test
public void escapeBodyWithHtmlEscapeAndJavaScriptEscape() throws JspException { void escapeBodyWithHtmlEscapeAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
EscapeBodyTag tag = new EscapeBodyTag() { EscapeBodyTag tag = new EscapeBodyTag() {
@Override @Override
protected String readBodyContent() { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Juergen Hoeller
* @since 14.01.2005 * @since 14.01.2005
*/ */
public class MessageTagOutsideDispatcherServletTests extends MessageTagTests { class MessageTagOutsideDispatcherServletTests extends MessageTagTests {
@Override @Override
protected boolean inDispatcherServlet() { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Nicholas Williams
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class MessageTagTests extends AbstractTagTests { class MessageTagTests extends AbstractTagTests {
@Test @Test
public void messageTagWithMessageSourceResolvable() throws JspException { void messageTagWithMessageSourceResolvable() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -63,9 +63,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCode() throws JspException { void messageTagWithCode() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -80,9 +80,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndArgument() throws JspException { void messageTagWithCodeAndArgument() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -98,9 +98,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndArguments() throws JspException { void messageTagWithCodeAndArguments() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -116,9 +116,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndStringArgumentWithCustomSeparator() throws JspException { void messageTagWithCodeAndStringArgumentWithCustomSeparator() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -135,9 +135,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndArrayArgument() throws JspException { void messageTagWithCodeAndArrayArgument() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -153,9 +153,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndObjectArgument() throws JspException { void messageTagWithCodeAndObjectArgument() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -171,9 +171,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException { void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -190,9 +190,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndNestedArgument() throws JspException { void messageTagWithCodeAndNestedArgument() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -208,9 +208,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndNestedArguments() throws JspException { void messageTagWithCodeAndNestedArguments() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -227,9 +227,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithCodeAndText() throws JspException { void messageTagWithCodeAndText() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -245,9 +245,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithText() throws JspException { void messageTagWithText() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -263,11 +263,11 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithTextEncodingEscaped() throws JspException { void messageTagWithTextEncodingEscaped() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
pc.getServletContext().setInitParameter(WebUtils.RESPONSE_ENCODED_HTML_ESCAPE_CONTEXT_PARAM, "true"); pc.getServletContext().setInitParameter(WebUtils.RESPONSE_ENCODED_HTML_ESCAPE_CONTEXT_PARAM, "true");
pc.getResponse().setCharacterEncoding("UTF-8"); pc.getResponse().setCharacterEncoding("UTF-8");
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -283,9 +283,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithTextAndJavaScriptEscape() throws JspException { void messageTagWithTextAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -301,9 +301,9 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageTagWithTextAndHtmlEscapeAndJavaScriptEscape() throws JspException { void messageTagWithTextAndHtmlEscapeAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() { MessageTag tag = new MessageTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -320,7 +320,7 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageWithVarAndScope() throws JspException { void messageWithVarAndScope() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
MessageTag tag = new MessageTag(); MessageTag tag = new MessageTag();
tag.setPageContext(pc); tag.setPageContext(pc);
@ -343,7 +343,7 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void messageWithVar() throws JspException { void messageWithVar() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
MessageTag tag = new MessageTag(); MessageTag tag = new MessageTag();
tag.setPageContext(pc); tag.setPageContext(pc);
@ -365,7 +365,7 @@ public class MessageTagTests extends AbstractTagTests {
} }
@Test @Test
public void nullMessageSource() throws JspException { void nullMessageSource() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext) ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext)
RequestContextUtils.findWebApplicationContext((HttpServletRequest) pc.getRequest(), pc.getServletContext()); RequestContextUtils.findWebApplicationContext((HttpServletRequest) pc.getRequest(), pc.getServletContext());
@ -381,7 +381,7 @@ public class MessageTagTests extends AbstractTagTests {
@Test @Test
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public void requestContext() throws ServletException { void requestContext() throws ServletException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest(), pc.getServletContext()); RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest(), pc.getServletContext());
assertThat(rc.getMessage("test")).isEqualTo("test message"); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 Juergen Hoeller
* @author Alef Arendsen * @author Alef Arendsen
*/ */
public class ThemeTagTests extends AbstractTagTests { class ThemeTagTests extends AbstractTagTests {
@Test @Test
@SuppressWarnings("serial") @SuppressWarnings("serial")
public void themeTag() throws JspException { void themeTag() throws JspException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer(); final StringBuilder message = new StringBuilder();
ThemeTag tag = new ThemeTag() { ThemeTag tag = new ThemeTag() {
@Override @Override
protected void writeMessage(String msg) { protected void writeMessage(String msg) {
@ -58,7 +58,7 @@ public class ThemeTagTests extends AbstractTagTests {
@Test @Test
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public void requestContext() throws ServletException { void requestContext() throws ServletException {
PageContext pc = createPageContext(); PageContext pc = createPageContext();
RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest()); RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest());
assertThat(rc.getThemeMessage("themetest")).isEqualTo("theme test message"); assertThat(rc.getThemeMessage("themetest")).isEqualTo("theme test message");