Refactor AssertJ assertions into more idiomatic ones
This commit refactors some AssertJ assertions into more idiomatic and readable ones. Using the dedicated assertion instead of a generic one will produce more meaningful error messages. For instance, consider collection size: ``` // expected: 5 but was: 2 assertThat(collection.size()).equals(5); // Expected size: 5 but was: 2 in: [1, 2] assertThat(collection).hasSize(5); ``` Closes gh-30104
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -72,7 +72,8 @@ class ContextLoaderTests {
|
||||
WebApplicationContext context = (WebApplicationContext) sc.getAttribute(contextAttr);
|
||||
boolean condition1 = context instanceof XmlWebApplicationContext;
|
||||
assertThat(condition1).as("Correct WebApplicationContext exposed in ServletContext").isTrue();
|
||||
assertThat(WebApplicationContextUtils.getRequiredWebApplicationContext(sc) instanceof XmlWebApplicationContext).isTrue();
|
||||
assertThat(WebApplicationContextUtils.getRequiredWebApplicationContext(sc)).isInstanceOf(
|
||||
XmlWebApplicationContext.class);
|
||||
LifecycleBean lb = (LifecycleBean) context.getBean("lifecycle");
|
||||
assertThat(context.containsBean("father")).as("Has father").isTrue();
|
||||
assertThat(context.containsBean("rod")).as("Has rod").isTrue();
|
||||
@@ -308,8 +309,8 @@ class ContextLoaderTests {
|
||||
assertThat(context.containsBean("father")).as("Has father").isTrue();
|
||||
assertThat(context.containsBean("rod")).as("Has rod").isTrue();
|
||||
assertThat(context.containsBean("kerry")).as("Hasn't kerry").isFalse();
|
||||
assertThat(((TestBean) context.getBean("rod")).getSpouse() == null).as("Doesn't have spouse").isTrue();
|
||||
assertThat("Roderick".equals(((TestBean) context.getBean("rod")).getName())).as("myinit not evaluated").isTrue();
|
||||
assertThat(((TestBean) context.getBean("rod")).getSpouse()).as("Doesn't have spouse").isNull();
|
||||
assertThat(((TestBean) context.getBean("rod")).getName()).as("myinit not evaluated").isEqualTo("Roderick");
|
||||
|
||||
context = new ClassPathXmlApplicationContext(new String[] {
|
||||
"/org/springframework/web/context/WEB-INF/applicationContext.xml",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -113,22 +113,22 @@ public class XmlWebApplicationContextTests extends AbstractApplicationContextTes
|
||||
assertThatExceptionOfType(NoSuchMessageException.class).isThrownBy(() ->
|
||||
wac.getMessage("someMessage", null, Locale.getDefault()));
|
||||
String msg = wac.getMessage("someMessage", null, "default", Locale.getDefault());
|
||||
assertThat("default".equals(msg)).as("Default message returned").isTrue();
|
||||
assertThat(msg).as("Default message returned").isEqualTo("default");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextNesting() {
|
||||
TestBean father = (TestBean) this.applicationContext.getBean("father");
|
||||
assertThat(father != null).as("Bean from root context").isTrue();
|
||||
assertThat(father).as("Bean from root context").isNotNull();
|
||||
assertThat(father.getFriends().contains("myFriend")).as("Custom BeanPostProcessor applied").isTrue();
|
||||
|
||||
TestBean rod = (TestBean) this.applicationContext.getBean("rod");
|
||||
assertThat("Rod".equals(rod.getName())).as("Bean from child context").isTrue();
|
||||
assertThat(rod.getSpouse() == father).as("Bean has external reference").isTrue();
|
||||
assertThat(!rod.getFriends().contains("myFriend")).as("Custom BeanPostProcessor not applied").isTrue();
|
||||
assertThat(rod.getName()).as("Bean from child context").isEqualTo("Rod");
|
||||
assertThat(rod.getSpouse()).as("Bean has external reference").isSameAs(father);
|
||||
assertThat(rod.getFriends().contains("myFriend")).as("Custom BeanPostProcessor not applied").isFalse();
|
||||
|
||||
rod = (TestBean) this.root.getBean("rod");
|
||||
assertThat("Roderick".equals(rod.getName())).as("Bean from root context").isTrue();
|
||||
assertThat(rod.getName()).as("Bean from root context").isEqualTo("Roderick");
|
||||
assertThat(rod.getFriends().contains("myFriend")).as("Custom BeanPostProcessor applied").isTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -118,16 +118,18 @@ public class DispatcherServletTests {
|
||||
|
||||
@Test
|
||||
public void configuredDispatcherServlets() {
|
||||
assertThat(("simple" + FrameworkServlet.DEFAULT_NAMESPACE_SUFFIX).equals(simpleDispatcherServlet.getNamespace())).as("Correct namespace").isTrue();
|
||||
assertThat((FrameworkServlet.SERVLET_CONTEXT_PREFIX + "simple").equals(
|
||||
simpleDispatcherServlet.getServletContextAttributeName())).as("Correct attribute").isTrue();
|
||||
assertThat(simpleDispatcherServlet.getWebApplicationContext() ==
|
||||
getServletContext().getAttribute(FrameworkServlet.SERVLET_CONTEXT_PREFIX + "simple")).as("Context published").isTrue();
|
||||
assertThat((simpleDispatcherServlet.getNamespace())).as("Correct namespace")
|
||||
.isEqualTo("simple" + FrameworkServlet.DEFAULT_NAMESPACE_SUFFIX);
|
||||
assertThat((FrameworkServlet.SERVLET_CONTEXT_PREFIX + "simple")).as("Correct attribute")
|
||||
.isEqualTo(simpleDispatcherServlet.getServletContextAttributeName());
|
||||
assertThat(simpleDispatcherServlet.getWebApplicationContext()).as("Context published")
|
||||
.isSameAs(getServletContext().getAttribute(FrameworkServlet.SERVLET_CONTEXT_PREFIX + "simple"));
|
||||
|
||||
assertThat("test".equals(complexDispatcherServlet.getNamespace())).as("Correct namespace").isTrue();
|
||||
assertThat((FrameworkServlet.SERVLET_CONTEXT_PREFIX + "complex").equals(
|
||||
complexDispatcherServlet.getServletContextAttributeName())).as("Correct attribute").isTrue();
|
||||
assertThat(getServletContext().getAttribute(FrameworkServlet.SERVLET_CONTEXT_PREFIX + "complex") == null).as("Context not published").isTrue();
|
||||
assertThat(complexDispatcherServlet.getNamespace()).as("Correct namespace").isEqualTo("test");
|
||||
assertThat((FrameworkServlet.SERVLET_CONTEXT_PREFIX + "complex")).as("Correct attribute")
|
||||
.isEqualTo(complexDispatcherServlet.getServletContextAttributeName());
|
||||
assertThat(getServletContext().getAttribute(FrameworkServlet.SERVLET_CONTEXT_PREFIX + "complex")).as("Context not published")
|
||||
.isNull();
|
||||
|
||||
simpleDispatcherServlet.destroy();
|
||||
complexDispatcherServlet.destroy();
|
||||
@@ -138,8 +140,8 @@ public class DispatcherServletTests {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/invalid.do");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
simpleDispatcherServlet.service(request, response);
|
||||
assertThat(response.getForwardedUrl() == null).as("Not forwarded").isTrue();
|
||||
assertThat(response.getStatus() == HttpServletResponse.SC_NOT_FOUND).as("correct error code").isTrue();
|
||||
assertThat(response.getForwardedUrl()).as("Not forwarded").isNull();
|
||||
assertThat(response.getStatus()).as("correct error code").isEqualTo(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,7 +152,7 @@ public class DispatcherServletTests {
|
||||
ComplexWebApplicationContext.TestApplicationListener listener =
|
||||
(ComplexWebApplicationContext.TestApplicationListener) complexDispatcherServlet
|
||||
.getWebApplicationContext().getBean("testListener");
|
||||
assertThat(listener.counter).isEqualTo(1);
|
||||
assertThat(listener.counter).isOne();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -181,7 +183,7 @@ public class DispatcherServletTests {
|
||||
request.addParameter("noView", "true");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getForwardedUrl() == null).as("Not forwarded").isTrue();
|
||||
assertThat(response.getForwardedUrl()).as("Not forwarded").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -190,7 +192,7 @@ public class DispatcherServletTests {
|
||||
request.addPreferredLocale(Locale.CANADA);
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
simpleDispatcherServlet.service(request, response);
|
||||
assertThat(response.getForwardedUrl() == null).as("Not forwarded").isTrue();
|
||||
assertThat(response.getForwardedUrl()).as("Not forwarded").isNull();
|
||||
assertThat(response.getHeader("Last-Modified")).isEqualTo("Wed, 01 Apr 2015 00:00:00 GMT");
|
||||
}
|
||||
|
||||
@@ -211,16 +213,16 @@ public class DispatcherServletTests {
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
|
||||
assertThat(response.getForwardedUrl() == null).as("Not forwarded").isTrue();
|
||||
assertThat(request.getAttribute("test1") != null).isTrue();
|
||||
assertThat(request.getAttribute("test1x") == null).isTrue();
|
||||
assertThat(request.getAttribute("test1y") == null).isTrue();
|
||||
assertThat(request.getAttribute("test2") != null).isTrue();
|
||||
assertThat(request.getAttribute("test2x") == null).isTrue();
|
||||
assertThat(request.getAttribute("test2y") == null).isTrue();
|
||||
assertThat(request.getAttribute("test3") != null).isTrue();
|
||||
assertThat(request.getAttribute("test3x") != null).isTrue();
|
||||
assertThat(request.getAttribute("test3y") != null).isTrue();
|
||||
assertThat(response.getForwardedUrl()).as("Not forwarded").isNull();
|
||||
assertThat(request.getAttribute("test1")).isNotNull();
|
||||
assertThat(request.getAttribute("test1x")).isNull();
|
||||
assertThat(request.getAttribute("test1y")).isNull();
|
||||
assertThat(request.getAttribute("test2")).isNotNull();
|
||||
assertThat(request.getAttribute("test2x")).isNull();
|
||||
assertThat(request.getAttribute("test2y")).isNull();
|
||||
assertThat(request.getAttribute("test3")).isNotNull();
|
||||
assertThat(request.getAttribute("test3x")).isNotNull();
|
||||
assertThat(request.getAttribute("test3y")).isNotNull();
|
||||
assertThat(response.getHeader("Last-Modified")).isEqualTo("Wed, 01 Apr 2015 00:00:01 GMT");
|
||||
}
|
||||
|
||||
@@ -278,13 +280,13 @@ public class DispatcherServletTests {
|
||||
request.addUserRole("role1");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getForwardedUrl() == null).as("Not forwarded").isTrue();
|
||||
assertThat(request.getAttribute("test1") != null).isTrue();
|
||||
assertThat(request.getAttribute("test1x") != null).isTrue();
|
||||
assertThat(request.getAttribute("test1y") == null).isTrue();
|
||||
assertThat(request.getAttribute("test2") == null).isTrue();
|
||||
assertThat(request.getAttribute("test2x") == null).isTrue();
|
||||
assertThat(request.getAttribute("test2y") == null).isTrue();
|
||||
assertThat(response.getForwardedUrl()).as("Not forwarded").isNull();
|
||||
assertThat(request.getAttribute("test1")).isNotNull();
|
||||
assertThat(request.getAttribute("test1x")).isNotNull();
|
||||
assertThat(request.getAttribute("test1y")).isNull();
|
||||
assertThat(request.getAttribute("test2")).isNull();
|
||||
assertThat(request.getAttribute("test2x")).isNull();
|
||||
assertThat(request.getAttribute("test2y")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -309,7 +311,8 @@ public class DispatcherServletTests {
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getForwardedUrl()).as("forwarded URL").isEqualTo("failed2.jsp");
|
||||
assertThat(request.getAttribute("exception") instanceof IllegalAccessException).as("Exception exposed").isTrue();
|
||||
assertThat(request.getAttribute("exception")).as("Exception exposed")
|
||||
.isInstanceOf(IllegalAccessException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -322,7 +325,7 @@ public class DispatcherServletTests {
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getForwardedUrl()).as("forwarded URL").isEqualTo("failed3.jsp");
|
||||
assertThat(request.getAttribute("exception") instanceof ServletException).as("Exception exposed").isTrue();
|
||||
assertThat(request.getAttribute("exception")).as("Exception exposed").isInstanceOf(ServletException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -335,7 +338,8 @@ public class DispatcherServletTests {
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getStatus()).isEqualTo(500);
|
||||
assertThat(response.getForwardedUrl()).as("forwarded URL").isEqualTo("failed1.jsp");
|
||||
assertThat(request.getAttribute("exception") instanceof IllegalAccessException).as("Exception exposed").isTrue();
|
||||
assertThat(request.getAttribute("exception")).as("Exception exposed")
|
||||
.isInstanceOf(IllegalAccessException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -348,7 +352,7 @@ public class DispatcherServletTests {
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getStatus()).isEqualTo(500);
|
||||
assertThat(response.getForwardedUrl()).as("forwarded URL").isEqualTo("failed1.jsp");
|
||||
assertThat(request.getAttribute("exception") instanceof ServletException).as("Exception exposed").isTrue();
|
||||
assertThat(request.getAttribute("exception")).as("Exception exposed").isInstanceOf(ServletException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -386,7 +390,7 @@ public class DispatcherServletTests {
|
||||
request.addParameter("locale2", "en_CA");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getForwardedUrl() == null).as("Not forwarded").isTrue();
|
||||
assertThat(response.getForwardedUrl()).as("Not forwarded").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -411,7 +415,7 @@ public class DispatcherServletTests {
|
||||
request.addParameter("theme2", "theme");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getForwardedUrl() == null).as("Not forwarded").isTrue();
|
||||
assertThat(response.getForwardedUrl()).as("Not forwarded").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -420,7 +424,7 @@ public class DispatcherServletTests {
|
||||
request.addPreferredLocale(Locale.CANADA);
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getStatus() == HttpServletResponse.SC_FORBIDDEN).as("Correct response").isTrue();
|
||||
assertThat(response.getStatus()).as("Correct response").isEqualTo(HttpServletResponse.SC_FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -433,7 +437,7 @@ public class DispatcherServletTests {
|
||||
request = new MockHttpServletRequest(getServletContext(), "GET", "/head.do");
|
||||
response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getContentAsString()).isEqualTo("");
|
||||
assertThat(response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -460,7 +464,7 @@ public class DispatcherServletTests {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/unknown.do");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getStatus() == HttpServletResponse.SC_NOT_FOUND).isTrue();
|
||||
assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -503,7 +507,8 @@ public class DispatcherServletTests {
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
complexDispatcherServlet.service(request, response);
|
||||
|
||||
assertThat(response.getStatus() == HttpServletResponse.SC_NOT_FOUND).as("Matched through parent controller/handler pair: not response=" + response.getStatus()).isFalse();
|
||||
assertThat(response.getStatus()).as("Matched through parent controller/handler pair: not response=" + response.getStatus())
|
||||
.isNotEqualTo(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -593,7 +598,7 @@ public class DispatcherServletTests {
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
complexDispatcherServlet.service(request, response);
|
||||
assertThat(response.getStatus() == HttpServletResponse.SC_NOT_FOUND).as("correct error code").isTrue();
|
||||
assertThat(response.getStatus()).as("correct error code").isEqualTo(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
// SPR-12984
|
||||
@@ -603,8 +608,8 @@ public class DispatcherServletTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("foo", "bar");
|
||||
NoHandlerFoundException ex = new NoHandlerFoundException("GET", "/foo", headers);
|
||||
assertThat(!ex.getMessage().contains("bar")).isTrue();
|
||||
assertThat(!ex.toString().contains("bar")).isTrue();
|
||||
assertThat(ex.getMessage()).doesNotContain("bar");
|
||||
assertThat(ex.toString()).doesNotContain("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -791,10 +796,10 @@ public class DispatcherServletTests {
|
||||
(ServletConfigAwareBean) servlet.getWebApplicationContext().getBean("servletConfigAwareBean");
|
||||
assertThat(contextBean2.getServletContext()).isSameAs(servletContext);
|
||||
assertThat(configBean2.getServletConfig()).isSameAs(servlet.getServletConfig());
|
||||
assertThat(contextBean != contextBean2).isTrue();
|
||||
assertThat(configBean != configBean2).isTrue();
|
||||
assertThat(contextBean).isNotSameAs(contextBean2);
|
||||
assertThat(configBean).isNotSameAs(configBean2);
|
||||
MultipartResolver multipartResolver2 = servlet.getMultipartResolver();
|
||||
assertThat(multipartResolver != multipartResolver2).isTrue();
|
||||
assertThat(multipartResolver).isNotSameAs(multipartResolver2);
|
||||
|
||||
servlet.destroy();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -120,13 +120,13 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
||||
assertThat(bean).isNotNull();
|
||||
Object value = new DirectFieldAccessor(bean).getPropertyValue("customArgumentResolvers");
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value instanceof List).isTrue();
|
||||
assertThat(value).isInstanceOf(List.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<HandlerMethodArgumentResolver> resolvers = (List<HandlerMethodArgumentResolver>) value;
|
||||
assertThat(resolvers).hasSize(3);
|
||||
assertThat(resolvers.get(0) instanceof ServletWebArgumentResolverAdapter).isTrue();
|
||||
assertThat(resolvers.get(1) instanceof TestHandlerMethodArgumentResolver).isTrue();
|
||||
assertThat(resolvers.get(2) instanceof TestHandlerMethodArgumentResolver).isTrue();
|
||||
assertThat(resolvers.get(0)).isInstanceOf(ServletWebArgumentResolverAdapter.class);
|
||||
assertThat(resolvers.get(1)).isInstanceOf(TestHandlerMethodArgumentResolver.class);
|
||||
assertThat(resolvers.get(2)).isInstanceOf(TestHandlerMethodArgumentResolver.class);
|
||||
assertThat(resolvers.get(2)).isNotSameAs(resolvers.get(1));
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
||||
assertThat(bean).isNotNull();
|
||||
Object value = new DirectFieldAccessor(bean).getPropertyValue("customReturnValueHandlers");
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value instanceof List).isTrue();
|
||||
assertThat(value).isInstanceOf(List.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<HandlerMethodReturnValueHandler> handlers = (List<HandlerMethodReturnValueHandler>) value;
|
||||
assertThat(handlers).hasSize(2);
|
||||
@@ -170,16 +170,16 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
||||
assertThat(bean).isNotNull();
|
||||
Object value = new DirectFieldAccessor(bean).getPropertyValue("messageConverters");
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value instanceof List).isTrue();
|
||||
assertThat(value).isInstanceOf(List.class);
|
||||
List<HttpMessageConverter<?>> converters = (List<HttpMessageConverter<?>>) value;
|
||||
if (hasDefaultRegistrations) {
|
||||
assertThat(converters.size() > 2).as("Default and custom converter expected").isTrue();
|
||||
assertThat(converters.size()).as("Default and custom converter expected").isGreaterThan(2);
|
||||
}
|
||||
else {
|
||||
assertThat(converters.size() == 2).as("Only custom converters expected").isTrue();
|
||||
assertThat(converters.size()).as("Only custom converters expected").isEqualTo(2);
|
||||
}
|
||||
assertThat(converters.get(0) instanceof StringHttpMessageConverter).isTrue();
|
||||
assertThat(converters.get(1) instanceof ResourceHttpMessageConverter).isTrue();
|
||||
assertThat(converters.get(0)).isInstanceOf(StringHttpMessageConverter.class);
|
||||
assertThat(converters.get(1)).isInstanceOf(ResourceHttpMessageConverter.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -187,9 +187,9 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
||||
assertThat(bean).isNotNull();
|
||||
Object value = new DirectFieldAccessor(bean).getPropertyValue("responseBodyAdvice");
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value instanceof List).isTrue();
|
||||
assertThat(value).isInstanceOf(List.class);
|
||||
List<ResponseBodyAdvice<?>> converters = (List<ResponseBodyAdvice<?>>) value;
|
||||
assertThat(converters.get(0) instanceof JsonViewResponseBodyAdvice).isTrue();
|
||||
assertThat(converters.get(0)).isInstanceOf(JsonViewResponseBodyAdvice.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -197,7 +197,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
||||
assertThat(bean).isNotNull();
|
||||
Object value = new DirectFieldAccessor(bean).getPropertyValue("requestResponseBodyAdvice");
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value instanceof List).isTrue();
|
||||
assertThat(value).isInstanceOf(List.class);
|
||||
List<ResponseBodyAdvice<?>> converters = (List<ResponseBodyAdvice<?>>) value;
|
||||
assertThat(converters.get(0) instanceof JsonViewRequestBodyAdvice).isTrue();
|
||||
assertThat(converters.get(1) instanceof JsonViewResponseBodyAdvice).isTrue();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -215,7 +215,7 @@ public class MvcNamespaceTests {
|
||||
.asInstanceOf(BOOLEAN).isTrue();
|
||||
|
||||
List<HttpMessageConverter<?>> converters = adapter.getMessageConverters();
|
||||
assertThat(converters.size() > 0).isTrue();
|
||||
assertThat(converters.size()).isGreaterThan(0);
|
||||
for (HttpMessageConverter<?> converter : converters) {
|
||||
if (converter instanceof AbstractJackson2HttpMessageConverter) {
|
||||
ObjectMapper objectMapper = ((AbstractJackson2HttpMessageConverter) converter).getObjectMapper();
|
||||
@@ -245,7 +245,7 @@ public class MvcNamespaceTests {
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(1);
|
||||
assertThat(chain.getInterceptorList().get(0) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(0)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
ConversionServiceExposingInterceptor interceptor = (ConversionServiceExposingInterceptor) chain.getInterceptorList().get(0);
|
||||
interceptor.preHandle(request, response, handlerMethod);
|
||||
assertThat(request.getAttribute(ConversionService.class.getName())).isSameAs(appContext.getBean(ConversionService.class));
|
||||
@@ -302,7 +302,7 @@ public class MvcNamespaceTests {
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(1);
|
||||
assertThat(chain.getInterceptorList().get(0) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(0)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
ConversionServiceExposingInterceptor interceptor = (ConversionServiceExposingInterceptor) chain.getInterceptorList().get(0);
|
||||
interceptor.preHandle(request, response, handler);
|
||||
assertThat(request.getAttribute(ConversionService.class.getName())).isSameAs(appContext.getBean("conversionService"));
|
||||
@@ -354,10 +354,10 @@ public class MvcNamespaceTests {
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(4);
|
||||
assertThat(chain.getInterceptorList().get(0) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(3) instanceof UserRoleAuthorizationInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(0)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(3)).isInstanceOf(UserRoleAuthorizationInterceptor.class);
|
||||
|
||||
request.setRequestURI("/admin/users");
|
||||
chain = mapping.getHandler(request);
|
||||
@@ -411,7 +411,7 @@ public class MvcNamespaceTests {
|
||||
|
||||
HandlerExecutionChain chain = resourceMapping.getHandler(request);
|
||||
assertThat(chain).isNotNull();
|
||||
assertThat(chain.getHandler() instanceof ResourceHttpRequestHandler).isTrue();
|
||||
assertThat(chain.getHandler()).isInstanceOf(ResourceHttpRequestHandler.class);
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
for (HandlerInterceptor interceptor : chain.getInterceptorList()) {
|
||||
@@ -534,7 +534,7 @@ public class MvcNamespaceTests {
|
||||
request.setMethod("GET");
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertThat(chain.getHandler() instanceof DefaultServletHttpRequestHandler).isTrue();
|
||||
assertThat(chain.getHandler()).isInstanceOf(DefaultServletHttpRequestHandler.class);
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
ModelAndView mv = adapter.handle(request, response, chain.getHandler());
|
||||
@@ -560,7 +560,7 @@ public class MvcNamespaceTests {
|
||||
request.setMethod("GET");
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertThat(chain.getHandler() instanceof DefaultServletHttpRequestHandler).isTrue();
|
||||
assertThat(chain.getHandler()).isInstanceOf(DefaultServletHttpRequestHandler.class);
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
ModelAndView mv = adapter.handle(request, response, chain.getHandler());
|
||||
@@ -579,9 +579,9 @@ public class MvcNamespaceTests {
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(3);
|
||||
assertThat(chain.getInterceptorList().get(0) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(0)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
LocaleChangeInterceptor interceptor = (LocaleChangeInterceptor) chain.getInterceptorList().get(1);
|
||||
assertThat(interceptor.getParamName()).isEqualTo("lang");
|
||||
ThemeChangeInterceptor interceptor2 = (ThemeChangeInterceptor) chain.getInterceptorList().get(2);
|
||||
@@ -605,9 +605,9 @@ public class MvcNamespaceTests {
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(3);
|
||||
assertThat(chain.getInterceptorList().get(0) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(0)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
|
||||
SimpleUrlHandlerMapping mapping2 = appContext.getBean(SimpleUrlHandlerMapping.class);
|
||||
assertThat(mapping2).isNotNull();
|
||||
@@ -618,9 +618,9 @@ public class MvcNamespaceTests {
|
||||
request = new MockHttpServletRequest("GET", "/foo");
|
||||
chain = mapping2.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(4);
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(3) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(3)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
ModelAndView mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
|
||||
assertThat((Object) mv.getViewName()).isNull();
|
||||
|
||||
@@ -629,9 +629,9 @@ public class MvcNamespaceTests {
|
||||
request.setServletPath("/app");
|
||||
chain = mapping2.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(4);
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(3) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(3)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
|
||||
assertThat(mv.getViewName()).isEqualTo("baz");
|
||||
|
||||
@@ -640,9 +640,9 @@ public class MvcNamespaceTests {
|
||||
request.setServletPath("/app");
|
||||
chain = mapping2.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(4);
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(3) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(3)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
|
||||
assertThat(mv.getViewName()).isEqualTo("root");
|
||||
|
||||
@@ -684,9 +684,9 @@ public class MvcNamespaceTests {
|
||||
request.setAttribute("com.ibm.websphere.servlet.uri_non_decoded", "/myapp/app/bar");
|
||||
HandlerExecutionChain chain = mapping2.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(4);
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(3) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(3)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
ModelAndView mv2 = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
|
||||
assertThat(mv2.getViewName()).isEqualTo("baz");
|
||||
|
||||
@@ -696,9 +696,9 @@ public class MvcNamespaceTests {
|
||||
request.setHttpServletMapping(new MockHttpServletMapping("", "", "", MappingMatch.PATH));
|
||||
chain = mapping2.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(4);
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(3) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(3)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
ModelAndView mv3 = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
|
||||
assertThat(mv3.getViewName()).isEqualTo("root");
|
||||
|
||||
@@ -707,9 +707,9 @@ public class MvcNamespaceTests {
|
||||
request.setServletPath("/");
|
||||
chain = mapping2.getHandler(request);
|
||||
assertThat(chain.getInterceptorList()).hasSize(4);
|
||||
assertThat(chain.getInterceptorList().get(1) instanceof ConversionServiceExposingInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(2) instanceof LocaleChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(3) instanceof ThemeChangeInterceptor).isTrue();
|
||||
assertThat(chain.getInterceptorList().get(1)).isInstanceOf(ConversionServiceExposingInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(LocaleChangeInterceptor.class);
|
||||
assertThat(chain.getInterceptorList().get(3)).isInstanceOf(ThemeChangeInterceptor.class);
|
||||
mv3 = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
|
||||
assertThat(mv3.getViewName()).isEqualTo("root");
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class DelegatingWebMvcConfigurationTests {
|
||||
this.webMvcConfig.mvcConversionService(),
|
||||
this.webMvcConfig.mvcValidator());
|
||||
|
||||
assertThat(adapter.getMessageConverters().size()).as("One custom converter expected").isEqualTo(2);
|
||||
assertThat(adapter.getMessageConverters()).as("One custom converter expected").hasSize(2);
|
||||
assertThat(adapter.getMessageConverters().get(0)).isSameAs(customConverter);
|
||||
assertThat(adapter.getMessageConverters().get(1)).isSameAs(stringConverter);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class DelegatingWebMvcConfigurationTests {
|
||||
assertThat(condition1).isTrue();
|
||||
boolean condition = exceptionResolvers.getValue().get(2) instanceof DefaultHandlerExceptionResolver;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(converters.getValue().size() > 0).isTrue();
|
||||
assertThat(converters.getValue()).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -198,9 +198,8 @@ public class DelegatingWebMvcConfigurationTests {
|
||||
(HandlerExceptionResolverComposite) webMvcConfig
|
||||
.handlerExceptionResolver(webMvcConfig.mvcContentNegotiationManager());
|
||||
|
||||
assertThat(composite.getExceptionResolvers().size())
|
||||
.as("Only one custom converter is expected")
|
||||
.isEqualTo(1);
|
||||
assertThat(composite.getExceptionResolvers())
|
||||
.as("Only one custom converter is expected").hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -111,7 +111,7 @@ class DefaultServerRequestTests {
|
||||
|
||||
DefaultServerRequest request = new DefaultServerRequest(servletRequest, this.messageConverters);
|
||||
|
||||
assertThat(request.attribute("foo")).isEqualTo(Optional.of("bar"));
|
||||
assertThat(request.attribute("foo")).contains("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,7 +121,7 @@ class DefaultServerRequestTests {
|
||||
|
||||
DefaultServerRequest request = new DefaultServerRequest(servletRequest, this.messageConverters);
|
||||
|
||||
assertThat(request.param("foo")).isEqualTo(Optional.of("bar"));
|
||||
assertThat(request.param("foo")).contains("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -149,7 +149,7 @@ class DefaultServerRequestTests {
|
||||
|
||||
DefaultServerRequest request = new DefaultServerRequest(servletRequest, this.messageConverters);
|
||||
|
||||
assertThat(request.param("foo")).isEqualTo(Optional.of(""));
|
||||
assertThat(request.param("foo")).contains("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -159,7 +159,7 @@ class DefaultServerRequestTests {
|
||||
|
||||
DefaultServerRequest request = new DefaultServerRequest(servletRequest, this.messageConverters);
|
||||
|
||||
assertThat(request.param("bar")).isEqualTo(Optional.empty());
|
||||
assertThat(request.param("bar")).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -221,7 +221,7 @@ class DefaultServerRequestTests {
|
||||
assertThat(headers.accept()).isEqualTo(accept);
|
||||
assertThat(headers.acceptCharset()).isEqualTo(acceptCharset);
|
||||
assertThat(headers.contentLength()).isEqualTo(OptionalLong.of(contentLength));
|
||||
assertThat(headers.contentType()).isEqualTo(Optional.of(contentType));
|
||||
assertThat(headers.contentType()).contains(contentType);
|
||||
assertThat(headers.header(HttpHeaders.CONTENT_TYPE)).containsExactly(MediaType.TEXT_PLAIN_VALUE);
|
||||
assertThat(headers.firstHeader(HttpHeaders.CONTENT_TYPE)).isEqualTo(MediaType.TEXT_PLAIN_VALUE);
|
||||
assertThat(headers.asHttpHeaders()).isEqualTo(httpHeaders);
|
||||
@@ -301,7 +301,7 @@ class DefaultServerRequestTests {
|
||||
|
||||
DefaultServerRequest request = new DefaultServerRequest(servletRequest, this.messageConverters);
|
||||
|
||||
assertThat(request.principal().get()).isEqualTo(principal);
|
||||
assertThat(request.principal()).contains(principal);
|
||||
}
|
||||
|
||||
@ParameterizedHttpMethodTest
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -41,7 +41,7 @@ class PathResourceLookupFunctionTests {
|
||||
ServerRequest request = initRequest("GET", "/resources/response.txt");
|
||||
|
||||
Optional<Resource> result = function.apply(request);
|
||||
assertThat(result.isPresent()).isTrue();
|
||||
assertThat(result).isPresent();
|
||||
|
||||
File expected = new ClassPathResource("response.txt", getClass()).getFile();
|
||||
assertThat(result.get().getFile()).isEqualTo(expected);
|
||||
@@ -54,7 +54,7 @@ class PathResourceLookupFunctionTests {
|
||||
ServerRequest request = initRequest("GET", "/resources/child/response.txt");
|
||||
|
||||
Optional<Resource> result = function.apply(request);
|
||||
assertThat(result.isPresent()).isTrue();
|
||||
assertThat(result).isPresent();
|
||||
|
||||
File expected = new ClassPathResource("org/springframework/web/servlet/function/child/response.txt").getFile();
|
||||
assertThat(result.get().getFile()).isEqualTo(expected);
|
||||
@@ -67,7 +67,7 @@ class PathResourceLookupFunctionTests {
|
||||
ServerRequest request = initRequest("GET", "/resources/foo.txt");
|
||||
|
||||
Optional<Resource> result = function.apply(request);
|
||||
assertThat(result.isPresent()).isFalse();
|
||||
assertThat(result).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,7 +91,7 @@ class PathResourceLookupFunctionTests {
|
||||
ServerRequest request = initRequest("GET", "/resources/foo");
|
||||
|
||||
Optional<Resource> result = customLookupFunction.apply(request);
|
||||
assertThat(result.isPresent()).isTrue();
|
||||
assertThat(result).isPresent();
|
||||
|
||||
assertThat(result.get().getFile()).isEqualTo(defaultResource.getFile());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -50,8 +50,8 @@ class RouterFunctionTests {
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
Optional<HandlerFunction<ServerResponse>> resultHandlerFunction = result.route(request);
|
||||
assertThat(resultHandlerFunction.isPresent()).isTrue();
|
||||
assertThat(resultHandlerFunction.get()).isEqualTo(handlerFunction);
|
||||
assertThat(resultHandlerFunction).isPresent();
|
||||
assertThat(resultHandlerFunction).contains(handlerFunction);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class RouterFunctionTests {
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
Optional<? extends HandlerFunction<?>> resultHandlerFunction = result.route(request);
|
||||
assertThat(resultHandlerFunction.isPresent()).isTrue();
|
||||
assertThat(resultHandlerFunction).isPresent();
|
||||
assertThat(resultHandlerFunction.get()).isEqualTo(handlerFunction);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class RouterFunctionTests {
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
Optional<? extends HandlerFunction<?>> resultHandlerFunction = result.route(request);
|
||||
assertThat(resultHandlerFunction.isPresent()).isTrue();
|
||||
assertThat(resultHandlerFunction).isPresent();
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class RouterFunctionTests {
|
||||
throw new AssertionError(ex.getMessage(), ex);
|
||||
}
|
||||
});
|
||||
assertThat(resultHandlerFunction.isPresent()).isTrue();
|
||||
assertThat(resultHandlerFunction).isPresent();
|
||||
assertThat((int) resultHandlerFunction.get().entity()).isEqualTo(42);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ public class RouterFunctionsTests {
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
Optional<HandlerFunction<ServerResponse>> resultHandlerFunction = result.route(request);
|
||||
assertThat(resultHandlerFunction.isPresent()).isTrue();
|
||||
assertThat(resultHandlerFunction.get()).isEqualTo(handlerFunction);
|
||||
assertThat(resultHandlerFunction).isPresent();
|
||||
assertThat(resultHandlerFunction).contains(handlerFunction);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,7 +64,7 @@ public class RouterFunctionsTests {
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
Optional<HandlerFunction<ServerResponse>> resultHandlerFunction = result.route(request);
|
||||
assertThat(resultHandlerFunction.isPresent()).isFalse();
|
||||
assertThat(resultHandlerFunction).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,8 +79,8 @@ public class RouterFunctionsTests {
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
Optional<HandlerFunction<ServerResponse>> resultHandlerFunction = result.route(request);
|
||||
assertThat(resultHandlerFunction.isPresent()).isTrue();
|
||||
assertThat(resultHandlerFunction.get()).isEqualTo(handlerFunction);
|
||||
assertThat(resultHandlerFunction).isPresent();
|
||||
assertThat(resultHandlerFunction).contains(handlerFunction);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,7 +95,7 @@ public class RouterFunctionsTests {
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
Optional<HandlerFunction<ServerResponse>> resultHandlerFunction = result.route(request);
|
||||
assertThat(resultHandlerFunction.isPresent()).isFalse();
|
||||
assertThat(resultHandlerFunction).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,8 +110,8 @@ public class RouterFunctionsTests {
|
||||
MockHttpServletRequest servletRequest = new MockHttpServletRequest("GET", "/bar");
|
||||
ServerRequest request = new DefaultServerRequest(servletRequest, Collections.emptyList());
|
||||
Optional<HandlerFunction<ServerResponse>> resultHandlerFunction = result.route(request);
|
||||
assertThat(resultHandlerFunction.isPresent()).isTrue();
|
||||
assertThat(resultHandlerFunction.get()).isEqualTo(handlerFunction);
|
||||
assertThat(resultHandlerFunction).isPresent();
|
||||
assertThat(resultHandlerFunction).contains(handlerFunction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,11 +57,11 @@ public class BeanNameUrlHandlerMappingTests {
|
||||
MockHttpServletRequest req = new MockHttpServletRequest("GET", "/myapp/mypath/nonsense.html");
|
||||
req.setContextPath("/myapp");
|
||||
Object h = hm.getHandler(req);
|
||||
assertThat(h == null).as("Handler is null").isTrue();
|
||||
assertThat(h).as("Handler is null").isNull();
|
||||
|
||||
req = new MockHttpServletRequest("GET", "/foo/bar/baz.html");
|
||||
h = hm.getHandler(req);
|
||||
assertThat(h == null).as("Handler is null").isTrue();
|
||||
assertThat(h).as("Handler is null").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -170,7 +170,7 @@ public class BeanNameUrlHandlerMappingTests {
|
||||
|
||||
req = new MockHttpServletRequest("GET", "/mypath/tes");
|
||||
hec = hm.getHandler(req);
|
||||
assertThat(hec == null).as("Handler is correct bean").isTrue();
|
||||
assertThat(hec).as("Handler is correct bean").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -190,7 +190,7 @@ public class BeanNameUrlHandlerMappingTests {
|
||||
|
||||
req = new MockHttpServletRequest("GET", "/mypath/tes");
|
||||
hec = hm.getHandler(req);
|
||||
assertThat(hec == null).as("Handler is correct bean").isTrue();
|
||||
assertThat(hec).as("Handler is correct bean").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -68,15 +68,15 @@ public class PathMatchingUrlHandlerMappingTests {
|
||||
|
||||
MockHttpServletRequest req = new MockHttpServletRequest("GET", "/welcome.html");
|
||||
HandlerExecutionChain hec = getHandler(mapping, wac, req);
|
||||
assertThat(hec.getHandler() == bean).isTrue();
|
||||
assertThat(hec.getHandler()).isSameAs(bean);
|
||||
|
||||
req = new MockHttpServletRequest("GET", "/show.html");
|
||||
hec = getHandler(mapping, wac, req);
|
||||
assertThat(hec.getHandler() == bean).isTrue();
|
||||
assertThat(hec.getHandler()).isSameAs(bean);
|
||||
|
||||
req = new MockHttpServletRequest("GET", "/bookseats.html");
|
||||
hec = getHandler(mapping, wac, req);
|
||||
assertThat(hec.getHandler() == bean).isTrue();
|
||||
assertThat(hec.getHandler()).isSameAs(bean);
|
||||
}
|
||||
|
||||
@PathPatternsParameterizedTest
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -157,7 +157,7 @@ public class SimpleUrlHandlerMappingTests {
|
||||
|
||||
request = PathPatternsTestUtils.initRequest("GET", "/somePath", usePathPatterns);
|
||||
chain = getHandler(hm, request);
|
||||
assertThat(chain.getHandler() == defaultBean).as("Handler is correct bean").isTrue();
|
||||
assertThat(chain.getHandler()).as("Handler is correct bean").isSameAs(defaultBean);
|
||||
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("/somePath");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -357,7 +357,7 @@ class CookieLocaleResolverTests {
|
||||
assertThat(cookies).hasSize(1);
|
||||
Cookie localeCookie = cookies[0];
|
||||
assertThat(localeCookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
|
||||
assertThat(localeCookie.getValue()).isEqualTo("");
|
||||
assertThat(localeCookie.getValue()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -376,7 +376,7 @@ class CookieLocaleResolverTests {
|
||||
assertThat(cookies).hasSize(1);
|
||||
Cookie localeCookie = cookies[0];
|
||||
assertThat(localeCookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
|
||||
assertThat(localeCookie.getValue()).isEqualTo("");
|
||||
assertThat(localeCookie.getValue()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -394,7 +394,7 @@ class CookieLocaleResolverTests {
|
||||
assertThat(cookies).hasSize(1);
|
||||
Cookie localeCookie = cookies[0];
|
||||
assertThat(localeCookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
|
||||
assertThat(localeCookie.getValue()).isEqualTo("");
|
||||
assertThat(localeCookie.getValue()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -415,7 +415,7 @@ class CookieLocaleResolverTests {
|
||||
assertThat(cookies).hasSize(1);
|
||||
Cookie localeCookie = cookies[0];
|
||||
assertThat(localeCookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
|
||||
assertThat(localeCookie.getValue()).isEqualTo("");
|
||||
assertThat(localeCookie.getValue()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -52,9 +52,9 @@ public class ControllerTests {
|
||||
pvc.setViewName(viewName);
|
||||
// We don't care about the params.
|
||||
ModelAndView mv = pvc.handleRequest(new MockHttpServletRequest("GET", "foo.html"), new MockHttpServletResponse());
|
||||
assertThat(mv.getModel().size() == 0).as("model has no data").isTrue();
|
||||
assertThat(mv.getViewName().equals(viewName)).as("model has correct viewname").isTrue();
|
||||
assertThat(pvc.getViewName().equals(viewName)).as("getViewName matches").isTrue();
|
||||
assertThat(mv.getModel()).as("model has no data").isEmpty();
|
||||
assertThat(mv.getViewName()).as("model has correct viewname").isEqualTo(viewName);
|
||||
assertThat(pvc.getViewName()).as("getViewName matches").isEqualTo(viewName);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -154,8 +154,7 @@ class UrlFilenameViewControllerTests {
|
||||
.as("For setPrefix(..) with null, the empty string must be used instead.")
|
||||
.isNotNull();
|
||||
assertThat(controller.getPrefix())
|
||||
.as("For setPrefix(..) with null, the empty string must be used instead.")
|
||||
.isEqualTo("");
|
||||
.as("For setPrefix(..) with null, the empty string must be used instead.").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,8 +165,7 @@ class UrlFilenameViewControllerTests {
|
||||
.as("For setPrefix(..) with null, the empty string must be used instead.")
|
||||
.isNotNull();
|
||||
assertThat(controller.getSuffix())
|
||||
.as("For setPrefix(..) with null, the empty string must be used instead.")
|
||||
.isEqualTo("");
|
||||
.as("For setPrefix(..) with null, the empty string must be used instead.").isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -110,8 +110,8 @@ class WebContentInterceptorTests {
|
||||
interceptor.setCacheSeconds(10);
|
||||
interceptor.preHandle(requestFactory.apply("/"), response, handler);
|
||||
|
||||
assertThat(response.getHeader("Pragma")).isEqualTo("");
|
||||
assertThat(response.getHeader("Expires")).isEqualTo("");
|
||||
assertThat(response.getHeader("Pragma")).isEmpty();
|
||||
assertThat(response.getHeader("Expires")).isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -124,8 +124,8 @@ class WebContentInterceptorTests {
|
||||
interceptor.setAlwaysMustRevalidate(true);
|
||||
interceptor.preHandle(requestFactory.apply("/"), response, handler);
|
||||
|
||||
assertThat(response.getHeader("Pragma")).isEqualTo("");
|
||||
assertThat(response.getHeader("Expires")).isEqualTo("");
|
||||
assertThat(response.getHeader("Pragma")).isEmpty();
|
||||
assertThat(response.getHeader("Expires")).isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -162,10 +162,10 @@ public class ConsumesRequestConditionTests {
|
||||
ConsumesRequestCondition condition2 = new ConsumesRequestCondition("text/*");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -176,10 +176,10 @@ public class ConsumesRequestConditionTests {
|
||||
ConsumesRequestCondition condition2 = new ConsumesRequestCondition("text/*", "text/plain;q=0.7");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -124,10 +124,10 @@ public class HeadersRequestConditionTests {
|
||||
HeadersRequestCondition condition2 = new HeadersRequestCondition("foo=a", "bar");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test // SPR-16674
|
||||
@@ -138,10 +138,10 @@ public class HeadersRequestConditionTests {
|
||||
HeadersRequestCondition condition2 = new HeadersRequestCondition("foo");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -96,10 +96,10 @@ public class ParamsRequestConditionTests {
|
||||
ParamsRequestCondition condition2 = new ParamsRequestCondition("foo=a", "bar");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test // SPR-16674
|
||||
@@ -110,7 +110,7 @@ public class ParamsRequestConditionTests {
|
||||
ParamsRequestCondition condition2 = new ParamsRequestCondition("response_type");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -43,8 +43,7 @@ public class PathPatternsRequestConditionTests {
|
||||
@Test
|
||||
void prependNonEmptyPatternsOnly() {
|
||||
assertThat(createCondition("").getPatternValues().iterator().next())
|
||||
.as("Do not prepend empty patterns (SPR-8255)")
|
||||
.isEqualTo("");
|
||||
.as("Do not prepend empty patterns (SPR-8255)").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -42,8 +42,7 @@ class PatternsRequestConditionTests {
|
||||
@Test
|
||||
void prependNonEmptyPatternsOnly() {
|
||||
assertThat(new PatternsRequestCondition("").getPatterns().iterator().next())
|
||||
.as("Do not prepend empty patterns (SPR-8255)")
|
||||
.isEqualTo("");
|
||||
.as("Do not prepend empty patterns (SPR-8255)").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -175,17 +175,17 @@ public class ProducesRequestConditionTests {
|
||||
|
||||
HttpServletRequest request = createRequest("application/xml, text/html");
|
||||
|
||||
assertThat(html.compareTo(xml, request) > 0).isTrue();
|
||||
assertThat(xml.compareTo(html, request) < 0).isTrue();
|
||||
assertThat(xml.compareTo(none, request) < 0).isTrue();
|
||||
assertThat(none.compareTo(xml, request) > 0).isTrue();
|
||||
assertThat(html.compareTo(none, request) < 0).isTrue();
|
||||
assertThat(none.compareTo(html, request) > 0).isTrue();
|
||||
assertThat(html.compareTo(xml, request)).isGreaterThan(0);
|
||||
assertThat(xml.compareTo(html, request)).isLessThan(0);
|
||||
assertThat(xml.compareTo(none, request)).isLessThan(0);
|
||||
assertThat(none.compareTo(xml, request)).isGreaterThan(0);
|
||||
assertThat(html.compareTo(none, request)).isLessThan(0);
|
||||
assertThat(none.compareTo(html, request)).isGreaterThan(0);
|
||||
|
||||
request = createRequest("application/xml, text/*");
|
||||
|
||||
assertThat(html.compareTo(xml, request) > 0).isTrue();
|
||||
assertThat(xml.compareTo(html, request) < 0).isTrue();
|
||||
assertThat(html.compareTo(xml, request)).isGreaterThan(0);
|
||||
assertThat(xml.compareTo(html, request)).isLessThan(0);
|
||||
|
||||
request = createRequest("application/pdf");
|
||||
|
||||
@@ -195,8 +195,8 @@ public class ProducesRequestConditionTests {
|
||||
// See SPR-7000
|
||||
request = createRequest("text/html;q=0.9,application/xml");
|
||||
|
||||
assertThat(html.compareTo(xml, request) > 0).isTrue();
|
||||
assertThat(xml.compareTo(html, request) < 0).isTrue();
|
||||
assertThat(html.compareTo(xml, request)).isGreaterThan(0);
|
||||
assertThat(xml.compareTo(html, request)).isLessThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,10 +207,10 @@ public class ProducesRequestConditionTests {
|
||||
ProducesRequestCondition condition2 = new ProducesRequestCondition("text/*");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -235,18 +235,18 @@ public class ProducesRequestConditionTests {
|
||||
HttpServletRequest request = createRequest("text/plain", "application/xml");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
|
||||
request = createRequest("application/xml", "text/plain");
|
||||
|
||||
result = condition1.compareTo(condition2, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
}
|
||||
|
||||
// SPR-8536
|
||||
@@ -258,28 +258,30 @@ public class ProducesRequestConditionTests {
|
||||
ProducesRequestCondition condition1 = new ProducesRequestCondition();
|
||||
ProducesRequestCondition condition2 = new ProducesRequestCondition("application/json");
|
||||
|
||||
assertThat(condition1.compareTo(condition2, request) < 0).as("Should have picked '*/*' condition as an exact match").isTrue();
|
||||
assertThat(condition2.compareTo(condition1, request) > 0).as("Should have picked '*/*' condition as an exact match").isTrue();
|
||||
assertThat(condition1.compareTo(condition2, request)).as("Should have picked '*/*' condition as an exact match")
|
||||
.isLessThan(0);
|
||||
assertThat(condition2.compareTo(condition1, request)).as("Should have picked '*/*' condition as an exact match")
|
||||
.isGreaterThan(0);
|
||||
|
||||
condition1 = new ProducesRequestCondition("*/*");
|
||||
condition2 = new ProducesRequestCondition("application/json");
|
||||
|
||||
assertThat(condition1.compareTo(condition2, request) < 0).isTrue();
|
||||
assertThat(condition2.compareTo(condition1, request) > 0).isTrue();
|
||||
assertThat(condition1.compareTo(condition2, request)).isLessThan(0);
|
||||
assertThat(condition2.compareTo(condition1, request)).isGreaterThan(0);
|
||||
|
||||
request.addHeader("Accept", "*/*");
|
||||
|
||||
condition1 = new ProducesRequestCondition();
|
||||
condition2 = new ProducesRequestCondition("application/json");
|
||||
|
||||
assertThat(condition1.compareTo(condition2, request) < 0).isTrue();
|
||||
assertThat(condition2.compareTo(condition1, request) > 0).isTrue();
|
||||
assertThat(condition1.compareTo(condition2, request)).isLessThan(0);
|
||||
assertThat(condition2.compareTo(condition1, request)).isGreaterThan(0);
|
||||
|
||||
condition1 = new ProducesRequestCondition("*/*");
|
||||
condition2 = new ProducesRequestCondition("application/json");
|
||||
|
||||
assertThat(condition1.compareTo(condition2, request) < 0).isTrue();
|
||||
assertThat(condition2.compareTo(condition1, request) > 0).isTrue();
|
||||
assertThat(condition1.compareTo(condition2, request)).isLessThan(0);
|
||||
assertThat(condition2.compareTo(condition1, request)).isGreaterThan(0);
|
||||
}
|
||||
|
||||
// SPR-9021
|
||||
@@ -291,8 +293,8 @@ public class ProducesRequestConditionTests {
|
||||
ProducesRequestCondition condition1 = new ProducesRequestCondition();
|
||||
ProducesRequestCondition condition2 = new ProducesRequestCondition("application/json");
|
||||
|
||||
assertThat(condition1.compareTo(condition2, request) < 0).isTrue();
|
||||
assertThat(condition2.compareTo(condition1, request) > 0).isTrue();
|
||||
assertThat(condition1.compareTo(condition2, request)).isLessThan(0);
|
||||
assertThat(condition2.compareTo(condition1, request)).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -303,10 +305,10 @@ public class ProducesRequestConditionTests {
|
||||
ProducesRequestCondition condition2 = new ProducesRequestCondition("text/xhtml");
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertThat(result < 0).as("Should have used MediaType.equals(Object) to break the match").isTrue();
|
||||
assertThat(result).as("Should have used MediaType.equals(Object) to break the match").isLessThan(0);
|
||||
|
||||
result = condition2.compareTo(condition1, request);
|
||||
assertThat(result > 0).as("Should have used MediaType.equals(Object) to break the match").isTrue();
|
||||
assertThat(result).as("Should have used MediaType.equals(Object) to break the match").isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -105,13 +105,13 @@ public class RequestMethodsRequestConditionTests {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
|
||||
int result = c1.compareTo(c2, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = c2.compareTo(c1, request);
|
||||
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isGreaterThan(0);
|
||||
|
||||
result = c2.compareTo(c3, request);
|
||||
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
|
||||
assertThat(result).as("Invalid comparison result: " + result).isLessThan(0);
|
||||
|
||||
result = c1.compareTo(c1, request);
|
||||
assertThat(result).as("Invalid comparison result ").isEqualTo(0);
|
||||
|
||||
@@ -363,7 +363,7 @@ class RequestMappingInfoHandlerMappingTests {
|
||||
|
||||
assertThat(matrixVariables).isNull();
|
||||
assertThat(uriVariables.get("cars")).isEqualTo("cars");
|
||||
assertThat(uriVariables.get("params")).isEqualTo("");
|
||||
assertThat(uriVariables.get("params")).isEmpty();
|
||||
|
||||
// SPR-11897
|
||||
request = new MockHttpServletRequest("GET", "/a=42;b=c");
|
||||
|
||||
@@ -128,7 +128,7 @@ public abstract class AbstractRequestAttributesArgumentResolverTests {
|
||||
Object actual = testResolveArgument(param, factory);
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.getClass()).isEqualTo(Optional.class);
|
||||
assertThat(((Optional<?>) actual).isPresent()).isFalse();
|
||||
assertThat(((Optional<?>) actual)).isNotPresent();
|
||||
|
||||
Foo foo = new Foo();
|
||||
this.webRequest.setAttribute("foo", foo, getScope());
|
||||
@@ -136,7 +136,7 @@ public abstract class AbstractRequestAttributesArgumentResolverTests {
|
||||
actual = testResolveArgument(param, factory);
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.getClass()).isEqualTo(Optional.class);
|
||||
assertThat(((Optional<?>) actual).isPresent()).isTrue();
|
||||
assertThat(((Optional<?>) actual)).isPresent();
|
||||
assertThat(((Optional<?>) actual).get()).isSameAs(foo);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -358,7 +358,7 @@ public class ExceptionHandlerExceptionResolverTests {
|
||||
assertThat(mav.isEmpty()).isTrue();
|
||||
assertThat(this.response.getStatus()).isEqualTo(HttpStatus.GATEWAY_TIMEOUT.value());
|
||||
assertThat(this.response.getErrorMessage()).isEqualTo("Gateway Timeout");
|
||||
assertThat(this.response.getContentAsString()).isEqualTo("");
|
||||
assertThat(this.response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -214,7 +214,7 @@ class HttpEntityMethodProcessorMockTests {
|
||||
|
||||
Object result = processor.resolveArgument(paramHttpEntity, mavContainer, webRequest, null);
|
||||
|
||||
assertThat(result instanceof HttpEntity).isTrue();
|
||||
assertThat(result).isInstanceOf(HttpEntity.class);
|
||||
assertThat(mavContainer.isRequestHandled()).as("The requestHandled flag shouldn't change").isFalse();
|
||||
assertThat(((HttpEntity<?>) result).getBody()).as("Invalid argument").isEqualTo(body);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class HttpEntityMethodProcessorMockTests {
|
||||
|
||||
Object result = processor.resolveArgument(paramRequestEntity, mavContainer, webRequest, null);
|
||||
|
||||
assertThat(result instanceof RequestEntity).isTrue();
|
||||
assertThat(result).isInstanceOf(RequestEntity.class);
|
||||
assertThat(mavContainer.isRequestHandled()).as("The requestHandled flag shouldn't change").isFalse();
|
||||
RequestEntity<?> requestEntity = (RequestEntity<?>) result;
|
||||
assertThat(requestEntity.getMethod()).as("Invalid method").isEqualTo(HttpMethod.GET);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -185,8 +185,8 @@ public class HttpEntityMethodProcessorTests {
|
||||
processor.handleReturnValue(returnValue, methodReturnType, this.mavContainer, this.webRequest);
|
||||
|
||||
String content = this.servletResponse.getContentAsString();
|
||||
assertThat(content.contains("\"type\":\"foo\"")).isTrue();
|
||||
assertThat(content.contains("\"type\":\"bar\"")).isTrue();
|
||||
assertThat(content).contains("\"type\":\"foo\"");
|
||||
assertThat(content).contains("\"type\":\"bar\"");
|
||||
}
|
||||
|
||||
@Test // SPR-13423
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -131,7 +131,7 @@ public class PathVariableMethodArgumentResolverTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
Optional<String> result = (Optional<String>)
|
||||
resolver.resolveArgument(paramOptional, mavContainer, webRequest, binderFactory);
|
||||
assertThat(result.get()).as("PathVariable not resolved correctly").isEqualTo("value");
|
||||
assertThat(result).as("PathVariable not resolved correctly").contains("value");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> pathVars = (Map<String, Object>) request.getAttribute(View.PATH_VARIABLES);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -212,7 +212,7 @@ class RequestMappingHandlerAdapterIntegrationTests {
|
||||
bindingResult = (BindingResult) model.get(BindingResult.MODEL_KEY_PREFIX + conventionAttrName);
|
||||
assertThat(bindingResult.getTarget()).isSameAs(modelAttrByConvention);
|
||||
|
||||
assertThat(model.get("customArg") instanceof Color).isTrue();
|
||||
assertThat(model.get("customArg")).isInstanceOf(Color.class);
|
||||
assertThat(model.get("user").getClass()).isEqualTo(User.class);
|
||||
assertThat(model.get("otherUser").getClass()).isEqualTo(OtherUser.class);
|
||||
assertThat(((Principal) model.get("customUser")).getName()).isEqualTo("Custom User");
|
||||
@@ -294,7 +294,7 @@ class RequestMappingHandlerAdapterIntegrationTests {
|
||||
bindingResult = (BindingResult) model.get(BindingResult.MODEL_KEY_PREFIX + conventionAttrName);
|
||||
assertThat(bindingResult.getTarget()).isSameAs(modelAttrByConvention);
|
||||
|
||||
assertThat(model.get("customArg") instanceof Color).isTrue();
|
||||
assertThat(model.get("customArg")).isInstanceOf(Color.class);
|
||||
assertThat(model.get("user").getClass()).isEqualTo(User.class);
|
||||
assertThat(model.get("otherUser").getClass()).isEqualTo(OtherUser.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -114,7 +114,7 @@ public class RequestMappingHandlerAdapterTests {
|
||||
this.handlerAdapter.afterPropertiesSet();
|
||||
|
||||
this.handlerAdapter.handle(this.request, this.response, handlerMethod);
|
||||
assertThat(response.getHeader("Cache-Control").contains("max-age")).isTrue();
|
||||
assertThat(response.getHeader("Cache-Control")).contains("max-age");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -193,7 +193,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
@Test
|
||||
void resolveMultipartFileList() throws Exception {
|
||||
Object actual = resolver.resolveArgument(paramMultipartFileList, null, webRequest, null);
|
||||
assertThat(actual instanceof List).isTrue();
|
||||
assertThat(actual).isInstanceOf(List.class);
|
||||
assertThat(actual).isEqualTo(Arrays.asList(multipartFile1, multipartFile2));
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
void resolveMultipartFileArray() throws Exception {
|
||||
Object actual = resolver.resolveArgument(paramMultipartFileArray, null, webRequest, null);
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual instanceof MultipartFile[]).isTrue();
|
||||
assertThat(actual).isInstanceOf(MultipartFile[].class);
|
||||
MultipartFile[] parts = (MultipartFile[]) actual;
|
||||
assertThat(parts).hasSize(2);
|
||||
assertThat(multipartFile1).isEqualTo(parts[0]);
|
||||
@@ -218,7 +218,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
|
||||
Object result = resolver.resolveArgument(paramMultipartFileNotAnnot, null, webRequest, null);
|
||||
|
||||
assertThat(result instanceof MultipartFile).isTrue();
|
||||
assertThat(result).isInstanceOf(MultipartFile.class);
|
||||
assertThat(result).as("Invalid result").isEqualTo(expected);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
webRequest = new ServletWebRequest(request);
|
||||
|
||||
Object result = resolver.resolveArgument(paramPart, null, webRequest, null);
|
||||
assertThat(result instanceof Part).isTrue();
|
||||
assertThat(result).isInstanceOf(Part.class);
|
||||
assertThat(result).as("Invalid result").isEqualTo(expected);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
webRequest = new ServletWebRequest(request);
|
||||
|
||||
Object result = resolver.resolveArgument(paramPartList, null, webRequest, null);
|
||||
assertThat(result instanceof List).isTrue();
|
||||
assertThat(result).isInstanceOf(List.class);
|
||||
assertThat(result).isEqualTo(Arrays.asList(part1, part2));
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
webRequest = new ServletWebRequest(request);
|
||||
|
||||
Object result = resolver.resolveArgument(paramPartArray, null, webRequest, null);
|
||||
assertThat(result instanceof Part[]).isTrue();
|
||||
assertThat(result).isInstanceOf(Part[].class);
|
||||
Part[] parts = (Part[]) result;
|
||||
assertThat(parts).hasSize(2);
|
||||
assertThat(part1).isEqualTo(parts[0]);
|
||||
@@ -357,12 +357,11 @@ class RequestPartMethodArgumentResolverTests {
|
||||
webRequest = new ServletWebRequest(request);
|
||||
|
||||
Object actualValue = resolver.resolveArgument(optionalMultipartFile, null, webRequest, null);
|
||||
boolean condition1 = actualValue instanceof Optional;
|
||||
assertThat(condition1).isTrue();
|
||||
assertThat(actualValue).isInstanceOf(Optional.class);
|
||||
assertThat(((Optional<?>) actualValue).get()).as("Invalid result").isEqualTo(expected);
|
||||
|
||||
actualValue = resolver.resolveArgument(optionalMultipartFile, null, webRequest, null);
|
||||
assertThat(actualValue instanceof Optional).isTrue();
|
||||
assertThat(actualValue).isInstanceOf(Optional.class);
|
||||
assertThat(((Optional<?>) actualValue).get()).as("Invalid result").isEqualTo(expected);
|
||||
}
|
||||
|
||||
@@ -403,7 +402,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
assertThat(((Optional<?>) actualValue).get()).as("Invalid result").isEqualTo(Collections.singletonList(expected));
|
||||
|
||||
actualValue = resolver.resolveArgument(optionalMultipartFileList, null, webRequest, null);
|
||||
assertThat(actualValue instanceof Optional).isTrue();
|
||||
assertThat(actualValue).isInstanceOf(Optional.class);
|
||||
assertThat(((Optional<?>) actualValue).get()).as("Invalid result").isEqualTo(Collections.singletonList(expected));
|
||||
}
|
||||
|
||||
@@ -446,7 +445,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
assertThat(((Optional<?>) actualValue).get()).as("Invalid result").isEqualTo(expected);
|
||||
|
||||
actualValue = resolver.resolveArgument(optionalPart, null, webRequest, null);
|
||||
assertThat(actualValue instanceof Optional).isTrue();
|
||||
assertThat(actualValue).isInstanceOf(Optional.class);
|
||||
assertThat(((Optional<?>) actualValue).get()).as("Invalid result").isEqualTo(expected);
|
||||
}
|
||||
|
||||
@@ -491,7 +490,7 @@ class RequestPartMethodArgumentResolverTests {
|
||||
assertThat(((Optional<?>) actualValue).get()).as("Invalid result").isEqualTo(Collections.singletonList(expected));
|
||||
|
||||
actualValue = resolver.resolveArgument(optionalPartList, null, webRequest, null);
|
||||
assertThat(actualValue instanceof Optional).isTrue();
|
||||
assertThat(actualValue).isInstanceOf(Optional.class);
|
||||
assertThat(((Optional<?>) actualValue).get()).as("Invalid result").isEqualTo(Collections.singletonList(expected));
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ class ResponseBodyEmitterReturnValueHandlerTests {
|
||||
this.handler.handleReturnValue(emitter, type, this.mavContainer, this.webRequest);
|
||||
|
||||
assertThat(this.request.isAsyncStarted()).isTrue();
|
||||
assertThat(this.response.getContentAsString()).isEqualTo("");
|
||||
assertThat(this.response.getContentAsString()).isEmpty();
|
||||
|
||||
SimpleBean bean = new SimpleBean();
|
||||
bean.setId(1L);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -350,12 +350,12 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
assertThat(allowHeader).as("No Allow header").isNotNull();
|
||||
Set<String> allowedMethods = new HashSet<>(Arrays.asList(StringUtils.delimitedListToStringArray(allowHeader, ", ")));
|
||||
assertThat(allowedMethods.size()).as("Invalid amount of supported methods").isEqualTo(6);
|
||||
assertThat(allowedMethods.contains("PUT")).as("PUT not allowed").isTrue();
|
||||
assertThat(allowedMethods.contains("DELETE")).as("DELETE not allowed").isTrue();
|
||||
assertThat(allowedMethods.contains("HEAD")).as("HEAD not allowed").isTrue();
|
||||
assertThat(allowedMethods.contains("TRACE")).as("TRACE not allowed").isTrue();
|
||||
assertThat(allowedMethods.contains("OPTIONS")).as("OPTIONS not allowed").isTrue();
|
||||
assertThat(allowedMethods.contains("POST")).as("POST not allowed").isTrue();
|
||||
assertThat(allowedMethods).as("PUT not allowed").contains("PUT");
|
||||
assertThat(allowedMethods).as("DELETE not allowed").contains("DELETE");
|
||||
assertThat(allowedMethods).as("HEAD not allowed").contains("HEAD");
|
||||
assertThat(allowedMethods).as("TRACE not allowed").contains("TRACE");
|
||||
assertThat(allowedMethods).as("OPTIONS not allowed").contains("OPTIONS");
|
||||
assertThat(allowedMethods).as("POST not allowed").contains("POST");
|
||||
}
|
||||
|
||||
@PathPatternsParameterizedTest
|
||||
@@ -372,7 +372,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
EmptyParameterListHandlerMethodController.called = false;
|
||||
getServlet().service(request, response);
|
||||
assertThat(EmptyParameterListHandlerMethodController.called).isTrue();
|
||||
assertThat(response.getContentAsString()).isEqualTo("");
|
||||
assertThat(response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -389,20 +389,20 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
assertThat(request.getAttribute("viewName")).isEqualTo("page1");
|
||||
HttpSession session = request.getSession();
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(session.getAttribute("object1") != null).isTrue();
|
||||
assertThat(session.getAttribute("object2") != null).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object1")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object2")).isTrue();
|
||||
assertThat(session.getAttribute("object1")).isNotNull();
|
||||
assertThat(session.getAttribute("object2")).isNotNull();
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object1");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
|
||||
|
||||
request = new MockHttpServletRequest("POST", "/myPage");
|
||||
request.setSession(session);
|
||||
response = new MockHttpServletResponse();
|
||||
getServlet().service(request, response);
|
||||
assertThat(request.getAttribute("viewName")).isEqualTo("page2");
|
||||
assertThat(session.getAttribute("object1") != null).isTrue();
|
||||
assertThat(session.getAttribute("object2") != null).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object1")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object2")).isTrue();
|
||||
assertThat(session.getAttribute("object1")).isNotNull();
|
||||
assertThat(session.getAttribute("object2")).isNotNull();
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object1");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -422,20 +422,20 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
assertThat(request.getAttribute("viewName")).isEqualTo("page1");
|
||||
HttpSession session = request.getSession();
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(session.getAttribute("object1") != null).isTrue();
|
||||
assertThat(session.getAttribute("object2") != null).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object1")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object2")).isTrue();
|
||||
assertThat(session.getAttribute("object1")).isNotNull();
|
||||
assertThat(session.getAttribute("object2")).isNotNull();
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object1");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
|
||||
|
||||
request = new MockHttpServletRequest("POST", "/myPage");
|
||||
request.setSession(session);
|
||||
response = new MockHttpServletResponse();
|
||||
getServlet().service(request, response);
|
||||
assertThat(request.getAttribute("viewName")).isEqualTo("page2");
|
||||
assertThat(session.getAttribute("object1") != null).isTrue();
|
||||
assertThat(session.getAttribute("object2") != null).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object1")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object2")).isTrue();
|
||||
assertThat(session.getAttribute("object1")).isNotNull();
|
||||
assertThat(session.getAttribute("object2")).isNotNull();
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object1");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -452,22 +452,22 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
assertThat(request.getAttribute("viewName")).isEqualTo("page1");
|
||||
HttpSession session = request.getSession();
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(session.getAttribute("object1") != null).isTrue();
|
||||
assertThat(session.getAttribute("object2") != null).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object1")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object2")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("testBeanList")).isTrue();
|
||||
assertThat(session.getAttribute("object1")).isNotNull();
|
||||
assertThat(session.getAttribute("object2")).isNotNull();
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object1");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("testBeanList");
|
||||
|
||||
request = new MockHttpServletRequest("POST", "/myPage");
|
||||
request.setSession(session);
|
||||
response = new MockHttpServletResponse();
|
||||
getServlet().service(request, response);
|
||||
assertThat(request.getAttribute("viewName")).isEqualTo("page2");
|
||||
assertThat(session.getAttribute("object1") != null).isTrue();
|
||||
assertThat(session.getAttribute("object2") != null).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object1")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object2")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("testBeanList")).isTrue();
|
||||
assertThat(session.getAttribute("object1")).isNotNull();
|
||||
assertThat(session.getAttribute("object2")).isNotNull();
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object1");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("testBeanList");
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -484,22 +484,22 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
assertThat(request.getAttribute("viewName")).isEqualTo("page1");
|
||||
HttpSession session = request.getSession();
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(session.getAttribute("object1") != null).isTrue();
|
||||
assertThat(session.getAttribute("object2") != null).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object1")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object2")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("testBeanList")).isTrue();
|
||||
assertThat(session.getAttribute("object1")).isNotNull();
|
||||
assertThat(session.getAttribute("object2")).isNotNull();
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object1");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("testBeanList");
|
||||
|
||||
request = new MockHttpServletRequest("POST", "/myPage");
|
||||
request.setSession(session);
|
||||
response = new MockHttpServletResponse();
|
||||
getServlet().service(request, response);
|
||||
assertThat(request.getAttribute("viewName")).isEqualTo("page2");
|
||||
assertThat(session.getAttribute("object1") != null).isTrue();
|
||||
assertThat(session.getAttribute("object2") != null).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object1")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("object2")).isTrue();
|
||||
assertThat(((Map) session.getAttribute("model")).containsKey("testBeanList")).isTrue();
|
||||
assertThat(session.getAttribute("object1")).isNotNull();
|
||||
assertThat(session.getAttribute("object2")).isNotNull();
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object1");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
|
||||
assertThat(((Map) session.getAttribute("model"))).containsKey("testBeanList");
|
||||
}
|
||||
|
||||
@PathPatternsParameterizedTest
|
||||
@@ -1946,7 +1946,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getHeader("MyResponseHeader")).isEqualTo("MyValue");
|
||||
assertThat(response.getContentLength()).isEqualTo(4);
|
||||
assertThat(response.getContentAsByteArray().length == 0).isTrue();
|
||||
assertThat(response.getContentAsByteArray().length).isEqualTo(0);
|
||||
|
||||
// Now repeat with GET
|
||||
request = new MockHttpServletRequest("GET", "/baz");
|
||||
@@ -1981,7 +1981,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getHeader("Allow")).isEqualTo("GET,HEAD,OPTIONS");
|
||||
assertThat(response.getContentAsByteArray().length == 0).isTrue();
|
||||
assertThat(response.getContentAsByteArray().length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@PathPatternsParameterizedTest
|
||||
@@ -4112,7 +4112,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
public String handle(Optional<DataClass> optionalData, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
assertThat(optionalData).isNotNull();
|
||||
assertThat(optionalData.isPresent()).isFalse();
|
||||
assertThat(optionalData).isNotPresent();
|
||||
return result.getFieldValue("param1") + "-" + result.getFieldValue("param2") + "-" +
|
||||
result.getFieldValue("param3");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -333,7 +333,7 @@ public class ServletInvocableHandlerMethodTests {
|
||||
handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer);
|
||||
|
||||
assertThat(this.response.getStatus()).isEqualTo(200);
|
||||
assertThat(this.response.getContentAsString()).isEqualTo("");
|
||||
assertThat(this.response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -344,7 +344,7 @@ public class ServletInvocableHandlerMethodTests {
|
||||
handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer);
|
||||
|
||||
assertThat(this.response.getStatus()).isEqualTo(200);
|
||||
assertThat(this.response.getContentAsString()).isEqualTo("");
|
||||
assertThat(this.response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -357,7 +357,7 @@ public class ServletInvocableHandlerMethodTests {
|
||||
handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer);
|
||||
|
||||
assertThat(this.response.getStatus()).isEqualTo(200);
|
||||
assertThat(this.response.getContentAsString()).isEqualTo("");
|
||||
assertThat(this.response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -368,7 +368,7 @@ public class ServletInvocableHandlerMethodTests {
|
||||
handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer);
|
||||
|
||||
assertThat(this.response.getStatus()).isEqualTo(200);
|
||||
assertThat(this.response.getContentAsString()).isEqualTo("");
|
||||
assertThat(this.response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -414,7 +414,7 @@ public class ServletInvocableHandlerMethodTests {
|
||||
handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer);
|
||||
|
||||
assertThat(this.response.getStatus()).isEqualTo(200);
|
||||
assertThat(this.response.getContentAsString()).isEqualTo("");
|
||||
assertThat(this.response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
private ServletInvocableHandlerMethod getHandlerMethod(Object controller,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -169,7 +169,7 @@ public class ServletModelAttributeMethodProcessorTests {
|
||||
|
||||
Optional<TestBean> testBean = (Optional<TestBean>) processor.resolveArgument(
|
||||
testBeanWithOptionalModelAttr, mavContainer, webRequest, binderFactory);
|
||||
assertThat(testBean.isPresent()).isFalse();
|
||||
assertThat(testBean).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -189,7 +189,7 @@ public class ServletModelAttributeMethodProcessorTests {
|
||||
|
||||
Optional<TestBean> testBean =(Optional<TestBean>) processor.resolveArgument(
|
||||
testBeanWithOptionalModelAttr, mavContainer, webRequest, binderFactory);
|
||||
assertThat(testBean.isPresent()).isFalse();
|
||||
assertThat(testBean).isNotPresent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -134,7 +134,7 @@ public class SseEmitterTests {
|
||||
}
|
||||
|
||||
public void assertObject(int index, Object object, MediaType mediaType) {
|
||||
assertThat(index <= this.objects.size()).isTrue();
|
||||
assertThat(index).isLessThanOrEqualTo(this.objects.size());
|
||||
assertThat(this.objects.get(index)).isEqualTo(object);
|
||||
assertThat(this.mediaTypes.get(index)).isEqualTo(mediaType);
|
||||
}
|
||||
|
||||
@@ -188,9 +188,9 @@ public class DefaultHandlerExceptionResolverTests {
|
||||
assertThat(mav).as("No ModelAndView returned").isNotNull();
|
||||
assertThat(mav.isEmpty()).as("No Empty ModelAndView returned").isTrue();
|
||||
assertThat(response.getStatus()).as("Invalid status code").isEqualTo(400);
|
||||
assertThat(response.getErrorMessage().contains("part")).isTrue();
|
||||
assertThat(response.getErrorMessage().contains("name")).isTrue();
|
||||
assertThat(response.getErrorMessage().contains("not present")).isTrue();
|
||||
assertThat(response.getErrorMessage()).contains("part");
|
||||
assertThat(response.getErrorMessage()).contains("name");
|
||||
assertThat(response.getErrorMessage()).contains("not present");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -173,7 +173,8 @@ class ResourceHttpRequestHandlerTests {
|
||||
this.handler.handleRequest(this.request, this.response);
|
||||
|
||||
assertThat(this.response.getHeader("Cache-Control")).isEqualTo("max-age=3600, must-revalidate");
|
||||
assertThat(this.response.getDateHeader("Expires") >= System.currentTimeMillis() - 1000 + (3600 * 1000)).isTrue();
|
||||
assertThat(this.response.getDateHeader("Expires")).isGreaterThanOrEqualTo(
|
||||
System.currentTimeMillis() - 1000 + (3600 * 1000));
|
||||
assertThat(this.response.containsHeader("Last-Modified")).isTrue();
|
||||
assertThat(this.response.getDateHeader("Last-Modified") / 1000).isEqualTo(resourceLastModified("test/foo.css") / 1000);
|
||||
assertThat(this.response.getHeader("Accept-Ranges")).isEqualTo("bytes");
|
||||
@@ -193,7 +194,7 @@ class ResourceHttpRequestHandlerTests {
|
||||
assertThat(this.response.getHeader("Pragma")).isEqualTo("no-cache");
|
||||
assertThat(this.response.getHeaderValues("Cache-Control")).hasSize(1);
|
||||
assertThat(this.response.getHeader("Cache-Control")).isEqualTo("no-cache");
|
||||
assertThat(this.response.getDateHeader("Expires") <= System.currentTimeMillis()).isTrue();
|
||||
assertThat(this.response.getDateHeader("Expires")).isLessThanOrEqualTo(System.currentTimeMillis());
|
||||
assertThat(this.response.containsHeader("Last-Modified")).isTrue();
|
||||
assertThat(this.response.getDateHeader("Last-Modified") / 1000).isEqualTo(resourceLastModified("test/foo.css") / 1000);
|
||||
assertThat(this.response.getHeader("Accept-Ranges")).isEqualTo("bytes");
|
||||
@@ -451,7 +452,7 @@ class ResourceHttpRequestHandlerTests {
|
||||
assertThat(this.handler.processPath((char) 1 + " / " + (char) 127 + " // foo/bar")).isEqualTo("/foo/bar");
|
||||
|
||||
// root or empty path
|
||||
assertThat(this.handler.processPath(" ")).isEqualTo("");
|
||||
assertThat(this.handler.processPath(" ")).isEmpty();
|
||||
assertThat(this.handler.processPath("/")).isEqualTo("/");
|
||||
assertThat(this.handler.processPath("///")).isEqualTo("/");
|
||||
assertThat(this.handler.processPath("/ / / ")).isEqualTo("/");
|
||||
@@ -651,7 +652,7 @@ class ResourceHttpRequestHandlerTests {
|
||||
this.handler.handleRequest(this.request, this.response);
|
||||
|
||||
assertThat(this.response.getStatus()).isEqualTo(206);
|
||||
assertThat(this.response.getContentType().startsWith("multipart/byteranges; boundary=")).isTrue();
|
||||
assertThat(this.response.getContentType()).startsWith("multipart/byteranges; boundary=");
|
||||
|
||||
String boundary = "--" + this.response.getContentType().substring(31);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -78,7 +78,7 @@ public class FlashMapManagerTests {
|
||||
FlashMap inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isEqualTo(flashMap);
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("Input FlashMap should have been removed").isEqualTo(0);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("Input FlashMap should have been removed").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +93,7 @@ public class FlashMapManagerTests {
|
||||
FlashMap inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isEqualTo(flashMap);
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("Input FlashMap should have been removed").isEqualTo(0);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("Input FlashMap should have been removed").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,19 +108,19 @@ public class FlashMapManagerTests {
|
||||
FlashMap inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isNull();
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("FlashMap should not have been removed").isEqualTo(1);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("FlashMap should not have been removed").hasSize(1);
|
||||
|
||||
this.request.setQueryString("number=two");
|
||||
inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isNull();
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("FlashMap should not have been removed").isEqualTo(1);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("FlashMap should not have been removed").hasSize(1);
|
||||
|
||||
this.request.setQueryString("number=one");
|
||||
inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isEqualTo(flashMap);
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("Input FlashMap should have been removed").isEqualTo(0);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("Input FlashMap should have been removed").isEmpty();
|
||||
}
|
||||
|
||||
@Test // SPR-8798
|
||||
@@ -136,13 +136,13 @@ public class FlashMapManagerTests {
|
||||
FlashMap inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isNull();
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("FlashMap should not have been removed").isEqualTo(1);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("FlashMap should not have been removed").hasSize(1);
|
||||
|
||||
this.request.setQueryString("id=1&id=2");
|
||||
inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isEqualTo(flashMap);
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("Input FlashMap should have been removed").isEqualTo(0);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("Input FlashMap should have been removed").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,7 +164,7 @@ public class FlashMapManagerTests {
|
||||
FlashMap inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isEqualTo(flashMapTwo);
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("Input FlashMap should have been removed").isEqualTo(2);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("Input FlashMap should have been removed").hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -178,7 +178,8 @@ public class FlashMapManagerTests {
|
||||
this.flashMapManager.setFlashMaps(flashMaps);
|
||||
this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("Expired instances should be removed even if the saved FlashMap is empty").isEqualTo(0);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("Expired instances should be removed even if the saved FlashMap is empty")
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -260,7 +261,7 @@ public class FlashMapManagerTests {
|
||||
flashMap.setTargetRequestPath("");
|
||||
this.flashMapManager.saveOutputFlashMap(flashMap, this.request, this.response);
|
||||
|
||||
assertThat(flashMap.getTargetRequestPath()).isEqualTo("");
|
||||
assertThat(flashMap.getTargetRequestPath()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // SPR-9657, SPR-11504
|
||||
@@ -328,7 +329,7 @@ public class FlashMapManagerTests {
|
||||
FlashMap inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
|
||||
|
||||
assertThatFlashMap(inputFlashMap).isEqualTo(flashMap);
|
||||
assertThat(this.flashMapManager.getFlashMaps().size()).as("Input FlashMap should have been removed").isEqualTo(0);
|
||||
assertThat(this.flashMapManager.getFlashMaps()).as("Input FlashMap should have been removed").isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -59,19 +59,19 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat(status.getExpression() == null).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isNull();
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
boolean condition = !status.isError();
|
||||
assertThat(condition).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 0).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 0).as("Correct errorMessages").isTrue();
|
||||
assertThat("".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("".equals(status.getErrorMessagesAsString(","))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").isEmpty();
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").isEmpty();
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEmpty();
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEmpty();
|
||||
assertThat(status.getErrorMessagesAsString(",")).as("Correct errorMessagesAsString").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,34 +84,34 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat(status.getExpression() == null).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isNull();
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 1).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 1).as("Correct errorMessages").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessagesAsString(","))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(1);
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(1);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message1");
|
||||
assertThat(status.getErrorMessagesAsString(",")).as("Correct errorMessagesAsString").isEqualTo("message1");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.*");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("*".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("*");
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 1).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 1).as("Correct errorMessages").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessagesAsString(","))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(1);
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(1);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message1");
|
||||
assertThat(status.getErrorMessagesAsString(",")).as("Correct errorMessagesAsString").isEqualTo("message1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,28 +124,28 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat(status.getExpression() == null).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isNull();
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 1).as("Correct errorCodes").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(1);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.*");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("*".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("*");
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 1).as("Correct errorCodes").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(1);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,30 +158,30 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat(status.getExpression() == null).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isNull();
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 1).as("Correct errorMessages").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessagesAsString(","))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(1);
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message1");
|
||||
assertThat(status.getErrorMessagesAsString(",")).as("Correct errorMessagesAsString").isEqualTo("message1");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.*");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("*".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("*");
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 1).as("Correct errorMessages").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessagesAsString(","))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(1);
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message1");
|
||||
assertThat(status.getErrorMessagesAsString(",")).as("Correct errorMessagesAsString").isEqualTo("message1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,7 +220,7 @@ class BindTagTests extends AbstractTagTests {
|
||||
tag.setPath("tb");
|
||||
tag.doStartTag();
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status.getErrorMessagesAsString(",")).as("Error messages String should be ''").isEqualTo("");
|
||||
assertThat(status.getErrorMessagesAsString(",")).as("Error messages String should be ''").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -238,59 +238,60 @@ class BindTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.name");
|
||||
tag.setHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("name".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat("name1".equals(status.getValue())).as("Correct value").isTrue();
|
||||
assertThat("name1".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("name");
|
||||
assertThat(status.getValue()).as("Correct value").isEqualTo("name1");
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEqualTo("name1");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 2).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 2).as("Correct errorMessages").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCodes()[0])).as("Correct errorCode").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCodes()[1])).as("Correct errorCode").isTrue();
|
||||
assertThat("message & 1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message & 1".equals(status.getErrorMessages()[0])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessages()[1])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message & 1 - message2".equals(status.getErrorMessagesAsString(" - "))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(2);
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(2);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[0]).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[1]).as("Correct errorCode").isEqualTo("code2");
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message & 1");
|
||||
assertThat(status.getErrorMessages()[0]).as("Correct errorMessage").isEqualTo("message & 1");
|
||||
assertThat(status.getErrorMessages()[1]).as("Correct errorMessage").isEqualTo("message2");
|
||||
assertThat(status.getErrorMessagesAsString(" - ")).as("Correct errorMessagesAsString")
|
||||
.isEqualTo("message & 1 - message2");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.age");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("age".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(Integer.valueOf(0).equals(status.getValue())).as("Correct value").isTrue();
|
||||
assertThat("0".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("age");
|
||||
assertThat(Integer.valueOf(0)).as("Correct value").isEqualTo(status.getValue());
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEqualTo("0");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 1).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 1).as("Correct errorMessages").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessagesAsString(" - "))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(1);
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(1);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code2");
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message2");
|
||||
assertThat(status.getErrorMessagesAsString(" - ")).as("Correct errorMessagesAsString").isEqualTo("message2");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.*");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("*".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("*");
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 3).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 3).as("Correct errorMessages").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCodes()[0])).as("Correct errorCode").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCodes()[1])).as("Correct errorCode").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCodes()[2])).as("Correct errorCode").isTrue();
|
||||
assertThat("message & 1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message & 1".equals(status.getErrorMessages()[0])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessages()[1])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessages()[2])).as("Correct errorMessage").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(3);
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(3);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[0]).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[1]).as("Correct errorCode").isEqualTo("code2");
|
||||
assertThat(status.getErrorCodes()[2]).as("Correct errorCode").isEqualTo("code2");
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message & 1");
|
||||
assertThat(status.getErrorMessages()[0]).as("Correct errorMessage").isEqualTo("message & 1");
|
||||
assertThat(status.getErrorMessages()[1]).as("Correct errorMessage").isEqualTo("message2");
|
||||
assertThat(status.getErrorMessages()[2]).as("Correct errorMessage").isEqualTo("message2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -308,46 +309,46 @@ class BindTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.name");
|
||||
tag.setHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("name".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat("name1".equals(status.getValue())).as("Correct value").isTrue();
|
||||
assertThat("name1".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("name");
|
||||
assertThat(status.getValue()).as("Correct value").isEqualTo("name1");
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEqualTo("name1");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 2).as("Correct errorCodes").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCodes()[0])).as("Correct errorCode").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCodes()[1])).as("Correct errorCode").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(2);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[0]).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[1]).as("Correct errorCode").isEqualTo("code2");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.age");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("age".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(Integer.valueOf(0).equals(status.getValue())).as("Correct value").isTrue();
|
||||
assertThat("0".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("age");
|
||||
assertThat(Integer.valueOf(0)).as("Correct value").isEqualTo(status.getValue());
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEqualTo("0");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 1).as("Correct errorCodes").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(1);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code2");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.*");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("*".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("*");
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 3).as("Correct errorCodes").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCodes()[0])).as("Correct errorCode").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCodes()[1])).as("Correct errorCode").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCodes()[2])).as("Correct errorCode").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(3);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[0]).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[1]).as("Correct errorCode").isEqualTo("code2");
|
||||
assertThat(status.getErrorCodes()[2]).as("Correct errorCode").isEqualTo("code2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -365,48 +366,49 @@ class BindTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.name");
|
||||
tag.setHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("name".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat("name1".equals(status.getValue())).as("Correct value").isTrue();
|
||||
assertThat("name1".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("name");
|
||||
assertThat(status.getValue()).as("Correct value").isEqualTo("name1");
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEqualTo("name1");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 2).as("Correct errorMessages").isTrue();
|
||||
assertThat("message & 1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message & 1".equals(status.getErrorMessages()[0])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessages()[1])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message & 1 - message2".equals(status.getErrorMessagesAsString(" - "))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(2);
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message & 1");
|
||||
assertThat(status.getErrorMessages()[0]).as("Correct errorMessage").isEqualTo("message & 1");
|
||||
assertThat(status.getErrorMessages()[1]).as("Correct errorMessage").isEqualTo("message2");
|
||||
assertThat(status.getErrorMessagesAsString(" - ")).as("Correct errorMessagesAsString")
|
||||
.isEqualTo("message & 1 - message2");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.age");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("age".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(Integer.valueOf(0).equals(status.getValue())).as("Correct value").isTrue();
|
||||
assertThat("0".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("age");
|
||||
assertThat(Integer.valueOf(0)).as("Correct value").isEqualTo(status.getValue());
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEqualTo("0");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 1).as("Correct errorMessages").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessagesAsString(" - "))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(1);
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message2");
|
||||
assertThat(status.getErrorMessagesAsString(" - ")).as("Correct errorMessagesAsString").isEqualTo("message2");
|
||||
|
||||
tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.*");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("*".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status.getValue() == null).as("Correct value").isTrue();
|
||||
assertThat("".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("*");
|
||||
assertThat(status.getValue()).as("Correct value").isNull();
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEmpty();
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 3).as("Correct errorMessages").isTrue();
|
||||
assertThat("message & 1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message & 1".equals(status.getErrorMessages()[0])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessages()[1])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessages()[2])).as("Correct errorMessage").isTrue();
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(3);
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message & 1");
|
||||
assertThat(status.getErrorMessages()[0]).as("Correct errorMessage").isEqualTo("message & 1");
|
||||
assertThat(status.getErrorMessages()[1]).as("Correct errorMessage").isEqualTo("message2");
|
||||
assertThat(status.getErrorMessages()[2]).as("Correct errorMessage").isEqualTo("message2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -423,18 +425,18 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.spouse.name");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("spouse.name".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat("name2".equals(status.getValue())).as("Correct value").isTrue();
|
||||
assertThat("name2".equals(status.getDisplayValue())).as("Correct displayValue").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("spouse.name");
|
||||
assertThat(status.getValue()).as("Correct value").isEqualTo("name2");
|
||||
assertThat(status.getDisplayValue()).as("Correct displayValue").isEqualTo("name2");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 1).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 1).as("Correct errorMessages").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCode())).as("Correct errorCode").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessage())).as("Correct errorMessage").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessagesAsString(" - "))).as("Correct errorMessagesAsString").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(1);
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(1);
|
||||
assertThat(status.getErrorCode()).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorMessage()).as("Correct errorMessage").isEqualTo("message1");
|
||||
assertThat(status.getErrorMessagesAsString(" - ")).as("Correct errorMessagesAsString").isEqualTo("message1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -451,14 +453,14 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.getProperty()).isNull();
|
||||
|
||||
// test property set (tb.name)
|
||||
tag.release();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.name");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.getProperty()).isEqualTo("name");
|
||||
}
|
||||
|
||||
@@ -474,20 +476,20 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.array[0]");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("array[0]".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("array[0]");
|
||||
boolean condition = status.getValue() instanceof TestBean;
|
||||
assertThat(condition).as("Value is TestBean").isTrue();
|
||||
assertThat("name0".equals(((TestBean) status.getValue()).getName())).as("Correct value").isTrue();
|
||||
assertThat(((TestBean) status.getValue()).getName()).as("Correct value").isEqualTo("name0");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 2).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 2).as("Correct errorMessages").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCodes()[0])).as("Correct errorCode").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCodes()[1])).as("Correct errorCode").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessages()[0])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessages()[1])).as("Correct errorMessage").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(2);
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(2);
|
||||
assertThat(status.getErrorCodes()[0]).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[1]).as("Correct errorCode").isEqualTo("code2");
|
||||
assertThat(status.getErrorMessages()[0]).as("Correct errorMessage").isEqualTo("message1");
|
||||
assertThat(status.getErrorMessages()[1]).as("Correct errorMessage").isEqualTo("message2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -502,20 +504,20 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.map[key1]");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("map[key1]".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("map[key1]");
|
||||
boolean condition = status.getValue() instanceof TestBean;
|
||||
assertThat(condition).as("Value is TestBean").isTrue();
|
||||
assertThat("name4".equals(((TestBean) status.getValue()).getName())).as("Correct value").isTrue();
|
||||
assertThat(((TestBean) status.getValue()).getName()).as("Correct value").isEqualTo("name4");
|
||||
assertThat(status.isError()).as("Correct isError").isTrue();
|
||||
assertThat(status.getErrorCodes().length == 2).as("Correct errorCodes").isTrue();
|
||||
assertThat(status.getErrorMessages().length == 2).as("Correct errorMessages").isTrue();
|
||||
assertThat("code1".equals(status.getErrorCodes()[0])).as("Correct errorCode").isTrue();
|
||||
assertThat("code2".equals(status.getErrorCodes()[1])).as("Correct errorCode").isTrue();
|
||||
assertThat("message1".equals(status.getErrorMessages()[0])).as("Correct errorMessage").isTrue();
|
||||
assertThat("message2".equals(status.getErrorMessages()[1])).as("Correct errorMessage").isTrue();
|
||||
assertThat(status.getErrorCodes()).as("Correct errorCodes").hasSize(2);
|
||||
assertThat(status.getErrorMessages()).as("Correct errorMessages").hasSize(2);
|
||||
assertThat(status.getErrorCodes()[0]).as("Correct errorCode").isEqualTo("code1");
|
||||
assertThat(status.getErrorCodes()[1]).as("Correct errorCode").isEqualTo("code2");
|
||||
assertThat(status.getErrorMessages()[0]).as("Correct errorMessage").isEqualTo("message1");
|
||||
assertThat(status.getErrorMessages()[1]).as("Correct errorMessage").isEqualTo("message2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -537,14 +539,14 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.array[0]");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat("array[0]".equals(status.getExpression())).as("Correct expression").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getExpression()).as("Correct expression").isEqualTo("array[0]");
|
||||
// because of the custom editor getValue() should return a String
|
||||
boolean condition = status.getValue() instanceof String;
|
||||
assertThat(condition).as("Value is TestBean").isTrue();
|
||||
assertThat("something".equals(status.getValue())).as("Correct value").isTrue();
|
||||
assertThat(status.getValue()).as("Correct value").isEqualTo("something");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -563,7 +565,7 @@ class BindTagTests extends AbstractTagTests {
|
||||
assertThat(status.getExpression()).isEqualTo("doctor");
|
||||
boolean condition = status.getValue() instanceof NestedTestBean;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(status.getDisplayValue().contains("juergen&eva")).isTrue();
|
||||
assertThat(status.getDisplayValue()).contains("juergen&eva");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -640,8 +642,8 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindErrorsTag tag = new BindErrorsTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setName("tb");
|
||||
assertThat(tag.doStartTag() == Tag.SKIP_BODY).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(pc.getAttribute(BindErrorsTag.ERRORS_VARIABLE_NAME) == null).as("Doesn't have errors variable").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.SKIP_BODY);
|
||||
assertThat(pc.getAttribute(BindErrorsTag.ERRORS_VARIABLE_NAME)).as("Doesn't have errors variable").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -653,8 +655,9 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindErrorsTag tag = new BindErrorsTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setName("tb");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(pc.getAttribute(BindErrorsTag.ERRORS_VARIABLE_NAME, PageContext.REQUEST_SCOPE) == errors).as("Has errors variable").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(pc.getAttribute(BindErrorsTag.ERRORS_VARIABLE_NAME, PageContext.REQUEST_SCOPE)).as("Has errors variable")
|
||||
.isSameAs(errors);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -663,7 +666,7 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindErrorsTag tag = new BindErrorsTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setName("tb");
|
||||
assertThat(tag.doStartTag() == Tag.SKIP_BODY).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.SKIP_BODY);
|
||||
}
|
||||
|
||||
|
||||
@@ -759,19 +762,19 @@ class BindTagTests extends AbstractTagTests {
|
||||
bindTag.setPageContext(pc);
|
||||
bindTag.setPath("name");
|
||||
|
||||
assertThat(bindTag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(bindTag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getPath()).isEqualTo("tb.name");
|
||||
assertThat(status.getDisplayValue()).as("Correct field value").isEqualTo("");
|
||||
assertThat(status.getDisplayValue()).as("Correct field value").isEmpty();
|
||||
|
||||
BindTag bindTag2 = new BindTag();
|
||||
bindTag2.setPageContext(pc);
|
||||
bindTag2.setPath("age");
|
||||
|
||||
assertThat(bindTag2.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(bindTag2.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status2 = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status2 != null).as("Has status variable").isTrue();
|
||||
assertThat(status2).as("Has status variable").isNotNull();
|
||||
assertThat(status2.getPath()).isEqualTo("tb.age");
|
||||
assertThat(status2.getDisplayValue()).as("Correct field value").isEqualTo("0");
|
||||
|
||||
@@ -780,7 +783,7 @@ class BindTagTests extends AbstractTagTests {
|
||||
BindStatus status3 = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status3).as("Status matches previous status").isSameAs(status);
|
||||
assertThat(status.getPath()).isEqualTo("tb.name");
|
||||
assertThat(status.getDisplayValue()).as("Correct field value").isEqualTo("");
|
||||
assertThat(status.getDisplayValue()).as("Correct field value").isEmpty();
|
||||
|
||||
bindTag.doEndTag();
|
||||
nestedPathTag.doEndTag();
|
||||
@@ -802,9 +805,9 @@ class BindTagTests extends AbstractTagTests {
|
||||
bindTag.setIgnoreNestedPath(true);
|
||||
bindTag.setPath("tb2.name");
|
||||
|
||||
assertThat(bindTag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(bindTag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertThat(status != null).as("Has status variable").isTrue();
|
||||
assertThat(status).as("Has status variable").isNotNull();
|
||||
assertThat(status.getPath()).isEqualTo("tb2.name");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -76,7 +76,7 @@ public class EvalTagTests extends AbstractTagTests {
|
||||
assertThat(action).isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
action = tag.doEndTag();
|
||||
assertThat(action).isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(((MockHttpServletResponse) context.getResponse()).getContentAsString()).isEqualTo("");
|
||||
assertThat(((MockHttpServletResponse) context.getResponse()).getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -54,18 +54,18 @@ class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
boolean condition6 = !testTag.isHtmlEscape();
|
||||
assertThat(condition6).as("Correctly applied").isTrue();
|
||||
tag.setDefaultHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.getRequestContext().isDefaultHtmlEscape()).as("Correctly enabled").isTrue();
|
||||
assertThat(testTag.isHtmlEscape()).as("Correctly applied").isTrue();
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
boolean condition5 = !tag.getRequestContext().isDefaultHtmlEscape();
|
||||
assertThat(condition5).as("Correctly disabled").isTrue();
|
||||
boolean condition4 = !testTag.isHtmlEscape();
|
||||
assertThat(condition4).as("Correctly applied").isTrue();
|
||||
|
||||
tag.setDefaultHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
testTag.setHtmlEscape(true);
|
||||
assertThat(tag.getRequestContext().isDefaultHtmlEscape()).as("Correctly enabled").isTrue();
|
||||
assertThat(testTag.isHtmlEscape()).as("Correctly applied").isTrue();
|
||||
@@ -74,7 +74,7 @@ class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
boolean condition3 = !testTag.isHtmlEscape();
|
||||
assertThat(condition3).as("Correctly applied").isTrue();
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
testTag.setHtmlEscape(true);
|
||||
boolean condition2 = !tag.getRequestContext().isDefaultHtmlEscape();
|
||||
assertThat(condition2).as("Correctly disabled").isTrue();
|
||||
@@ -99,10 +99,10 @@ class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
boolean condition1 = !tag.getRequestContext().isDefaultHtmlEscape();
|
||||
assertThat(condition1).as("Correct default").isTrue();
|
||||
tag.setDefaultHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.getRequestContext().isDefaultHtmlEscape()).as("Correctly enabled").isTrue();
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
boolean condition = !tag.getRequestContext().isDefaultHtmlEscape();
|
||||
assertThat(condition).as("Correctly disabled").isTrue();
|
||||
}
|
||||
@@ -119,10 +119,10 @@ class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
boolean condition1 = !tag.getRequestContext().isDefaultHtmlEscape();
|
||||
assertThat(condition1).as("Correct default").isTrue();
|
||||
tag.setDefaultHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.getRequestContext().isDefaultHtmlEscape()).as("Correctly enabled").isTrue();
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
boolean condition = !tag.getRequestContext().isDefaultHtmlEscape();
|
||||
assertThat(condition).as("Correctly disabled").isTrue();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setMessage(new DefaultMessageSourceResolvable("test"));
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test message");
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("test");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test message");
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
tag.setArguments("arg1");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test arg1 message {1}");
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
tag.setArguments("arg1,arg2");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test arg1 message arg2");
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setCode("testArgs");
|
||||
tag.setArguments("arg1,1;arg2,2");
|
||||
tag.setArgumentSeparator(";");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test arg1,1 message arg2,2");
|
||||
}
|
||||
@@ -147,7 +147,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
tag.setArguments(new Object[] {"arg1", 5});
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test arg1 message 5");
|
||||
}
|
||||
@@ -165,7 +165,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
tag.setArguments(5);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test 5 message {1}");
|
||||
}
|
||||
@@ -182,7 +182,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
tag.setArguments(5);
|
||||
tag.addArgument(7);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
@@ -201,7 +201,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
tag.addArgument(7);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test 7 message {1}");
|
||||
@@ -219,7 +219,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
tag.addArgument("arg1");
|
||||
tag.addArgument(6);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
@@ -239,7 +239,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("test");
|
||||
tag.setText("testtext");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat((message.toString())).as("Correct message").isEqualTo("test message");
|
||||
}
|
||||
@@ -257,9 +257,9 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setText("test & text é");
|
||||
tag.setHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString().startsWith("test & text &")).as("Correct message").isTrue();
|
||||
assertThat(message.toString()).as("Correct message").startsWith("test & text &");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -277,7 +277,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setText("test <&> é");
|
||||
tag.setHtmlEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("test <&> é");
|
||||
}
|
||||
@@ -295,7 +295,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setPageContext(pc);
|
||||
tag.setText("' test & text \\");
|
||||
tag.setJavaScriptEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("\\' test & text \\\\");
|
||||
}
|
||||
@@ -314,7 +314,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
tag.setText("' test & text \\");
|
||||
tag.setHtmlEscape(true);
|
||||
tag.setJavaScriptEscape(true);
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).as("Correct message").isEqualTo("' test & text \\\\");
|
||||
}
|
||||
@@ -389,7 +389,7 @@ class MessageTagTests extends AbstractTagTests {
|
||||
assertThat(rc.getMessage("test", "default")).isEqualTo("test message");
|
||||
assertThat(rc.getMessage("test", (Object[]) null, "default")).isEqualTo("test message");
|
||||
assertThat(rc.getMessage("testArgs", new String[]{"arg1", "arg2"}, "default")).isEqualTo("test arg1 message arg2");
|
||||
assertThat(rc.getMessage("testArgs", Arrays.asList(new String[]{"arg1", "arg2"}), "default")).isEqualTo("test arg1 message arg2");
|
||||
assertThat(rc.getMessage("testArgs", Arrays.asList("arg1", "arg2"), "default")).isEqualTo("test arg1 message arg2");
|
||||
assertThat(rc.getMessage("testa", "default")).isEqualTo("default");
|
||||
assertThat(rc.getMessage("testa", (List) null, "default")).isEqualTo("default");
|
||||
MessageSourceResolvable resolvable = new DefaultMessageSourceResolvable(new String[] {"test"});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -52,7 +52,7 @@ class ThemeTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("themetest");
|
||||
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
|
||||
assertThat(tag.doStartTag()).as("Correct doStartTag return value").isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
|
||||
assertThat(message.toString()).isEqualTo("theme test message");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -204,7 +204,7 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
Set<String> usedParams = new HashSet<>();
|
||||
|
||||
String queryString = tag.createQueryString(params, usedParams, true);
|
||||
assertThat(queryString).isEqualTo("");
|
||||
assertThat(queryString).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -275,7 +275,7 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
usedParams.add("name");
|
||||
|
||||
String queryString = tag.createQueryString(params, usedParams, true);
|
||||
assertThat(queryString).isEqualTo("");
|
||||
assertThat(queryString).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,7 +327,7 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
params.add(param);
|
||||
|
||||
String queryString = tag.createQueryString(params, usedParams, true);
|
||||
assertThat(queryString).isEqualTo("");
|
||||
assertThat(queryString).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -341,7 +341,7 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
params.add(param);
|
||||
|
||||
String queryString = tag.createQueryString(params, usedParams, true);
|
||||
assertThat(queryString).isEqualTo("");
|
||||
assertThat(queryString).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -124,9 +124,9 @@ public abstract class AbstractHtmlElementTagTests extends AbstractTagTests {
|
||||
|
||||
protected final void assertContainsAttribute(String output, String attributeName, String attributeValue) {
|
||||
String attributeString = attributeName + "=\"" + attributeValue + "\"";
|
||||
assertThat(output.contains(attributeString)).as("Expected to find attribute '" + attributeName +
|
||||
assertThat(output).as("Expected to find attribute '" + attributeName +
|
||||
"' with value '" + attributeValue +
|
||||
"' in output + '" + output + "'").isTrue();
|
||||
"' in output + '" + output + "'").contains(attributeString);
|
||||
}
|
||||
|
||||
protected final void assertAttributeNotPresent(String output, String attributeName) {
|
||||
@@ -136,7 +136,8 @@ public abstract class AbstractHtmlElementTagTests extends AbstractTagTests {
|
||||
|
||||
protected final void assertBlockTagContains(String output, String desiredContents) {
|
||||
String contents = output.substring(output.indexOf(">") + 1, output.lastIndexOf('<'));
|
||||
assertThat(contents.contains(desiredContents)).as("Expected to find '" + desiredContents + "' in the contents of block tag '" + output + "'").isTrue();
|
||||
assertThat(contents).as("Expected to find '" + desiredContents + "' in the contents of block tag '" + output + "'")
|
||||
.contains(desiredContents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -78,11 +78,11 @@ public class ButtonTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
protected final void assertTagClosed(String output) {
|
||||
assertThat(output.endsWith("</button>")).as("Tag not closed properly").isTrue();
|
||||
assertThat(output).as("Tag not closed properly").endsWith("</button>");
|
||||
}
|
||||
|
||||
protected final void assertTagOpened(String output) {
|
||||
assertThat(output.startsWith("<button ")).as("Tag not opened properly").isTrue();
|
||||
assertThat(output).as("Tag not opened properly").startsWith("<button ");
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -79,7 +79,7 @@ class CheckboxTagTests extends AbstractFormTagTests {
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new StringReader(output));
|
||||
Element rootElement = document.getRootElement();
|
||||
assertThat(rootElement.elements().size()).as("Both tag and hidden element not rendered").isEqualTo(2);
|
||||
assertThat(rootElement.elements()).as("Both tag and hidden element not rendered").hasSize(2);
|
||||
Element checkboxElement = rootElement.elements().get(0);
|
||||
assertThat(checkboxElement.getName()).isEqualTo("input");
|
||||
assertThat(checkboxElement.attribute("type").getValue()).isEqualTo("checkbox");
|
||||
@@ -102,7 +102,7 @@ class CheckboxTagTests extends AbstractFormTagTests {
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new StringReader(output));
|
||||
Element rootElement = document.getRootElement();
|
||||
assertThat(rootElement.elements().size()).as("Both tag and hidden element not rendered").isEqualTo(2);
|
||||
assertThat(rootElement.elements()).as("Both tag and hidden element not rendered").hasSize(2);
|
||||
Element checkboxElement = rootElement.elements().get(0);
|
||||
assertThat(checkboxElement.getName()).isEqualTo("input");
|
||||
assertThat(checkboxElement.attribute("type").getValue()).isEqualTo("checkbox");
|
||||
@@ -131,7 +131,7 @@ class CheckboxTagTests extends AbstractFormTagTests {
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new StringReader(output));
|
||||
Element rootElement = document.getRootElement();
|
||||
assertThat(rootElement.elements().size()).as("Both tag and hidden element not rendered").isEqualTo(2);
|
||||
assertThat(rootElement.elements()).as("Both tag and hidden element not rendered").hasSize(2);
|
||||
Element checkboxElement = rootElement.elements().get(0);
|
||||
assertThat(checkboxElement.getName()).isEqualTo("input");
|
||||
assertThat(checkboxElement.attribute("type").getValue()).isEqualTo("checkbox");
|
||||
@@ -631,7 +631,7 @@ class CheckboxTagTests extends AbstractFormTagTests {
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new StringReader(output));
|
||||
Element rootElement = document.getRootElement();
|
||||
assertThat(rootElement.elements().size()).as("Both tag and hidden element rendered incorrectly").isEqualTo(1);
|
||||
assertThat(rootElement.elements()).as("Both tag and hidden element rendered incorrectly").hasSize(1);
|
||||
Element checkboxElement = rootElement.elements().get(0);
|
||||
assertThat(checkboxElement.getName()).isEqualTo("input");
|
||||
assertThat(checkboxElement.attribute("type").getValue()).isEqualTo("checkbox");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -694,7 +694,7 @@ public class CheckboxesTagTests extends AbstractFormTagTests {
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new StringReader(output));
|
||||
Element rootElement = document.getRootElement();
|
||||
assertThat(rootElement.elements().size()).as("Both tag and hidden element rendered incorrectly").isEqualTo(3);
|
||||
assertThat(rootElement.elements()).as("Both tag and hidden element rendered incorrectly").hasSize(3);
|
||||
Element spanElement = document.getRootElement().elements().get(0);
|
||||
Element checkboxElement = spanElement.elements().get(0);
|
||||
assertThat(checkboxElement.getName()).isEqualTo("input");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -303,7 +303,7 @@ public class ErrorsTagTests extends AbstractFormTagTests {
|
||||
assertThat(result).isEqualTo(Tag.EVAL_PAGE);
|
||||
|
||||
String output = getOutput();
|
||||
assertThat(output.length()).isEqualTo(0);
|
||||
assertThat(output).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -315,7 +315,7 @@ public class ErrorsTagTests extends AbstractFormTagTests {
|
||||
assertThat(result).isEqualTo(Tag.EVAL_PAGE);
|
||||
|
||||
String output = getOutput();
|
||||
assertThat(output.length()).isEqualTo(0);
|
||||
assertThat(output).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -426,9 +426,9 @@ public class ErrorsTagTests extends AbstractFormTagTests {
|
||||
assertThat(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE)).isNotNull();
|
||||
this.tag.doEndTag();
|
||||
String output = getOutput();
|
||||
assertThat(output.contains("id=\"testBean.errors\"")).isTrue();
|
||||
assertThat(output.contains("object error")).isTrue();
|
||||
assertThat(output.contains("field error")).isFalse();
|
||||
assertThat(output).contains("id=\"testBean.errors\"");
|
||||
assertThat(output).contains("object error");
|
||||
assertThat(output).doesNotContain("field error");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -442,9 +442,9 @@ public class ErrorsTagTests extends AbstractFormTagTests {
|
||||
assertThat(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE)).isNotNull();
|
||||
this.tag.doEndTag();
|
||||
String output = getOutput();
|
||||
assertThat(output.contains("id=\"name.errors\"")).isTrue();
|
||||
assertThat(output.contains("object error")).isFalse();
|
||||
assertThat(output.contains("field error")).isTrue();
|
||||
assertThat(output).contains("id=\"name.errors\"");
|
||||
assertThat(output).doesNotContain("object error");
|
||||
assertThat(output).contains("field error");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -458,9 +458,9 @@ public class ErrorsTagTests extends AbstractFormTagTests {
|
||||
assertThat(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE)).isNotNull();
|
||||
this.tag.doEndTag();
|
||||
String output = getOutput();
|
||||
assertThat(output.contains("id=\"testBean.errors\"")).isTrue();
|
||||
assertThat(output.contains("object error")).isTrue();
|
||||
assertThat(output.contains("field error")).isTrue();
|
||||
assertThat(output).contains("id=\"testBean.errors\"");
|
||||
assertThat(output).contains("object error");
|
||||
assertThat(output).contains("field error");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -476,11 +476,11 @@ public class ErrorsTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
private void assertElementTagOpened(String output) {
|
||||
assertThat(output.startsWith("<" + this.tag.getElement() + " ")).isTrue();
|
||||
assertThat(output).startsWith("<" + this.tag.getElement() + " ");
|
||||
}
|
||||
|
||||
private void assertElementTagClosed(String output) {
|
||||
assertThat(output.endsWith("</" + this.tag.getElement() + ">")).isTrue();
|
||||
assertThat(output).endsWith("</" + this.tag.getElement() + ">");
|
||||
}
|
||||
|
||||
private void assertWhenNoErrorsExistingMessagesInScopeAreNotClobbered(int scope) throws JspException {
|
||||
@@ -496,7 +496,7 @@ public class ErrorsTagTests extends AbstractFormTagTests {
|
||||
assertThat(result).isEqualTo(Tag.EVAL_PAGE);
|
||||
|
||||
String output = getOutput();
|
||||
assertThat(output.length()).isEqualTo(0);
|
||||
assertThat(output).isEmpty();
|
||||
|
||||
assertThat(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE, scope)).isEqualTo(existingAttribute);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -240,7 +240,7 @@ public class FormTagTests extends AbstractHtmlElementTagTests {
|
||||
String inputOutput = getInputTag(output);
|
||||
|
||||
assertContainsAttribute(formOutput, "method", "get");
|
||||
assertThat(inputOutput).isEqualTo("");
|
||||
assertThat(inputOutput).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,7 +256,7 @@ public class FormTagTests extends AbstractHtmlElementTagTests {
|
||||
String inputOutput = getInputTag(output);
|
||||
|
||||
assertContainsAttribute(formOutput, "method", "post");
|
||||
assertThat(inputOutput).isEqualTo("");
|
||||
assertThat(inputOutput).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -373,11 +373,11 @@ public class FormTagTests extends AbstractHtmlElementTagTests {
|
||||
|
||||
|
||||
private static void assertFormTagOpened(String output) {
|
||||
assertThat(output.startsWith("<form ")).isTrue();
|
||||
assertThat(output).startsWith("<form ");
|
||||
}
|
||||
|
||||
private static void assertFormTagClosed(String output) {
|
||||
assertThat(output.endsWith("</form>")).isTrue();
|
||||
assertThat(output).endsWith("</form>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -120,11 +120,11 @@ class HiddenInputTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
private void assertTagClosed(String output) {
|
||||
assertThat(output.endsWith("/>")).isTrue();
|
||||
assertThat(output).endsWith("/>");
|
||||
}
|
||||
|
||||
private void assertTagOpened(String output) {
|
||||
assertThat(output.startsWith("<input ")).isTrue();
|
||||
assertThat(output).startsWith("<input ");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -372,11 +372,11 @@ public class InputTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
protected final void assertTagClosed(String output) {
|
||||
assertThat(output.endsWith("/>")).as("Tag not closed properly").isTrue();
|
||||
assertThat(output).as("Tag not closed properly").endsWith("/>");
|
||||
}
|
||||
|
||||
protected final void assertTagOpened(String output) {
|
||||
assertThat(output.startsWith("<input ")).as("Tag not opened properly").isTrue();
|
||||
assertThat(output).as("Tag not opened properly").startsWith("<input ");
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -76,8 +76,8 @@ public class LabelTagTests extends AbstractFormTagTests {
|
||||
assertAttributeNotPresent(output, "name");
|
||||
// id attribute is supported, but we don't want it
|
||||
assertAttributeNotPresent(output, "id");
|
||||
assertThat(output.startsWith("<label ")).isTrue();
|
||||
assertThat(output.endsWith("</label>")).isTrue();
|
||||
assertThat(output).startsWith("<label ");
|
||||
assertThat(output).endsWith("</label>");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,8 +104,8 @@ public class LabelTagTests extends AbstractFormTagTests {
|
||||
assertAttributeNotPresent(output, "name");
|
||||
// id attribute is supported, but we don't want it
|
||||
assertAttributeNotPresent(output, "id");
|
||||
assertThat(output.startsWith("<label ")).isTrue();
|
||||
assertThat(output.endsWith("</label>")).isTrue();
|
||||
assertThat(output).startsWith("<label ");
|
||||
assertThat(output).endsWith("</label>");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,8 +124,8 @@ public class LabelTagTests extends AbstractFormTagTests {
|
||||
assertAttributeNotPresent(output, "name");
|
||||
// id attribute is supported, but we don't want it
|
||||
assertAttributeNotPresent(output, "id");
|
||||
assertThat(output.startsWith("<label ")).isTrue();
|
||||
assertThat(output.endsWith("</label>")).isTrue();
|
||||
assertThat(output).startsWith("<label ");
|
||||
assertThat(output).endsWith("</label>");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,8 +144,8 @@ public class LabelTagTests extends AbstractFormTagTests {
|
||||
assertAttributeNotPresent(output, "name");
|
||||
// id attribute is supported, but we don't want it
|
||||
assertAttributeNotPresent(output, "id");
|
||||
assertThat(output.startsWith("<label ")).isTrue();
|
||||
assertThat(output.endsWith("</label>")).isTrue();
|
||||
assertThat(output).startsWith("<label ");
|
||||
assertThat(output).endsWith("</label>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -82,11 +82,11 @@ public class OptionTagEnumTests extends AbstractHtmlElementTagTests {
|
||||
}
|
||||
|
||||
private void assertOptionTagOpened(String output) {
|
||||
assertThat(output.startsWith("<option")).isTrue();
|
||||
assertThat(output).startsWith("<option");
|
||||
}
|
||||
|
||||
private void assertOptionTagClosed(String output) {
|
||||
assertThat(output.endsWith("</option>")).isTrue();
|
||||
assertThat(output).endsWith("</option>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -472,11 +472,11 @@ class OptionTagTests extends AbstractHtmlElementTagTests {
|
||||
|
||||
|
||||
private void assertOptionTagOpened(String output) {
|
||||
assertThat(output.startsWith("<option")).isTrue();
|
||||
assertThat(output).startsWith("<option");
|
||||
}
|
||||
|
||||
private void assertOptionTagClosed(String output) {
|
||||
assertThat(output.endsWith("</option>")).isTrue();
|
||||
assertThat(output).endsWith("</option>");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -251,11 +251,11 @@ class RadioButtonTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
private void assertTagOpened(String output) {
|
||||
assertThat(output.contains("<input ")).isTrue();
|
||||
assertThat(output).contains("<input ");
|
||||
}
|
||||
|
||||
private void assertTagClosed(String output) {
|
||||
assertThat(output.contains("/>")).isTrue();
|
||||
assertThat(output).contains("/>");
|
||||
}
|
||||
|
||||
private Float getFloat() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -230,9 +230,9 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
|
||||
this.tag.doStartTag();
|
||||
String output = getOutput();
|
||||
assertThat(output.startsWith("<select ")).isTrue();
|
||||
assertThat(output.endsWith("</select>")).isTrue();
|
||||
assertThat(output.contains("option value=\"AT\" selected=\"selected\">Austria")).isTrue();
|
||||
assertThat(output).startsWith("<select ");
|
||||
assertThat(output).endsWith("</select>");
|
||||
assertThat(output).contains("option value=\"AT\" selected=\"selected\">Austria");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -268,10 +268,10 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
|
||||
this.tag.doStartTag();
|
||||
String output = getOutput();
|
||||
assertThat(output.startsWith("<select ")).isTrue();
|
||||
assertThat(output.endsWith("</select>")).isTrue();
|
||||
assertThat(output.contains("selected=\"selected\"")).isFalse();
|
||||
assertThat(output.contains("multiple=\"multiple\"")).isFalse();
|
||||
assertThat(output).startsWith("<select ");
|
||||
assertThat(output).endsWith("</select>");
|
||||
assertThat(output).doesNotContain("selected=\"selected\"");
|
||||
assertThat(output).doesNotContain("multiple=\"multiple\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -296,9 +296,9 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
|
||||
this.tag.doStartTag();
|
||||
String output = getOutput();
|
||||
assertThat(output.startsWith("<select ")).isTrue();
|
||||
assertThat(output.endsWith("</select>")).isTrue();
|
||||
assertThat(output.contains("option value=\"AT\" selected=\"selected\">Austria")).isTrue();
|
||||
assertThat(output).startsWith("<select ");
|
||||
assertThat(output).endsWith("</select>");
|
||||
assertThat(output).contains("option value=\"AT\" selected=\"selected\">Austria");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,9 +327,9 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
|
||||
this.tag.doStartTag();
|
||||
String output = getOutput();
|
||||
assertThat(output.startsWith("<select ")).isTrue();
|
||||
assertThat(output.endsWith("</select>")).isTrue();
|
||||
assertThat(output.contains("selected=\"selected\"")).isFalse();
|
||||
assertThat(output).startsWith("<select ");
|
||||
assertThat(output).endsWith("</select>");
|
||||
assertThat(output).doesNotContain("selected=\"selected\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -365,8 +365,8 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
this.tag.doFinally();
|
||||
|
||||
String output = getOutput();
|
||||
assertThat(output.startsWith("<select ")).isTrue();
|
||||
assertThat(output.endsWith("</select>")).isTrue();
|
||||
assertThat(output).startsWith("<select ");
|
||||
assertThat(output).endsWith("</select>");
|
||||
assertContainsAttribute(output, "name", "country");
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("name").getValue()).isEqualTo("someIntegerArray");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(array.length);
|
||||
assertThat(children).as("Incorrect number of children").hasSameSizeAs(array);
|
||||
|
||||
Element e = (Element) selectElement.selectSingleNode("option[text() = '12']");
|
||||
assertThat(e.attribute("selected").getValue()).as("'12' node not selected").isEqualTo("selected");
|
||||
@@ -437,8 +437,8 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(result).isEqualTo(Tag.SKIP_BODY);
|
||||
|
||||
String output = getOutput();
|
||||
assertThat(output.startsWith("<select ")).isTrue();
|
||||
assertThat(output.endsWith("</select>")).isTrue();
|
||||
assertThat(output).startsWith("<select ");
|
||||
assertThat(output).endsWith("</select>");
|
||||
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new StringReader(output));
|
||||
@@ -446,7 +446,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(rootElement.getName()).isEqualTo("select");
|
||||
assertThat(rootElement.attribute("name").getValue()).isEqualTo("myFloat");
|
||||
List children = rootElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(array.length);
|
||||
assertThat(children).as("Incorrect number of children").hasSameSizeAs(array);
|
||||
|
||||
Element e = (Element) rootElement.selectSingleNode("option[text() = '12.34f']");
|
||||
assertThat(e.attribute("selected").getValue()).as("'12.34' node not selected").isEqualTo("selected");
|
||||
@@ -481,7 +481,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("name").getValue()).isEqualTo("someList");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element e = (Element) selectElement.selectSingleNode("option[@value = 'UK']");
|
||||
assertThat(e.attribute("selected").getValue()).as("UK node not selected").isEqualTo("selected");
|
||||
@@ -530,7 +530,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("name").getValue()).isEqualTo("realCountry");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element e = (Element) selectElement.selectSingleNode("option[@value = 'UK']");
|
||||
assertThat(e.attribute("selected").getValue()).as("UK node not selected").isEqualTo("selected");
|
||||
@@ -578,7 +578,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("name").getValue()).isEqualTo("someList");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element e = (Element) selectElement.selectSingleNode("option[@value = 'UK']");
|
||||
assertThat(e.attribute("selected").getValue()).as("UK node not selected").isEqualTo("selected");
|
||||
@@ -624,7 +624,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("name").getValue()).isEqualTo("someList");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element e = (Element) selectElement.selectSingleNode("option[@value = 'UK']");
|
||||
assertThat(e.attribute("selected").getValue()).as("UK node not selected").isEqualTo("selected");
|
||||
@@ -659,7 +659,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("name").getValue()).isEqualTo("someMap");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(2);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(2);
|
||||
|
||||
Element e = (Element) selectElement.selectSingleNode("option[@value = 'M']");
|
||||
assertThat(e.attribute("selected").getValue()).as("M node not selected").isEqualTo("selected");
|
||||
@@ -735,7 +735,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("name").getValue()).isEqualTo("someMap");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(3);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(3);
|
||||
|
||||
Element e;
|
||||
e = (Element) selectElement.selectSingleNode("option[@value = '" + austria.getIsoCode() + "']");
|
||||
@@ -779,7 +779,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("multiple").getValue()).isEqualTo("multiple");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element inputElement = rootElement.element("input");
|
||||
assertThat(inputElement).isNotNull();
|
||||
@@ -808,7 +808,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("multiple").getValue()).isEqualTo("multiple");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element inputElement = rootElement.element("input");
|
||||
assertThat(inputElement).isNotNull();
|
||||
@@ -837,7 +837,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("multiple").getValue()).isEqualTo("multiple");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element inputElement = rootElement.element("input");
|
||||
assertThat(inputElement).isNotNull();
|
||||
@@ -866,7 +866,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("multiple")).isNull();
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -892,7 +892,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("multiple").getValue()).isEqualTo("multiple");
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element inputElement = rootElement.element("input");
|
||||
assertThat(inputElement).isNotNull();
|
||||
@@ -921,7 +921,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(selectElement.attribute("multiple")).isNull();
|
||||
|
||||
List children = selectElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
}
|
||||
|
||||
|
||||
@@ -930,8 +930,8 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(result).isEqualTo(Tag.SKIP_BODY);
|
||||
|
||||
String output = getOutput();
|
||||
assertThat(output.startsWith("<select ")).isTrue();
|
||||
assertThat(output.endsWith("</select>")).isTrue();
|
||||
assertThat(output).startsWith("<select ");
|
||||
assertThat(output).endsWith("</select>");
|
||||
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new StringReader(output));
|
||||
@@ -940,7 +940,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(rootElement.attribute("name").getValue()).isEqualTo("name");
|
||||
|
||||
List children = rootElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element e = (Element) rootElement.selectSingleNode("option[text() = 'Rob']");
|
||||
assertThat(e.attribute("selected").getValue()).as("Rob node not selected").isEqualTo("selected");
|
||||
@@ -985,7 +985,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
assertThat(rootElement.attribute("name").getValue()).isEqualTo("country");
|
||||
|
||||
List children = rootElement.elements();
|
||||
assertThat(children.size()).as("Incorrect number of children").isEqualTo(4);
|
||||
assertThat(children).as("Incorrect number of children").hasSize(4);
|
||||
|
||||
Element e = (Element) rootElement.selectSingleNode("option[@value = 'UK']");
|
||||
Attribute selectedAttr = e.attribute("selected");
|
||||
|
||||
@@ -218,7 +218,7 @@ public class BaseViewTests {
|
||||
public void attributeCSVParsingValid() {
|
||||
AbstractView v = new ConcreteView();
|
||||
v.setAttributesCSV("foo=[bar],king=[kong]");
|
||||
assertThat(v.getStaticAttributes().size() == 2).isTrue();
|
||||
assertThat(v.getStaticAttributes()).hasSize(2);
|
||||
assertThat(v.getStaticAttributes().get("foo").equals("bar")).isTrue();
|
||||
assertThat(v.getStaticAttributes().get("king").equals("kong")).isTrue();
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public class BaseViewTests {
|
||||
// Also tests empty value
|
||||
String kingval = "";
|
||||
v.setAttributesCSV("foo=(" + fooval + "),king={" + kingval + "},f1=[we]");
|
||||
assertThat(v.getStaticAttributes().size() == 3).isTrue();
|
||||
assertThat(v.getStaticAttributes()).hasSize(3);
|
||||
assertThat(v.getStaticAttributes().get("foo").equals(fooval)).isTrue();
|
||||
assertThat(v.getStaticAttributes().get("king").equals(kingval)).isTrue();
|
||||
}
|
||||
@@ -319,7 +319,7 @@ public class BaseViewTests {
|
||||
throw new RuntimeException("Already initialized");
|
||||
}
|
||||
this.initialized = true;
|
||||
assertThat(getApplicationContext() == wac).isTrue();
|
||||
assertThat(getApplicationContext()).isSameAs(wac);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -253,7 +253,7 @@ public class ViewResolverTests {
|
||||
view.render(model, this.request, this.response);
|
||||
|
||||
assertThat(tb.equals(this.request.getAttribute("tb"))).as("Correct tb attribute").isTrue();
|
||||
assertThat(this.request.getAttribute("rc") == null).as("Correct rc attribute").isTrue();
|
||||
assertThat(this.request.getAttribute("rc")).as("Correct rc attribute").isNull();
|
||||
assertThat(this.request.getAttribute("key1")).isEqualTo("value1");
|
||||
assertThat(this.request.getAttribute("key2")).isEqualTo(2);
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public class ViewResolverTests {
|
||||
return new MockRequestDispatcher(path) {
|
||||
@Override
|
||||
public void forward(ServletRequest forwardRequest, ServletResponse forwardResponse) {
|
||||
assertThat(forwardRequest.getAttribute("rc") == null).as("Correct rc attribute").isTrue();
|
||||
assertThat(forwardRequest.getAttribute("rc")).as("Correct rc attribute").isNull();
|
||||
assertThat(forwardRequest.getAttribute("key1")).isEqualTo("value1");
|
||||
assertThat(forwardRequest.getAttribute("key2")).isEqualTo(2);
|
||||
assertThat(forwardRequest.getAttribute("myBean")).isSameAs(wac.getBean("myBean"));
|
||||
@@ -315,7 +315,7 @@ public class ViewResolverTests {
|
||||
return new MockRequestDispatcher(path) {
|
||||
@Override
|
||||
public void forward(ServletRequest forwardRequest, ServletResponse forwardResponse) {
|
||||
assertThat(forwardRequest.getAttribute("rc") == null).as("Correct rc attribute").isTrue();
|
||||
assertThat(forwardRequest.getAttribute("rc")).as("Correct rc attribute").isNull();
|
||||
assertThat(forwardRequest.getAttribute("key1")).isEqualTo("value1");
|
||||
assertThat(forwardRequest.getAttribute("key2")).isEqualTo(2);
|
||||
assertThat(forwardRequest.getAttribute("myBean")).isNull();
|
||||
@@ -356,7 +356,7 @@ public class ViewResolverTests {
|
||||
view.render(model, this.request, this.response);
|
||||
|
||||
assertThat(tb.equals(this.request.getAttribute("tb"))).as("Correct tb attribute").isTrue();
|
||||
assertThat(this.request.getAttribute("rc") == null).as("Correct rc attribute").isTrue();
|
||||
assertThat(this.request.getAttribute("rc")).as("Correct rc attribute").isNull();
|
||||
|
||||
assertThat(Config.get(this.request, Config.FMT_LOCALE)).isEqualTo(locale);
|
||||
LocalizationContext lc = (LocalizationContext) Config.get(this.request, Config.FMT_LOCALIZATION_CONTEXT);
|
||||
@@ -390,7 +390,7 @@ public class ViewResolverTests {
|
||||
view.render(model, this.request, this.response);
|
||||
|
||||
assertThat(tb.equals(this.request.getAttribute("tb"))).as("Correct tb attribute").isTrue();
|
||||
assertThat(this.request.getAttribute("rc") == null).as("Correct rc attribute").isTrue();
|
||||
assertThat(this.request.getAttribute("rc")).as("Correct rc attribute").isNull();
|
||||
|
||||
assertThat(Config.get(this.request, Config.FMT_LOCALE)).isEqualTo(locale);
|
||||
LocalizationContext lc = (LocalizationContext) Config.get(this.request, Config.FMT_LOCALIZATION_CONTEXT);
|
||||
@@ -410,11 +410,11 @@ public class ViewResolverTests {
|
||||
|
||||
View view1 = vr.resolveViewName("example1", Locale.getDefault());
|
||||
assertThat(TestView.class.equals(view1.getClass())).as("Correct view class").isTrue();
|
||||
assertThat("/example1.jsp".equals(((InternalResourceView) view1).getUrl())).as("Correct URL").isTrue();
|
||||
assertThat(((InternalResourceView) view1).getUrl()).as("Correct URL").isEqualTo("/example1.jsp");
|
||||
|
||||
View view2 = vr.resolveViewName("example2", Locale.getDefault());
|
||||
assertThat(JstlView.class.equals(view2.getClass())).as("Correct view class").isTrue();
|
||||
assertThat("/example2new.jsp".equals(((InternalResourceView) view2).getUrl())).as("Correct URL").isTrue();
|
||||
assertThat(((InternalResourceView) view2).getUrl()).as("Correct URL").isEqualTo("/example2new.jsp");
|
||||
|
||||
Map<String, Object> model = new HashMap<>();
|
||||
TestBean tb = new TestBean();
|
||||
@@ -425,7 +425,7 @@ public class ViewResolverTests {
|
||||
this.request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
|
||||
view1.render(model, this.request, this.response);
|
||||
assertThat(tb.equals(this.request.getAttribute("tb"))).as("Correct tb attribute").isTrue();
|
||||
assertThat("testvalue1".equals(this.request.getAttribute("test1"))).as("Correct test1 attribute").isTrue();
|
||||
assertThat(this.request.getAttribute("test1")).as("Correct test1 attribute").isEqualTo("testvalue1");
|
||||
assertThat(testBean.equals(this.request.getAttribute("test2"))).as("Correct test2 attribute").isTrue();
|
||||
|
||||
this.request.clearAttributes();
|
||||
@@ -434,8 +434,8 @@ public class ViewResolverTests {
|
||||
this.request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
|
||||
view2.render(model, this.request, this.response);
|
||||
assertThat(tb.equals(this.request.getAttribute("tb"))).as("Correct tb attribute").isTrue();
|
||||
assertThat("testvalue1".equals(this.request.getAttribute("test1"))).as("Correct test1 attribute").isTrue();
|
||||
assertThat("testvalue2".equals(this.request.getAttribute("test2"))).as("Correct test2 attribute").isTrue();
|
||||
assertThat(this.request.getAttribute("test1")).as("Correct test1 attribute").isEqualTo("testvalue1");
|
||||
assertThat(this.request.getAttribute("test2")).as("Correct test2 attribute").isEqualTo("testvalue2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -444,7 +444,7 @@ public class ViewResolverTests {
|
||||
StaticWebApplicationContext wac = new StaticWebApplicationContext() {
|
||||
@Override
|
||||
protected Resource getResourceByPath(String path) {
|
||||
assertThat(org.springframework.web.servlet.view.XmlViewResolver.DEFAULT_LOCATION.equals(path)).as("Correct default location").isTrue();
|
||||
assertThat(path).as("Correct default location").isEqualTo(XmlViewResolver.DEFAULT_LOCATION);
|
||||
return super.getResourceByPath(path);
|
||||
}
|
||||
};
|
||||
@@ -461,7 +461,7 @@ public class ViewResolverTests {
|
||||
StaticWebApplicationContext wac = new StaticWebApplicationContext() {
|
||||
@Override
|
||||
protected Resource getResourceByPath(String path) {
|
||||
assertThat(org.springframework.web.servlet.view.XmlViewResolver.DEFAULT_LOCATION.equals(path)).as("Correct default location").isTrue();
|
||||
assertThat(path).as("Correct default location").isEqualTo(XmlViewResolver.DEFAULT_LOCATION);
|
||||
return super.getResourceByPath(path);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -249,17 +249,19 @@ public class FreeMarkerMacroTests {
|
||||
@Test
|
||||
public void testForm15() throws Exception {
|
||||
String output = getMacroOutput("FORM15");
|
||||
assertThat(output.startsWith("<input type=\"hidden\" name=\"_name\" value=\"on\"/>")).as("Wrong output: " + output).isTrue();
|
||||
assertThat(output.contains("<input type=\"checkbox\" id=\"name\" name=\"name\" />")).as("Wrong output: " + output).isTrue();
|
||||
assertThat(output).as("Wrong output: " + output)
|
||||
.startsWith("<input type=\"hidden\" name=\"_name\" value=\"on\"/>");
|
||||
assertThat(output).as("Wrong output: " + output)
|
||||
.contains("<input type=\"checkbox\" id=\"name\" name=\"name\" />");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForm16() throws Exception {
|
||||
String output = getMacroOutput("FORM16");
|
||||
assertThat(output.startsWith(
|
||||
"<input type=\"hidden\" name=\"_jedi\" value=\"on\"/>")).as("Wrong output: " + output).isTrue();
|
||||
assertThat(output.contains(
|
||||
"<input type=\"checkbox\" id=\"jedi\" name=\"jedi\" checked=\"checked\" />")).as("Wrong output: " + output).isTrue();
|
||||
assertThat(output).as("Wrong output: " + output)
|
||||
.startsWith("<input type=\"hidden\" name=\"_jedi\" value=\"on\"/>");
|
||||
assertThat(output).as("Wrong output: " + output)
|
||||
.contains("<input type=\"checkbox\" id=\"jedi\" name=\"jedi\" checked=\"checked\" />");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -270,10 +272,10 @@ public class FreeMarkerMacroTests {
|
||||
@Test
|
||||
public void testForm18() throws Exception {
|
||||
String output = getMacroOutput("FORM18");
|
||||
assertThat(output.startsWith(
|
||||
"<input type=\"hidden\" name=\"_spouses[0].jedi\" value=\"on\"/>")).as("Wrong output: " + output).isTrue();
|
||||
assertThat(output.contains(
|
||||
"<input type=\"checkbox\" id=\"spouses0.jedi\" name=\"spouses[0].jedi\" checked=\"checked\" />")).as("Wrong output: " + output).isTrue();
|
||||
assertThat(output).as("Wrong output: " + output)
|
||||
.startsWith("<input type=\"hidden\" name=\"_spouses[0].jedi\" value=\"on\"/>");
|
||||
assertThat(output).as("Wrong output: " + output)
|
||||
.contains("<input type=\"checkbox\" id=\"spouses0.jedi\" name=\"spouses[0].jedi\" checked=\"checked\" />");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -94,7 +94,7 @@ public class MappingJackson2JsonViewTests {
|
||||
assertThat(mediaType.isCompatibleWith(MediaType.parseMediaType(MappingJackson2JsonView.DEFAULT_CONTENT_TYPE))).isTrue();
|
||||
|
||||
String jsonResult = response.getContentAsString();
|
||||
assertThat(jsonResult.length() > 0).isTrue();
|
||||
assertThat(jsonResult).isNotEmpty();
|
||||
assertThat(response.getContentLength()).isEqualTo(jsonResult.length());
|
||||
|
||||
validateResult();
|
||||
@@ -145,7 +145,7 @@ public class MappingJackson2JsonViewTests {
|
||||
view.setUpdateContentLength(true);
|
||||
view.render(model, request, response);
|
||||
|
||||
assertThat(response.getContentAsString().length() > 0).isTrue();
|
||||
assertThat(response.getContentAsString()).isNotEmpty();
|
||||
assertThat(response.getContentLength()).isEqualTo(response.getContentAsString().length());
|
||||
|
||||
validateResult();
|
||||
@@ -159,7 +159,7 @@ public class MappingJackson2JsonViewTests {
|
||||
view.render(model, request, response);
|
||||
|
||||
String result = response.getContentAsString().replace("\r\n", "\n");
|
||||
assertThat(result.startsWith("{\n \"foo\" : {\n ")).as("Pretty printing not applied:\n" + result).isTrue();
|
||||
assertThat(result).as("Pretty printing not applied:\n" + result).startsWith("{\n \"foo\" : {\n ");
|
||||
|
||||
validateResult();
|
||||
}
|
||||
@@ -168,14 +168,14 @@ public class MappingJackson2JsonViewTests {
|
||||
public void renderSimpleBeanPrefixed() throws Exception {
|
||||
view.setPrefixJson(true);
|
||||
renderSimpleBean();
|
||||
assertThat(response.getContentAsString().startsWith(")]}', ")).isTrue();
|
||||
assertThat(response.getContentAsString()).startsWith(")]}', ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renderSimpleBeanNotPrefixed() throws Exception {
|
||||
view.setPrefixJson(false);
|
||||
renderSimpleBean();
|
||||
assertThat(response.getContentAsString().startsWith(")]}', ")).isFalse();
|
||||
assertThat(response.getContentAsString()).doesNotStartWith(")]}', ");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -186,7 +186,7 @@ public class MappingJackson2JsonViewTests {
|
||||
|
||||
view.render(model, request, response);
|
||||
|
||||
assertThat(response.getContentAsString().length() > 0).isTrue();
|
||||
assertThat(response.getContentAsString()).isNotEmpty();
|
||||
assertThat(response.getContentAsString()).isEqualTo("{\"foo\":{\"testBeanSimple\":\"custom\"}}");
|
||||
|
||||
validateResult();
|
||||
@@ -207,8 +207,8 @@ public class MappingJackson2JsonViewTests {
|
||||
view.render(model, request, response);
|
||||
|
||||
String result = response.getContentAsString();
|
||||
assertThat(result.length() > 0).isTrue();
|
||||
assertThat(result.contains("\"foo\":{\"testBeanSimple\":\"custom\"}")).isTrue();
|
||||
assertThat(result).isNotEmpty();
|
||||
assertThat(result).contains("\"foo\":{\"testBeanSimple\":\"custom\"}");
|
||||
|
||||
validateResult();
|
||||
}
|
||||
@@ -230,9 +230,9 @@ public class MappingJackson2JsonViewTests {
|
||||
view.render(model, request, response);
|
||||
|
||||
String result = response.getContentAsString();
|
||||
assertThat(result.length() > 0).isTrue();
|
||||
assertThat(result.contains("\"foo\":\"foo\"")).isTrue();
|
||||
assertThat(result.contains("\"baz\":\"baz\"")).isTrue();
|
||||
assertThat(result).isNotEmpty();
|
||||
assertThat(result).contains("\"foo\":\"foo\"");
|
||||
assertThat(result).contains("\"baz\":\"baz\"");
|
||||
|
||||
validateResult();
|
||||
}
|
||||
@@ -263,7 +263,7 @@ public class MappingJackson2JsonViewTests {
|
||||
|
||||
Object actual = view.filterModel(model);
|
||||
|
||||
assertThat(actual instanceof Map).isTrue();
|
||||
assertThat(actual).isInstanceOf(Map.class);
|
||||
assertThat(((Map) actual).get("foo1")).isSameAs(bean1);
|
||||
assertThat(((Map) actual).get("foo2")).isSameAs(bean2);
|
||||
}
|
||||
@@ -280,11 +280,11 @@ public class MappingJackson2JsonViewTests {
|
||||
view.render(model, request, response);
|
||||
|
||||
String content = response.getContentAsString();
|
||||
assertThat(content.length() > 0).isTrue();
|
||||
assertThat(content).isNotEmpty();
|
||||
assertThat(response.getContentLength()).isEqualTo(content.length());
|
||||
assertThat(content.contains("foo")).isTrue();
|
||||
assertThat(content.contains("boo")).isFalse();
|
||||
assertThat(content.contains(JsonView.class.getName())).isFalse();
|
||||
assertThat(content).contains("foo");
|
||||
assertThat(content).doesNotContain("boo");
|
||||
assertThat(content).doesNotContain(JsonView.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -303,11 +303,11 @@ public class MappingJackson2JsonViewTests {
|
||||
view.render(model, request, response);
|
||||
|
||||
String content = response.getContentAsString();
|
||||
assertThat(content.length() > 0).isTrue();
|
||||
assertThat(content).isNotEmpty();
|
||||
assertThat(response.getContentLength()).isEqualTo(content.length());
|
||||
assertThat(content).contains("\"property1\":\"value\"");
|
||||
assertThat(content).doesNotContain("\"property2\":\"value\"");
|
||||
assertThat(content.contains(FilterProvider.class.getName())).isFalse();
|
||||
assertThat(content).doesNotContain(FilterProvider.class.getName());
|
||||
}
|
||||
|
||||
private void validateResult() throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -85,7 +85,7 @@ public class MappingJackson2XmlViewTests {
|
||||
assertThat(mediaType.isCompatibleWith(MediaType.parseMediaType(MappingJackson2XmlView.DEFAULT_CONTENT_TYPE))).isTrue();
|
||||
|
||||
String jsonResult = response.getContentAsString();
|
||||
assertThat(jsonResult.length() > 0).isTrue();
|
||||
assertThat(jsonResult).isNotEmpty();
|
||||
assertThat(response.getContentLength()).isEqualTo(jsonResult.length());
|
||||
|
||||
validateResult();
|
||||
@@ -130,7 +130,7 @@ public class MappingJackson2XmlViewTests {
|
||||
view.setUpdateContentLength(true);
|
||||
view.render(model, request, response);
|
||||
|
||||
assertThat(response.getContentAsString().length() > 0).isTrue();
|
||||
assertThat(response.getContentAsString()).isNotEmpty();
|
||||
assertThat(response.getContentLength()).isEqualTo(response.getContentAsString().length());
|
||||
|
||||
validateResult();
|
||||
@@ -144,8 +144,8 @@ public class MappingJackson2XmlViewTests {
|
||||
|
||||
view.render(model, request, response);
|
||||
|
||||
assertThat(response.getContentAsString().length() > 0).isTrue();
|
||||
assertThat(response.getContentAsString().contains("<testBeanSimple>custom</testBeanSimple>")).isTrue();
|
||||
assertThat(response.getContentAsString()).isNotEmpty();
|
||||
assertThat(response.getContentAsString()).contains("<testBeanSimple>custom</testBeanSimple>");
|
||||
|
||||
validateResult();
|
||||
}
|
||||
@@ -164,8 +164,8 @@ public class MappingJackson2XmlViewTests {
|
||||
view.render(model, request, response);
|
||||
|
||||
String result = response.getContentAsString();
|
||||
assertThat(result.length() > 0).isTrue();
|
||||
assertThat(result.contains("custom</testBeanSimple>")).isTrue();
|
||||
assertThat(result).isNotEmpty();
|
||||
assertThat(result).contains("custom</testBeanSimple>");
|
||||
|
||||
validateResult();
|
||||
}
|
||||
@@ -182,10 +182,10 @@ public class MappingJackson2XmlViewTests {
|
||||
view.render(model, request, response);
|
||||
|
||||
String result = response.getContentAsString();
|
||||
assertThat(result.length() > 0).isTrue();
|
||||
assertThat(result.contains("foo")).isFalse();
|
||||
assertThat(result.contains("bar")).isTrue();
|
||||
assertThat(result.contains("baz")).isFalse();
|
||||
assertThat(result).isNotEmpty();
|
||||
assertThat(result).doesNotContain("foo");
|
||||
assertThat(result).contains("bar");
|
||||
assertThat(result).doesNotContain("baz");
|
||||
|
||||
validateResult();
|
||||
}
|
||||
@@ -212,11 +212,11 @@ public class MappingJackson2XmlViewTests {
|
||||
view.render(model, request, response);
|
||||
|
||||
String content = response.getContentAsString();
|
||||
assertThat(content.length() > 0).isTrue();
|
||||
assertThat(content).isNotEmpty();
|
||||
assertThat(response.getContentLength()).isEqualTo(content.length());
|
||||
assertThat(content.contains("foo")).isTrue();
|
||||
assertThat(content.contains("boo")).isFalse();
|
||||
assertThat(content.contains(JsonView.class.getName())).isFalse();
|
||||
assertThat(content).contains("foo");
|
||||
assertThat(content).doesNotContain("boo");
|
||||
assertThat(content).doesNotContain(JsonView.class.getName());
|
||||
}
|
||||
|
||||
private void validateResult() throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -126,7 +126,7 @@ public class XsltViewTests {
|
||||
|
||||
Source source = new StreamSource(getProductDataResource().getInputStream());
|
||||
view.render(singletonMap("someKey", source), this.request, this.response);
|
||||
assertThat(this.response.getContentType().startsWith("text/html")).isTrue();
|
||||
assertThat(this.response.getContentType()).startsWith("text/html");
|
||||
assertThat(this.response.getCharacterEncoding()).isEqualTo("UTF-8");
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class XsltViewTests {
|
||||
model.put("someKey", getProductDataResource());
|
||||
model.put("title", "Product List");
|
||||
doTestWithModel(model);
|
||||
assertThat(this.response.getContentAsString().contains("Product List")).isTrue();
|
||||
assertThat(this.response.getContentAsString()).contains("Product List");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,7 +151,7 @@ public class XsltViewTests {
|
||||
|
||||
view.render(model, this.request, this.response);
|
||||
assertHtmlOutput(this.response.getContentAsString());
|
||||
assertThat(this.response.getContentAsString().contains("Product List")).isTrue();
|
||||
assertThat(this.response.getContentAsString()).contains("Product List");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user