Polish tests
This commit is contained in:
parent
f04e9a8366
commit
3e14cdbc69
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
@ -58,10 +58,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 " +
|
||||||
|
|
@ -95,7 +95,7 @@ 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 StringBuffer buffer = new StringBuffer();
|
||||||
final String expectedContents = "customizeContext() was called";
|
final String expectedContents = "customizeContext() was called";
|
||||||
final MockServletContext sc = new MockServletContext("");
|
final MockServletContext sc = new MockServletContext("");
|
||||||
|
|
@ -115,7 +115,7 @@ public class ContextLoaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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");
|
||||||
|
|
@ -130,7 +130,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");
|
||||||
|
|
@ -145,7 +145,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");
|
||||||
|
|
@ -160,7 +160,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");
|
||||||
|
|
@ -174,7 +174,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");
|
||||||
|
|
@ -189,7 +189,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");
|
||||||
|
|
@ -204,7 +204,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,
|
||||||
|
|
@ -218,7 +218,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,
|
||||||
|
|
@ -232,7 +232,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");
|
||||||
|
|
@ -246,7 +246,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();
|
||||||
|
|
@ -257,7 +257,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");
|
||||||
|
|
@ -269,7 +269,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);
|
||||||
|
|
@ -281,7 +281,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)
|
||||||
|
|
@ -292,7 +292,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");
|
||||||
|
|
@ -303,7 +303,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();
|
||||||
|
|
@ -322,7 +322,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",
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
@ -33,10 +33,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);
|
||||||
|
|
@ -88,7 +88,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");
|
||||||
|
|
@ -109,7 +109,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();
|
||||||
|
|
@ -129,7 +129,7 @@ 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 StringBuffer result = new StringBuffer();
|
||||||
EscapeBodyTag tag = new EscapeBodyTag() {
|
EscapeBodyTag tag = new EscapeBodyTag() {
|
||||||
|
|
@ -149,7 +149,7 @@ 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 StringBuffer result = new StringBuffer();
|
||||||
EscapeBodyTag tag = new EscapeBodyTag() {
|
EscapeBodyTag tag = new EscapeBodyTag() {
|
||||||
|
|
@ -170,7 +170,7 @@ 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 StringBuffer result = new StringBuffer();
|
||||||
EscapeBodyTag tag = new EscapeBodyTag() {
|
EscapeBodyTag tag = new EscapeBodyTag() {
|
||||||
|
|
@ -191,7 +191,7 @@ 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 StringBuffer result = new StringBuffer();
|
||||||
EscapeBodyTag tag = new EscapeBodyTag() {
|
EscapeBodyTag tag = new EscapeBodyTag() {
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
@ -44,10 +44,10 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -64,7 +64,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -81,7 +81,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -99,7 +99,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -117,7 +117,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -136,7 +136,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -154,7 +154,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -172,7 +172,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -191,7 +191,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -209,7 +209,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -228,7 +228,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -246,7 +246,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -264,7 +264,7 @@ 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");
|
||||||
|
|
@ -284,7 +284,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -302,7 +302,7 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
MessageTag tag = new MessageTag() {
|
MessageTag tag = new MessageTag() {
|
||||||
|
|
@ -321,7 +321,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);
|
||||||
|
|
@ -344,7 +344,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);
|
||||||
|
|
@ -366,7 +366,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());
|
||||||
|
|
@ -382,7 +382,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");
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
@ -37,11 +37,11 @@ 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 StringBuffer message = new StringBuffer();
|
||||||
ThemeTag tag = new ThemeTag() {
|
ThemeTag tag = new ThemeTag() {
|
||||||
|
|
@ -59,7 +59,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");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue