Polish tests

This commit is contained in:
Sam Brannen
2022-01-04 13:56:16 +01:00
parent f04e9a8366
commit 3e14cdbc69
7 changed files with 79 additions and 82 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.
@@ -58,10 +58,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 " +
@@ -95,7 +95,7 @@ public class ContextLoaderTests {
* context before calling refresh in ContextLoaders</em>.
*/
@Test
public void testContextLoaderListenerWithCustomizedContextLoader() {
void contextLoaderListenerWithCustomizedContextLoader() {
final StringBuffer buffer = new StringBuffer();
final String expectedContents = "customizeContext() was called";
final MockServletContext sc = new MockServletContext("");
@@ -115,7 +115,7 @@ public class ContextLoaderTests {
}
@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");
@@ -130,7 +130,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");
@@ -145,7 +145,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");
@@ -160,7 +160,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");
@@ -174,7 +174,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");
@@ -189,7 +189,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");
@@ -204,7 +204,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,
@@ -218,7 +218,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,
@@ -232,7 +232,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");
@@ -246,7 +246,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();
@@ -257,7 +257,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");
@@ -269,7 +269,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);
@@ -281,7 +281,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)
@@ -292,7 +292,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");
@@ -303,7 +303,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();
@@ -322,7 +322,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.
@@ -33,10 +33,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);
@@ -88,7 +88,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");
@@ -109,7 +109,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();
@@ -129,7 +129,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void escapeBody() throws JspException {
void escapeBody() throws JspException {
PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer();
EscapeBodyTag tag = new EscapeBodyTag() {
@@ -149,7 +149,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void escapeBodyWithHtmlEscape() throws JspException {
void escapeBodyWithHtmlEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer();
EscapeBodyTag tag = new EscapeBodyTag() {
@@ -170,7 +170,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void escapeBodyWithJavaScriptEscape() throws JspException {
void escapeBodyWithJavaScriptEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer();
EscapeBodyTag tag = new EscapeBodyTag() {
@@ -191,7 +191,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
}
@Test
public void escapeBodyWithHtmlEscapeAndJavaScriptEscape() throws JspException {
void escapeBodyWithHtmlEscapeAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer result = new StringBuffer();
EscapeBodyTag tag = new EscapeBodyTag() {

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.
@@ -44,10 +44,10 @@ 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();
MessageTag tag = new MessageTag() {
@@ -64,7 +64,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCode() throws JspException {
void messageTagWithCode() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -81,7 +81,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndArgument() throws JspException {
void messageTagWithCodeAndArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -99,7 +99,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndArguments() throws JspException {
void messageTagWithCodeAndArguments() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -117,7 +117,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndStringArgumentWithCustomSeparator() throws JspException {
void messageTagWithCodeAndStringArgumentWithCustomSeparator() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -136,7 +136,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndArrayArgument() throws JspException {
void messageTagWithCodeAndArrayArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -154,7 +154,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndObjectArgument() throws JspException {
void messageTagWithCodeAndObjectArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -172,7 +172,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -191,7 +191,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndNestedArgument() throws JspException {
void messageTagWithCodeAndNestedArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -209,7 +209,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndNestedArguments() throws JspException {
void messageTagWithCodeAndNestedArguments() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -228,7 +228,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithCodeAndText() throws JspException {
void messageTagWithCodeAndText() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -246,7 +246,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithText() throws JspException {
void messageTagWithText() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -264,7 +264,7 @@ 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");
@@ -284,7 +284,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithTextAndJavaScriptEscape() throws JspException {
void messageTagWithTextAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -302,7 +302,7 @@ public class MessageTagTests extends AbstractTagTests {
}
@Test
public void messageTagWithTextAndHtmlEscapeAndJavaScriptEscape() throws JspException {
void messageTagWithTextAndHtmlEscapeAndJavaScriptEscape() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@@ -321,7 +321,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);
@@ -344,7 +344,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);
@@ -366,7 +366,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());
@@ -382,7 +382,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.
@@ -37,11 +37,11 @@ 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();
ThemeTag tag = new ThemeTag() {
@@ -59,7 +59,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");