Polish tests
See gh-27248
This commit is contained in:
@@ -83,7 +83,7 @@ public class EscapedErrorsTests {
|
||||
FieldError ageError = errors.getFieldError("age");
|
||||
assertThat("message: <tag>".equals(ageError.getDefaultMessage())).as("Age error message escaped").isTrue();
|
||||
assertThat("AGE_NOT_SET <tag>".equals(ageError.getCode())).as("Age error code not escaped").isTrue();
|
||||
assertThat((new Integer(0)).equals(errors.getFieldValue("age"))).as("Age value not escaped").isTrue();
|
||||
assertThat((Integer.valueOf(0)).equals(errors.getFieldValue("age"))).as("Age value not escaped").isTrue();
|
||||
FieldError ageErrorInList = errors.getFieldErrors("age").get(0);
|
||||
assertThat(ageError.getDefaultMessage().equals(ageErrorInList.getDefaultMessage())).as("Same name error in list").isTrue();
|
||||
FieldError ageError2 = errors.getFieldErrors("age").get(1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -47,7 +47,7 @@ class ServletRequestUtilsTests {
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredIntParameter(request, "param2"));
|
||||
|
||||
assertThat(ServletRequestUtils.getIntParameter(request, "param3")).isEqualTo(null);
|
||||
assertThat(ServletRequestUtils.getIntParameter(request, "param3")).isNull();
|
||||
assertThat(ServletRequestUtils.getIntParameter(request, "param3", 6)).isEqualTo(6);
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredIntParameter(request, "param3"));
|
||||
@@ -66,7 +66,7 @@ class ServletRequestUtilsTests {
|
||||
|
||||
int[] array = new int[] {1, 2, 3};
|
||||
int[] values = ServletRequestUtils.getRequiredIntParameters(request, "param");
|
||||
assertThat(3).isEqualTo(values.length);
|
||||
assertThat(values).hasSize(3);
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
assertThat(array[i]).isEqualTo(values[i]);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class ServletRequestUtilsTests {
|
||||
request.addParameter("param2", "e");
|
||||
request.addParameter("paramEmpty", "");
|
||||
|
||||
assertThat(ServletRequestUtils.getLongParameter(request, "param1")).isEqualTo(new Long(5L));
|
||||
assertThat(ServletRequestUtils.getLongParameter(request, "param1")).isEqualTo(Long.valueOf(5L));
|
||||
assertThat(ServletRequestUtils.getLongParameter(request, "param1", 6L)).isEqualTo(5L);
|
||||
assertThat(ServletRequestUtils.getRequiredIntParameter(request, "param1")).isEqualTo(5L);
|
||||
|
||||
@@ -89,7 +89,7 @@ class ServletRequestUtilsTests {
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredLongParameter(request, "param2"));
|
||||
|
||||
assertThat(ServletRequestUtils.getLongParameter(request, "param3")).isEqualTo(null);
|
||||
assertThat(ServletRequestUtils.getLongParameter(request, "param3")).isNull();
|
||||
assertThat(ServletRequestUtils.getLongParameter(request, "param3", 6L)).isEqualTo(6L);
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredLongParameter(request, "param3"));
|
||||
@@ -128,7 +128,7 @@ class ServletRequestUtilsTests {
|
||||
request.addParameter("param2", "e");
|
||||
request.addParameter("paramEmpty", "");
|
||||
|
||||
assertThat(ServletRequestUtils.getFloatParameter(request, "param1").equals(new Float(5.5f))).isTrue();
|
||||
assertThat(ServletRequestUtils.getFloatParameter(request, "param1")).isEqualTo(Float.valueOf(5.5f));
|
||||
assertThat(ServletRequestUtils.getFloatParameter(request, "param1", 6.5f) == 5.5f).isTrue();
|
||||
assertThat(ServletRequestUtils.getRequiredFloatParameter(request, "param1") == 5.5f).isTrue();
|
||||
|
||||
@@ -136,7 +136,7 @@ class ServletRequestUtilsTests {
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredFloatParameter(request, "param2"));
|
||||
|
||||
assertThat(ServletRequestUtils.getFloatParameter(request, "param3") == null).isTrue();
|
||||
assertThat(ServletRequestUtils.getFloatParameter(request, "param3")).isNull();
|
||||
assertThat(ServletRequestUtils.getFloatParameter(request, "param3", 6.5f) == 6.5f).isTrue();
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredFloatParameter(request, "param3"));
|
||||
@@ -166,7 +166,7 @@ class ServletRequestUtilsTests {
|
||||
request.addParameter("param2", "e");
|
||||
request.addParameter("paramEmpty", "");
|
||||
|
||||
assertThat(ServletRequestUtils.getDoubleParameter(request, "param1").equals(new Double(5.5))).isTrue();
|
||||
assertThat(ServletRequestUtils.getDoubleParameter(request, "param1")).isEqualTo(Double.valueOf(5.5));
|
||||
assertThat(ServletRequestUtils.getDoubleParameter(request, "param1", 6.5) == 5.5).isTrue();
|
||||
assertThat(ServletRequestUtils.getRequiredDoubleParameter(request, "param1") == 5.5).isTrue();
|
||||
|
||||
@@ -174,7 +174,7 @@ class ServletRequestUtilsTests {
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredDoubleParameter(request, "param2"));
|
||||
|
||||
assertThat(ServletRequestUtils.getDoubleParameter(request, "param3") == null).isTrue();
|
||||
assertThat(ServletRequestUtils.getDoubleParameter(request, "param3")).isNull();
|
||||
assertThat(ServletRequestUtils.getDoubleParameter(request, "param3", 6.5) == 6.5).isTrue();
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredDoubleParameter(request, "param3"));
|
||||
@@ -212,7 +212,7 @@ class ServletRequestUtilsTests {
|
||||
assertThat(ServletRequestUtils.getBooleanParameter(request, "param2", true)).isFalse();
|
||||
assertThat(ServletRequestUtils.getRequiredBooleanParameter(request, "param2")).isFalse();
|
||||
|
||||
assertThat(ServletRequestUtils.getBooleanParameter(request, "param3") == null).isTrue();
|
||||
assertThat(ServletRequestUtils.getBooleanParameter(request, "param3")).isNull();
|
||||
assertThat(ServletRequestUtils.getBooleanParameter(request, "param3", true)).isTrue();
|
||||
assertThatExceptionOfType(ServletRequestBindingException.class).isThrownBy(() ->
|
||||
ServletRequestUtils.getRequiredBooleanParameter(request, "param3"));
|
||||
@@ -235,14 +235,14 @@ class ServletRequestUtilsTests {
|
||||
|
||||
boolean[] array = new boolean[] {true, true, false, true, false};
|
||||
boolean[] values = ServletRequestUtils.getRequiredBooleanParameters(request, "param");
|
||||
assertThat(array.length).isEqualTo(values.length);
|
||||
assertThat(array).hasSameSizeAs(values);
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
assertThat(array[i]).isEqualTo(values[i]);
|
||||
}
|
||||
|
||||
array = new boolean[] {false, true, false};
|
||||
values = ServletRequestUtils.getRequiredBooleanParameters(request, "param2");
|
||||
assertThat(array.length).isEqualTo(values.length);
|
||||
assertThat(array).hasSameSizeAs(values);
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
assertThat(array[i]).isEqualTo(values[i]);
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
* @author Sebastien Deleuze
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class CorsConfigurationTests {
|
||||
class CorsConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void setNullValues() {
|
||||
void setNullValues() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowedOrigins(null);
|
||||
assertThat(config.getAllowedOrigins()).isNull();
|
||||
@@ -55,7 +55,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setValues() {
|
||||
void setValues() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedOrigin("*");
|
||||
config.addAllowedOriginPattern("http://*.example.com");
|
||||
@@ -71,11 +71,11 @@ public class CorsConfigurationTests {
|
||||
assertThat(config.getAllowedMethods()).containsExactly("*");
|
||||
assertThat(config.getExposedHeaders()).containsExactly("*");
|
||||
assertThat(config.getAllowCredentials()).isTrue();
|
||||
assertThat(config.getMaxAge()).isEqualTo(new Long(123));
|
||||
assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(123));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combineWithNull() {
|
||||
void combineWithNull() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowedOrigins(Collections.singletonList("*"));
|
||||
config.combine(null);
|
||||
@@ -84,7 +84,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combineWithNullProperties() {
|
||||
void combineWithNullProperties() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedOrigin("*");
|
||||
config.setAllowedOriginPatterns(Collections.singletonList("http://*.example.com"));
|
||||
@@ -103,12 +103,12 @@ public class CorsConfigurationTests {
|
||||
assertThat(config.getAllowedHeaders()).containsExactly("header1");
|
||||
assertThat(config.getExposedHeaders()).containsExactly("header3");
|
||||
assertThat(config.getAllowedMethods()).containsExactly(HttpMethod.GET.name());
|
||||
assertThat(config.getMaxAge()).isEqualTo(new Long(123));
|
||||
assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(123));
|
||||
assertThat(config.getAllowCredentials()).isTrue();
|
||||
}
|
||||
|
||||
@Test // SPR-15772
|
||||
public void combineWithDefaultPermitValues() {
|
||||
void combineWithDefaultPermitValues() {
|
||||
CorsConfiguration config = new CorsConfiguration().applyPermitDefaultValues();
|
||||
CorsConfiguration other = new CorsConfiguration();
|
||||
other.addAllowedOrigin("https://domain.com");
|
||||
@@ -147,7 +147,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combinePatternWithDefaultPermitValues() {
|
||||
void combinePatternWithDefaultPermitValues() {
|
||||
CorsConfiguration config = new CorsConfiguration().applyPermitDefaultValues();
|
||||
CorsConfiguration other = new CorsConfiguration();
|
||||
other.addAllowedOriginPattern("http://*.com");
|
||||
@@ -164,7 +164,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combinePatternWithDefaultPermitValuesAndCustomOrigin() {
|
||||
void combinePatternWithDefaultPermitValuesAndCustomOrigin() {
|
||||
CorsConfiguration config = new CorsConfiguration().applyPermitDefaultValues();
|
||||
config.setAllowedOrigins(Collections.singletonList("https://domain.com"));
|
||||
|
||||
@@ -183,7 +183,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combineWithAsteriskWildCard() {
|
||||
void combineWithAsteriskWildCard() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedOrigin("*");
|
||||
config.addAllowedHeader("*");
|
||||
@@ -219,7 +219,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test // SPR-14792
|
||||
public void combineWithDuplicatedElements() {
|
||||
void combineWithDuplicatedElements() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedOrigin("https://domain1.com");
|
||||
config.addAllowedOrigin("https://domain2.com");
|
||||
@@ -249,7 +249,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combine() {
|
||||
void combine() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedOrigin("https://domain1.com");
|
||||
config.addAllowedOriginPattern("http://*.domain1.com");
|
||||
@@ -274,14 +274,14 @@ public class CorsConfigurationTests {
|
||||
assertThat(config.getAllowedHeaders()).containsExactly("header1", "header2");
|
||||
assertThat(config.getExposedHeaders()).containsExactly("header3", "header4");
|
||||
assertThat(config.getAllowedMethods()).containsExactly(HttpMethod.GET.name(), HttpMethod.PUT.name());
|
||||
assertThat(config.getMaxAge()).isEqualTo(new Long(456));
|
||||
assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(456));
|
||||
assertThat(config).isNotNull();
|
||||
assertThat(config.getAllowCredentials()).isFalse();
|
||||
assertThat(config.getAllowedOriginPatterns()).containsExactly("http://*.domain1.com", "http://*.domain2.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkOriginAllowed() {
|
||||
void checkOriginAllowed() {
|
||||
// "*" matches
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedOrigin("*");
|
||||
@@ -306,7 +306,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkOriginNotAllowed() {
|
||||
void checkOriginNotAllowed() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
assertThat(config.checkOrigin(null)).isNull();
|
||||
assertThat(config.checkOrigin("https://domain.com")).isNull();
|
||||
@@ -322,7 +322,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkOriginPatternAllowed() {
|
||||
void checkOriginPatternAllowed() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
assertThat(config.checkOrigin("https://domain.com")).isNull();
|
||||
|
||||
@@ -349,7 +349,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkOriginPatternNotAllowed() {
|
||||
void checkOriginPatternNotAllowed() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
assertThat(config.checkOrigin(null)).isNull();
|
||||
assertThat(config.checkOrigin("https://domain.com")).isNull();
|
||||
@@ -367,7 +367,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkMethodAllowed() {
|
||||
void checkMethodAllowed() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
assertThat(config.checkHttpMethod(HttpMethod.GET)).containsExactly(HttpMethod.GET, HttpMethod.HEAD);
|
||||
|
||||
@@ -380,7 +380,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkMethodNotAllowed() {
|
||||
void checkMethodNotAllowed() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
assertThat(config.checkHttpMethod(null)).isNull();
|
||||
assertThat(config.checkHttpMethod(HttpMethod.DELETE)).isNull();
|
||||
@@ -390,7 +390,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkHeadersAllowed() {
|
||||
void checkHeadersAllowed() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
assertThat(config.checkHeaders(Collections.emptyList())).isEqualTo(Collections.emptyList());
|
||||
|
||||
@@ -403,7 +403,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkHeadersNotAllowed() {
|
||||
void checkHeadersNotAllowed() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
assertThat(config.checkHeaders(null)).isNull();
|
||||
assertThat(config.checkHeaders(Collections.singletonList("header1"))).isNull();
|
||||
@@ -417,7 +417,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test // SPR-15772
|
||||
public void changePermitDefaultValues() {
|
||||
void changePermitDefaultValues() {
|
||||
CorsConfiguration config = new CorsConfiguration().applyPermitDefaultValues();
|
||||
config.addAllowedOrigin("https://domain.com");
|
||||
config.addAllowedHeader("header1");
|
||||
@@ -429,7 +429,7 @@ public class CorsConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void permitDefaultDoesntSetOriginWhenPatternPresent() {
|
||||
void permitDefaultDoesntSetOriginWhenPatternPresent() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedOriginPattern("http://*.com");
|
||||
config = config.applyPermitDefaultValues();
|
||||
|
||||
Reference in New Issue
Block a user