Browse Source

Merge branch '6.0.x'

pull/28374/merge
Sam Brannen 1 year ago
parent
commit
16b9640af2
  1. 10
      spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java
  2. 6
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java
  3. 4
      spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
  4. 16
      spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java
  5. 4
      spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java
  6. 2
      spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java
  7. 3
      spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java
  8. 18
      spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java
  9. 4
      spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java
  10. 20
      spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java
  11. 4
      spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java
  12. 20
      spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java
  13. 4
      spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java
  14. 2
      spring-jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java
  15. 2
      spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java
  16. 20
      spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java
  17. 10
      spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java
  18. 2
      spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java
  19. 8
      spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java
  20. 2
      spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java
  21. 2
      spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java
  22. 16
      spring-jms/src/test/java/org/springframework/jms/StubTextMessage.java
  23. 95
      spring-jms/src/test/java/org/springframework/jms/support/SimpleJmsHeaderMapperTests.java
  24. 8
      spring-r2dbc/src/test/java/org/springframework/r2dbc/core/AbstractDatabaseClientIntegrationTests.java
  25. 6
      spring-r2dbc/src/test/java/org/springframework/r2dbc/core/AbstractTransactionalDatabaseClientIntegrationTests.java
  26. 13
      spring-r2dbc/src/test/java/org/springframework/r2dbc/core/H2DatabaseClientIntegrationTests.java
  27. 13
      spring-r2dbc/src/test/java/org/springframework/r2dbc/core/H2TransactionalDatabaseClientIntegrationTests.java
  28. 2
      spring-test/src/test/java/org/springframework/test/context/cache/MethodLevelDirtiesContextTests.java
  29. 2
      spring-test/src/test/java/org/springframework/test/context/env/MergedPropertiesFilesTestPropertySourceTests.java
  30. 6
      spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java
  31. 10
      spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java
  32. 53
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java

10
spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java

@ -673,22 +673,22 @@ abstract class AbstractPropertyAccessorTests { @@ -673,22 +673,22 @@ abstract class AbstractPropertyAccessorTests {
accessor.setPropertyValue("myDouble", doubleValue);
assertThat(target.getMyPrimitiveByte()).isEqualTo(Byte.MAX_VALUE);
assertThat(target.getMyByte().byteValue()).isEqualTo(Byte.MAX_VALUE);
assertThat(target.getMyByte()).isEqualTo(Byte.MAX_VALUE);
assertThat(target.getMyPrimitiveShort()).isEqualTo(Short.MAX_VALUE);
assertThat(target.getMyShort().shortValue()).isEqualTo(Short.MAX_VALUE);
assertThat(target.getMyShort()).isEqualTo(Short.MAX_VALUE);
assertThat(target.getMyPrimitiveInt()).isEqualTo(Integer.MAX_VALUE);
assertThat(target.getMyInteger().intValue()).isEqualTo(Integer.MAX_VALUE);
assertThat(target.getMyInteger()).isEqualTo(Integer.MAX_VALUE);
assertThat(target.getMyPrimitiveLong()).isEqualTo(Long.MAX_VALUE);
assertThat(target.getMyLong().longValue()).isEqualTo(Long.MAX_VALUE);
assertThat(target.getMyLong()).isEqualTo(Long.MAX_VALUE);
assertThat((double) target.getMyPrimitiveFloat()).isCloseTo(Float.MAX_VALUE, within(0.001));
assertThat((double) target.getMyFloat()).isCloseTo(Float.MAX_VALUE, within(0.001));
assertThat(target.getMyPrimitiveDouble()).isCloseTo(Double.MAX_VALUE, within(0.001));
assertThat(target.getMyDouble().doubleValue()).isCloseTo(Double.MAX_VALUE, within(0.001));
assertThat(target.getMyDouble()).isCloseTo(Double.MAX_VALUE, within(0.001));
}
@Test

6
spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java

@ -335,7 +335,7 @@ class BeanWrapperGenericsTests { @@ -335,7 +335,7 @@ class BeanWrapperGenericsTests {
Object obj = gb.getMapOfListOfInteger().get("testKey").get(0);
assertThat(obj).isInstanceOf(Integer.class);
assertThat(((Integer) obj).intValue()).isEqualTo(1);
assertThat(obj).isEqualTo(1);
}
@Test
@ -351,7 +351,7 @@ class BeanWrapperGenericsTests { @@ -351,7 +351,7 @@ class BeanWrapperGenericsTests {
Object obj = gb.getListOfMapOfInteger().get(0).get("testKey");
assertThat(obj).isInstanceOf(Integer.class);
assertThat(((Integer) obj).intValue()).isEqualTo(5);
assertThat(obj).isEqualTo(5);
}
@Test
@ -366,7 +366,7 @@ class BeanWrapperGenericsTests { @@ -366,7 +366,7 @@ class BeanWrapperGenericsTests {
Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0);
assertThat(obj).isInstanceOf(Integer.class);
assertThat(((Integer) obj).intValue()).isEqualTo(1);
assertThat(obj).isEqualTo(1);
}
@Test

4
spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java

@ -3201,9 +3201,9 @@ class DefaultListableBeanFactoryTests { @@ -3201,9 +3201,9 @@ class DefaultListableBeanFactoryTests {
@Override
public Object convertIfNecessary(Object value, @Nullable Class requiredType) {
if (value instanceof String && Float.class.isAssignableFrom(requiredType)) {
if (value instanceof String text && Float.class.isAssignableFrom(requiredType)) {
try {
return this.numberFormat.parse((String) value).floatValue();
return this.numberFormat.parse(text).floatValue();
}
catch (ParseException ex) {
throw new TypeMismatchException(value, requiredType, ex);

16
spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java

@ -135,9 +135,9 @@ public class MethodInvokingFactoryBeanTests { @@ -135,9 +135,9 @@ public class MethodInvokingFactoryBeanTests {
mcfb.setTargetMethod("method1");
mcfb.afterPropertiesSet();
Integer i = (Integer) mcfb.getObject();
assertThat(i.intValue()).isEqualTo(1);
assertThat(i).isEqualTo(1);
i = (Integer) mcfb.getObject();
assertThat(i.intValue()).isEqualTo(1);
assertThat(i).isEqualTo(1);
// non-singleton, non-static
tc1 = new TestClass1();
@ -147,9 +147,9 @@ public class MethodInvokingFactoryBeanTests { @@ -147,9 +147,9 @@ public class MethodInvokingFactoryBeanTests {
mcfb.setSingleton(false);
mcfb.afterPropertiesSet();
i = (Integer) mcfb.getObject();
assertThat(i.intValue()).isEqualTo(1);
assertThat(i).isEqualTo(1);
i = (Integer) mcfb.getObject();
assertThat(i.intValue()).isEqualTo(2);
assertThat(i).isEqualTo(2);
// singleton, static
TestClass1._staticField1 = 0;
@ -158,9 +158,9 @@ public class MethodInvokingFactoryBeanTests { @@ -158,9 +158,9 @@ public class MethodInvokingFactoryBeanTests {
mcfb.setTargetMethod("staticMethod1");
mcfb.afterPropertiesSet();
i = (Integer) mcfb.getObject();
assertThat(i.intValue()).isEqualTo(1);
assertThat(i).isEqualTo(1);
i = (Integer) mcfb.getObject();
assertThat(i.intValue()).isEqualTo(1);
assertThat(i).isEqualTo(1);
// non-singleton, static
TestClass1._staticField1 = 0;
@ -169,9 +169,9 @@ public class MethodInvokingFactoryBeanTests { @@ -169,9 +169,9 @@ public class MethodInvokingFactoryBeanTests {
mcfb.setSingleton(false);
mcfb.afterPropertiesSet();
i = (Integer) mcfb.getObject();
assertThat(i.intValue()).isEqualTo(1);
assertThat(i).isEqualTo(1);
i = (Integer) mcfb.getObject();
assertThat(i.intValue()).isEqualTo(2);
assertThat(i).isEqualTo(2);
// void return value
mcfb = new MethodInvokingFactoryBean();

4
spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java

@ -65,13 +65,13 @@ public class UtilNamespaceHandlerTests { @@ -65,13 +65,13 @@ public class UtilNamespaceHandlerTests {
@Test
void testConstant() {
Integer min = (Integer) this.beanFactory.getBean("min");
assertThat(min.intValue()).isEqualTo(Integer.MIN_VALUE);
assertThat(min).isEqualTo(Integer.MIN_VALUE);
}
@Test
void testConstantWithDefaultName() {
Integer max = (Integer) this.beanFactory.getBean("java.lang.Integer.MAX_VALUE");
assertThat(max.intValue()).isEqualTo(Integer.MAX_VALUE);
assertThat(max).isEqualTo(Integer.MAX_VALUE);
}
@Test

2
spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java

@ -160,7 +160,7 @@ class ApplicationContextExpressionTests { @@ -160,7 +160,7 @@ class ApplicationContextExpressionTests {
ValueTestBean tb3 = ac.getBean("tb3", ValueTestBean.class);
assertThat(tb3.name).isEqualTo("XXXmyNameYYY42ZZZ");
assertThat(tb3.age).isEqualTo(42);
assertThat(tb3.ageFactory.getObject().intValue()).isEqualTo(42);
assertThat(tb3.ageFactory.getObject()).isEqualTo(42);
assertThat(tb3.country).isEqualTo("123 UK");
assertThat(tb3.countryFactory.getObject()).isEqualTo("123 UK");
System.getProperties().put("country", "US");

3
spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java

@ -51,8 +51,7 @@ class PropertyPlaceholderConfigurerTests extends AbstractJmxTests { @@ -51,8 +51,7 @@ class PropertyPlaceholderConfigurerTests extends AbstractJmxTests {
Integer age = (Integer) getServer().getAttribute(oname, "Age");
assertThat(name).as("Name is incorrect in JMX").isEqualTo("Rob Harrop");
assertThat(age.intValue()).as("Age is incorrect in JMX").isEqualTo(100);
assertThat(age).as("Age is incorrect in JMX").isEqualTo(100);
}
}

18
spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java

@ -60,26 +60,18 @@ class CollectionToCollectionConverterTests { @@ -60,26 +60,18 @@ class CollectionToCollectionConverterTests {
@Test
void scalarList() throws Exception {
List<String> list = new ArrayList<>();
list.add("9");
list.add("37");
List<String> list = List.of("9", "37");
TypeDescriptor sourceType = TypeDescriptor.forObject(list);
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("scalarListTarget"));
assertThat(conversionService.canConvert(sourceType, targetType)).isTrue();
try {
conversionService.convert(list, sourceType, targetType);
}
catch (ConversionFailedException ex) {
boolean condition = ex.getCause() instanceof ConverterNotFoundException;
assertThat(condition).isTrue();
}
assertThatExceptionOfType(ConversionFailedException.class)
.isThrownBy(() -> conversionService.convert(list, sourceType, targetType))
.withCauseInstanceOf(ConverterNotFoundException.class);
conversionService.addConverterFactory(new StringToNumberConverterFactory());
assertThat(conversionService.canConvert(sourceType, targetType)).isTrue();
@SuppressWarnings("unchecked")
List<Integer> result = (List<Integer>) conversionService.convert(list, sourceType, targetType);
assertThat(list.equals(result)).isFalse();
assertThat(result.get(0).intValue()).isEqualTo(9);
assertThat(result.get(1).intValue()).isEqualTo(37);
assertThat(result).isNotEqualTo(list).containsExactly(9, 37);
}
@Test

4
spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java

@ -42,7 +42,7 @@ class MethodInvokerTests { @@ -42,7 +42,7 @@ class MethodInvokerTests {
mi.setTargetMethod("method1");
mi.prepare();
Integer i = (Integer) mi.invoke();
assertThat(i.intValue()).isEqualTo(1);
assertThat(i).isEqualTo(1);
// defensive check: singleton, non-static should work with null array
tc1 = new TestClass1();
@ -52,7 +52,7 @@ class MethodInvokerTests { @@ -52,7 +52,7 @@ class MethodInvokerTests {
mi.setArguments((Object[]) null);
mi.prepare();
i = (Integer) mi.invoke();
assertThat(i.intValue()).isEqualTo(1);
assertThat(i).isEqualTo(1);
// sanity check: check that argument count matching works
mi = new MethodInvoker();

20
spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java

@ -104,8 +104,8 @@ class NumberUtilsTests { @@ -104,8 +104,8 @@ class NumberUtilsTests {
@Test
void parseNumberAsHex() {
String aByte = "0x" + Integer.toHexString(Byte.valueOf(Byte.MAX_VALUE).intValue());
String aShort = "0x" + Integer.toHexString(Short.valueOf(Short.MAX_VALUE).intValue());
String aByte = "0x" + Integer.toHexString(Byte.valueOf(Byte.MAX_VALUE));
String aShort = "0x" + Integer.toHexString(Short.valueOf(Short.MAX_VALUE));
String anInteger = "0x" + Integer.toHexString(Integer.MAX_VALUE);
String aLong = "0x" + Long.toHexString(Long.MAX_VALUE);
String aReallyBigInt = "FEBD4E677898DFEBFFEE44";
@ -368,35 +368,35 @@ class NumberUtilsTests { @@ -368,35 +368,35 @@ class NumberUtilsTests {
private void assertLongEquals(String aLong) {
assertThat(NumberUtils.parseNumber(aLong, Long.class).longValue()).as("Long did not parse").isEqualTo(Long.MAX_VALUE);
assertThat(NumberUtils.parseNumber(aLong, Long.class)).as("Long did not parse").isEqualTo(Long.MAX_VALUE);
}
private void assertIntegerEquals(String anInteger) {
assertThat(NumberUtils.parseNumber(anInteger, Integer.class).intValue()).as("Integer did not parse").isEqualTo(Integer.MAX_VALUE);
assertThat(NumberUtils.parseNumber(anInteger, Integer.class)).as("Integer did not parse").isEqualTo(Integer.MAX_VALUE);
}
private void assertShortEquals(String aShort) {
assertThat(NumberUtils.parseNumber(aShort, Short.class).shortValue()).as("Short did not parse").isEqualTo(Short.MAX_VALUE);
assertThat(NumberUtils.parseNumber(aShort, Short.class)).as("Short did not parse").isEqualTo(Short.MAX_VALUE);
}
private void assertByteEquals(String aByte) {
assertThat(NumberUtils.parseNumber(aByte, Byte.class).byteValue()).as("Byte did not parse").isEqualTo(Byte.MAX_VALUE);
assertThat(NumberUtils.parseNumber(aByte, Byte.class)).as("Byte did not parse").isEqualTo(Byte.MAX_VALUE);
}
private void assertNegativeLongEquals(String aLong) {
assertThat(NumberUtils.parseNumber(aLong, Long.class).longValue()).as("Long did not parse").isEqualTo(Long.MIN_VALUE);
assertThat(NumberUtils.parseNumber(aLong, Long.class)).as("Long did not parse").isEqualTo(Long.MIN_VALUE);
}
private void assertNegativeIntegerEquals(String anInteger) {
assertThat(NumberUtils.parseNumber(anInteger, Integer.class).intValue()).as("Integer did not parse").isEqualTo(Integer.MIN_VALUE);
assertThat(NumberUtils.parseNumber(anInteger, Integer.class)).as("Integer did not parse").isEqualTo(Integer.MIN_VALUE);
}
private void assertNegativeShortEquals(String aShort) {
assertThat(NumberUtils.parseNumber(aShort, Short.class).shortValue()).as("Short did not parse").isEqualTo(Short.MIN_VALUE);
assertThat(NumberUtils.parseNumber(aShort, Short.class)).as("Short did not parse").isEqualTo(Short.MIN_VALUE);
}
private void assertNegativeByteEquals(String aByte) {
assertThat(NumberUtils.parseNumber(aByte, Byte.class).byteValue()).as("Byte did not parse").isEqualTo(Byte.MIN_VALUE);
assertThat(NumberUtils.parseNumber(aByte, Byte.class)).as("Byte did not parse").isEqualTo(Byte.MIN_VALUE);
}
private void assertToNumberOverflow(Number number, Class<? extends Number> targetClass) {

4
spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java

@ -164,9 +164,9 @@ class ObjectUtilsTests { @@ -164,9 +164,9 @@ class ObjectUtilsTests {
void toObjectArray() {
int[] a = new int[] {1, 2, 3, 4, 5};
Integer[] wrapper = (Integer[]) ObjectUtils.toObjectArray(a);
assertThat(wrapper.length).isEqualTo(5);
assertThat(wrapper).hasSize(5);
for (int i = 0; i < wrapper.length; i++) {
assertThat(wrapper[i].intValue()).isEqualTo(a[i]);
assertThat(wrapper[i]).isEqualTo(a[i]);
}
}

20
spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java

@ -859,7 +859,7 @@ class EvaluationTests extends AbstractExpressionTests { @@ -859,7 +859,7 @@ class EvaluationTests extends AbstractExpressionTests {
StandardEvaluationContext ctx = new StandardEvaluationContext(i);
ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
Expression e = parser.parseExpression("#this++");
assertThat(i.intValue()).isEqualTo(42);
assertThat(i).isEqualTo(42);
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
e.getValue(ctx, Integer.class))
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.NOT_ASSIGNABLE));
@ -1009,7 +1009,7 @@ class EvaluationTests extends AbstractExpressionTests { @@ -1009,7 +1009,7 @@ class EvaluationTests extends AbstractExpressionTests {
StandardEvaluationContext ctx = new StandardEvaluationContext(i);
ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
Expression e = parser.parseExpression("#this--");
assertThat(i.intValue()).isEqualTo(42);
assertThat(i).isEqualTo(42);
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
e.getValue(ctx, Integer.class))
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.NOT_ASSIGNABLE));
@ -1170,13 +1170,13 @@ class EvaluationTests extends AbstractExpressionTests { @@ -1170,13 +1170,13 @@ class EvaluationTests extends AbstractExpressionTests {
// index1 is 3 intArray[3] is 4
e = parser.parseExpression("intArray[#root.index1++]--");
assertThat(e.getValue(ctx, Integer.class).intValue()).isEqualTo(4);
assertThat(e.getValue(ctx, Integer.class)).isEqualTo(4);
assertThat(helper.index1).isEqualTo(4);
assertThat(helper.intArray[3]).isEqualTo(3);
// index1 is 4, intArray[3] is 3
e = parser.parseExpression("intArray[--#root.index1]++");
assertThat(e.getValue(ctx, Integer.class).intValue()).isEqualTo(3);
assertThat(e.getValue(ctx, Integer.class)).isEqualTo(3);
assertThat(helper.index1).isEqualTo(3);
assertThat(helper.intArray[3]).isEqualTo(4);
}
@ -1427,22 +1427,22 @@ class EvaluationTests extends AbstractExpressionTests { @@ -1427,22 +1427,22 @@ class EvaluationTests extends AbstractExpressionTests {
ctx.setVariable("wobble", 3);
e = parser.parseExpression("#wobble++");
assertThat(((Integer) ctx.lookupVariable("wobble")).intValue()).isEqualTo(3);
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(3);
int r = e.getValue(ctx, Integer.TYPE);
assertThat(r).isEqualTo(3);
assertThat(((Integer) ctx.lookupVariable("wobble")).intValue()).isEqualTo(4);
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(4);
e = parser.parseExpression("--#wobble");
assertThat(((Integer) ctx.lookupVariable("wobble")).intValue()).isEqualTo(4);
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(4);
r = e.getValue(ctx, Integer.TYPE);
assertThat(r).isEqualTo(3);
assertThat(((Integer) ctx.lookupVariable("wobble")).intValue()).isEqualTo(3);
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(3);
e = parser.parseExpression("#wobble=34");
assertThat(((Integer) ctx.lookupVariable("wobble")).intValue()).isEqualTo(3);
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(3);
r = e.getValue(ctx, Integer.TYPE);
assertThat(r).isEqualTo(34);
assertThat(((Integer) ctx.lookupVariable("wobble")).intValue()).isEqualTo(34);
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(34);
// Projection
expectFailNotIncrementable(parser, ctx, "({1,2,3}.![#isEven(#this)])++"); // projection would be {false,true,false}

4
spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java

@ -90,12 +90,12 @@ public class ExpressionWithConversionTests extends AbstractExpressionTests { @@ -90,12 +90,12 @@ public class ExpressionWithConversionTests extends AbstractExpressionTests {
public void testSetParameterizedList() throws Exception {
StandardEvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
Expression e = parser.parseExpression("listOfInteger.size()");
assertThat(e.getValue(context, Integer.class).intValue()).isEqualTo(0);
assertThat(e.getValue(context, Integer.class)).isZero();
context.setTypeConverter(new TypeConvertorUsingConversionService());
// Assign a List<String> to the List<Integer> field - the component elements should be converted
parser.parseExpression("listOfInteger").setValue(context,listOfString);
// size now 3
assertThat(e.getValue(context, Integer.class).intValue()).isEqualTo(3);
assertThat(e.getValue(context, Integer.class)).isEqualTo(3);
Class<?> clazz = parser.parseExpression("listOfInteger[1].getClass()").getValue(context, Class.class); // element type correctly Integer
assertThat(clazz).isEqualTo(Integer.class);
}

2
spring-jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java

@ -115,7 +115,7 @@ public class InitializeDatabaseIntegrationTests { @@ -115,7 +115,7 @@ public class InitializeDatabaseIntegrationTests {
private void assertCorrectSetup(DataSource dataSource) {
JdbcTemplate jt = new JdbcTemplate(dataSource);
assertThat(jt.queryForObject("select count(*) from T_TEST", Integer.class).intValue()).isEqualTo(1);
assertThat(jt.queryForObject("select count(*) from T_TEST", Integer.class)).isEqualTo(1);
}

2
spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java

@ -172,7 +172,7 @@ class JdbcNamespaceIntegrationTests { @@ -172,7 +172,7 @@ class JdbcNamespaceIntegrationTests {
}
private void assertNumRowsInTestTable(JdbcTemplate template, int count) {
assertThat(template.queryForObject("select count(*) from T_TEST", Integer.class).intValue()).isEqualTo(count);
assertThat(template.queryForObject("select count(*) from T_TEST", Integer.class)).isEqualTo(count);
}
private void assertCorrectSetup(String file, String... dataSources) {

20
spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java

@ -85,8 +85,8 @@ public class JdbcTemplateQueryTests { @@ -85,8 +85,8 @@ public class JdbcTemplateQueryTests {
given(this.resultSet.getObject(1)).willReturn(11, 12);
List<Map<String, Object>> li = this.template.queryForList(sql);
assertThat(li).as("All rows returned").hasSize(2);
assertThat(((Integer) li.get(0).get("age")).intValue()).as("First row is Integer").isEqualTo(11);
assertThat(((Integer) li.get(1).get("age")).intValue()).as("Second row is Integer").isEqualTo(12);
assertThat(((Integer) li.get(0).get("age"))).as("First row is Integer").isEqualTo(11);
assertThat(((Integer) li.get(1).get("age"))).as("Second row is Integer").isEqualTo(12);
verify(this.resultSet).close();
verify(this.statement).close();
}
@ -108,7 +108,7 @@ public class JdbcTemplateQueryTests { @@ -108,7 +108,7 @@ public class JdbcTemplateQueryTests {
given(this.resultSet.getObject(1)).willReturn(11);
List<Map<String, Object>> li = this.template.queryForList(sql);
assertThat(li).as("All rows returned").hasSize(1);
assertThat(((Integer) li.get(0).get("age")).intValue()).as("First row is Integer").isEqualTo(11);
assertThat(((Integer) li.get(0).get("age"))).as("First row is Integer").isEqualTo(11);
verify(this.resultSet).close();
verify(this.statement).close();
}
@ -120,7 +120,7 @@ public class JdbcTemplateQueryTests { @@ -120,7 +120,7 @@ public class JdbcTemplateQueryTests {
given(this.resultSet.getInt(1)).willReturn(11);
List<Integer> li = this.template.queryForList(sql, Integer.class);
assertThat(li).as("All rows returned").hasSize(1);
assertThat(li.get(0).intValue()).as("Element is Integer").isEqualTo(11);
assertThat(li.get(0)).as("Element is Integer").isEqualTo(11);
verify(this.resultSet).close();
verify(this.statement).close();
}
@ -131,7 +131,7 @@ public class JdbcTemplateQueryTests { @@ -131,7 +131,7 @@ public class JdbcTemplateQueryTests {
given(this.resultSet.next()).willReturn(true, false);
given(this.resultSet.getObject(1)).willReturn(11);
Map<String, Object> map = this.template.queryForMap(sql);
assertThat(((Integer) map.get("age")).intValue()).as("Wow is Integer").isEqualTo(11);
assertThat((Integer) map.get("age")).as("Wow is Integer").isEqualTo(11);
verify(this.resultSet).close();
verify(this.statement).close();
}
@ -285,8 +285,8 @@ public class JdbcTemplateQueryTests { @@ -285,8 +285,8 @@ public class JdbcTemplateQueryTests {
given(this.resultSet.getObject(1)).willReturn(11, 12);
List<Map<String, Object>> li = this.template.queryForList(sql, 3);
assertThat(li).as("All rows returned").hasSize(2);
assertThat(((Integer) li.get(0).get("age")).intValue()).as("First row is Integer").isEqualTo(11);
assertThat(((Integer) li.get(1).get("age")).intValue()).as("Second row is Integer").isEqualTo(12);
assertThat(((Integer) li.get(0).get("age"))).as("First row is Integer").isEqualTo(11);
assertThat(((Integer) li.get(1).get("age"))).as("Second row is Integer").isEqualTo(12);
verify(this.preparedStatement).setObject(1, 3);
verify(this.resultSet).close();
verify(this.preparedStatement).close();
@ -310,7 +310,7 @@ public class JdbcTemplateQueryTests { @@ -310,7 +310,7 @@ public class JdbcTemplateQueryTests {
given(this.resultSet.getObject(1)).willReturn(11);
List<Map<String, Object>> li = this.template.queryForList(sql, 3);
assertThat(li).as("All rows returned").hasSize(1);
assertThat(((Integer) li.get(0).get("age")).intValue()).as("First row is Integer").isEqualTo(11);
assertThat(((Integer) li.get(0).get("age"))).as("First row is Integer").isEqualTo(11);
verify(this.preparedStatement).setObject(1, 3);
verify(this.resultSet).close();
verify(this.preparedStatement).close();
@ -323,7 +323,7 @@ public class JdbcTemplateQueryTests { @@ -323,7 +323,7 @@ public class JdbcTemplateQueryTests {
given(this.resultSet.getInt(1)).willReturn(11);
List<Integer> li = this.template.queryForList(sql, Integer.class, 3);
assertThat(li).as("All rows returned").hasSize(1);
assertThat(li.get(0).intValue()).as("First row is Integer").isEqualTo(11);
assertThat(li.get(0)).as("First row is Integer").isEqualTo(11);
verify(this.preparedStatement).setObject(1, 3);
verify(this.resultSet).close();
verify(this.preparedStatement).close();
@ -335,7 +335,7 @@ public class JdbcTemplateQueryTests { @@ -335,7 +335,7 @@ public class JdbcTemplateQueryTests {
given(this.resultSet.next()).willReturn(true, false);
given(this.resultSet.getObject(1)).willReturn(11);
Map<String, Object> map = this.template.queryForMap(sql, 3);
assertThat(((Integer) map.get("age")).intValue()).as("Row is Integer").isEqualTo(11);
assertThat(((Integer) map.get("age"))).as("Row is Integer").isEqualTo(11);
verify(this.preparedStatement).setObject(1, 3);
verify(this.resultSet).close();
verify(this.preparedStatement).close();

10
spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java

@ -90,8 +90,8 @@ public class NamedParameterQueryTests { @@ -90,8 +90,8 @@ public class NamedParameterQueryTests {
"SELECT AGE FROM CUSTMR WHERE ID < :id", params);
assertThat(li.size()).as("All rows returned").isEqualTo(2);
assertThat(((Integer) li.get(0).get("age")).intValue()).as("First row is Integer").isEqualTo(11);
assertThat(((Integer) li.get(1).get("age")).intValue()).as("Second row is Integer").isEqualTo(12);
assertThat(li.get(0).get("age")).as("First row is Integer").isEqualTo(11);
assertThat(li.get(1).get("age")).as("Second row is Integer").isEqualTo(12);
verify(connection).prepareStatement("SELECT AGE FROM CUSTMR WHERE ID < ?");
verify(preparedStatement).setObject(1, 3);
@ -123,7 +123,7 @@ public class NamedParameterQueryTests { @@ -123,7 +123,7 @@ public class NamedParameterQueryTests {
"SELECT AGE FROM CUSTMR WHERE ID < :id", params);
assertThat(li.size()).as("All rows returned").isEqualTo(1);
assertThat(((Integer) li.get(0).get("age")).intValue()).as("First row is Integer").isEqualTo(11);
assertThat(li.get(0).get("age")).as("First row is Integer").isEqualTo(11);
verify(connection).prepareStatement("SELECT AGE FROM CUSTMR WHERE ID < ?");
verify(preparedStatement).setObject(1, 3);
}
@ -141,7 +141,7 @@ public class NamedParameterQueryTests { @@ -141,7 +141,7 @@ public class NamedParameterQueryTests {
params, Integer.class);
assertThat(li.size()).as("All rows returned").isEqualTo(1);
assertThat(li.get(0).intValue()).as("First row is Integer").isEqualTo(11);
assertThat(li.get(0)).as("First row is Integer").isEqualTo(11);
verify(connection).prepareStatement("SELECT AGE FROM CUSTMR WHERE ID < ?");
verify(preparedStatement).setObject(1, 3);
}
@ -156,7 +156,7 @@ public class NamedParameterQueryTests { @@ -156,7 +156,7 @@ public class NamedParameterQueryTests {
params.addValue("id", 3);
Map<String, Object> map = template.queryForMap("SELECT AGE FROM CUSTMR WHERE ID < :id", params);
assertThat(((Integer) map.get("age")).intValue()).as("Row is Integer").isEqualTo(11);
assertThat(map.get("age")).as("Row is Integer").isEqualTo(11);
verify(connection).prepareStatement("SELECT AGE FROM CUSTMR WHERE ID < ?");
verify(preparedStatement).setObject(1, 3);
}

2
spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java

@ -173,7 +173,7 @@ public class EmbeddedDatabaseBuilderTests { @@ -173,7 +173,7 @@ public class EmbeddedDatabaseBuilderTests {
}
private void assertNumRowsInTestTable(JdbcTemplate template, int count) {
assertThat(template.queryForObject("select count(*) from T_TEST", Integer.class).intValue()).isEqualTo(count);
assertThat(template.queryForObject("select count(*) from T_TEST", Integer.class)).isEqualTo(count);
}
private void assertDatabaseCreated(EmbeddedDatabase db) {

8
spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java

@ -19,7 +19,6 @@ package org.springframework.jdbc.object; @@ -19,7 +19,6 @@ package org.springframework.jdbc.object;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
@ -60,12 +59,9 @@ public class GenericStoredProcedureTests { @@ -60,12 +59,9 @@ public class GenericStoredProcedureTests {
given(connection.prepareCall("{call " + "add_invoice" + "(?, ?, ?)}")).willReturn(callableStatement);
StoredProcedure adder = (StoredProcedure) bf.getBean("genericProcedure");
Map<String, Object> in = new HashMap<>(2);
in.put("amount", 1106);
in.put("custid", 3);
Map<String, Object> in = Map.of("amount", 1106, "custid", 3);
Map<String, Object> out = adder.execute(in);
Integer id = (Integer) out.get("newid");
assertThat(id.intValue()).isEqualTo(4);
assertThat(out.get("newid")).isEqualTo(4);
verify(callableStatement).setObject(1, 1106, Types.INTEGER);
verify(callableStatement).setObject(2, 3, Types.INTEGER);

2
spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java

@ -221,7 +221,7 @@ public class SqlUpdateTests { @@ -221,7 +221,7 @@ public class SqlUpdateTests {
assertThat(rowsAffected).isEqualTo(1);
assertThat(generatedKeyHolder.getKeyList()).hasSize(1);
assertThat(generatedKeyHolder.getKey().intValue()).isEqualTo(11);
assertThat(generatedKeyHolder.getKey()).isEqualTo(11);
verify(preparedStatement).setString(1, "rod");
verify(resultSet).close();
}

2
spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java

@ -325,7 +325,7 @@ public class StoredProcedureTests { @@ -325,7 +325,7 @@ public class StoredProcedureTests {
assertThat(m2.get("eggs")).isEqualTo("Eggs");
Number n = (Number) res.get("#update-count-1");
assertThat(n.intValue()).as("wrong update count").isEqualTo(0);
assertThat(n).as("wrong update count").isEqualTo(0);
verify(resultSet1).close();
verify(resultSet2).close();
}

16
spring-jms/src/test/java/org/springframework/jms/StubTextMessage.java

@ -94,31 +94,31 @@ public class StubTextMessage implements TextMessage { @@ -94,31 +94,31 @@ public class StubTextMessage implements TextMessage {
@Override
public boolean getBooleanProperty(String name) throws JMSException {
Object value = this.properties.get(name);
return (value instanceof Boolean) ? ((Boolean) value).booleanValue() : false;
return (value instanceof Boolean b) ? b : false;
}
@Override
public byte getByteProperty(String name) throws JMSException {
Object value = this.properties.get(name);
return (value instanceof Byte) ? ((Byte) value).byteValue() : 0;
return (value instanceof Byte b) ? b : 0;
}
@Override
public double getDoubleProperty(String name) throws JMSException {
Object value = this.properties.get(name);
return (value instanceof Double) ? ((Double) value).doubleValue() : 0;
return (value instanceof Double d) ? d : 0;
}
@Override
public float getFloatProperty(String name) throws JMSException {
Object value = this.properties.get(name);
return (value instanceof Float) ? ((Float) value).floatValue() : 0;
return (value instanceof Float f) ? f : 0;
}
@Override
public int getIntProperty(String name) throws JMSException {
Object value = this.properties.get(name);
return (value instanceof Integer) ? ((Integer) value).intValue() : 0;
return (value instanceof Integer i) ? i : 0;
}
@Override
@ -184,7 +184,7 @@ public class StubTextMessage implements TextMessage { @@ -184,7 +184,7 @@ public class StubTextMessage implements TextMessage {
@Override
public long getLongProperty(String name) throws JMSException {
Object value = this.properties.get(name);
return (value instanceof Long) ? ((Long) value).longValue() : 0;
return (value instanceof Long l) ? l : 0;
}
@Override
@ -200,13 +200,13 @@ public class StubTextMessage implements TextMessage { @@ -200,13 +200,13 @@ public class StubTextMessage implements TextMessage {
@Override
public short getShortProperty(String name) throws JMSException {
Object value = this.properties.get(name);
return (value instanceof Short) ? ((Short) value).shortValue() : 0;
return (value instanceof Short s) ? s : 0;
}
@Override
public String getStringProperty(String name) throws JMSException {
Object value = this.properties.get(name);
return (value instanceof String) ? (String) value : null;
return (value instanceof String text) ? text : null;
}
@Override

95
spring-jms/src/test/java/org/springframework/jms/support/SimpleJmsHeaderMapperTests.java

@ -32,12 +32,11 @@ import org.springframework.messaging.support.MessageBuilder; @@ -32,12 +32,11 @@ import org.springframework.messaging.support.MessageBuilder;
import static org.assertj.core.api.Assertions.assertThat;
/**
*
* @author Mark Fisher
* @author Gary Russel
* @author Gary Russell
* @author Stephane Nicoll
*/
public class SimpleJmsHeaderMapperTests {
class SimpleJmsHeaderMapperTests {
private final SimpleJmsHeaderMapper mapper = new SimpleJmsHeaderMapper();
@ -45,7 +44,7 @@ public class SimpleJmsHeaderMapperTests { @@ -45,7 +44,7 @@ public class SimpleJmsHeaderMapperTests {
// Outbound mapping
@Test
public void jmsReplyToMappedFromHeader() throws JMSException {
void jmsReplyToMappedFromHeader() throws JMSException {
Destination replyTo = new Destination() {};
Message<String> message = initBuilder()
.setHeader(JmsHeaders.REPLY_TO, replyTo).build();
@ -57,7 +56,7 @@ public class SimpleJmsHeaderMapperTests { @@ -57,7 +56,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void JmsReplyToIgnoredIfIncorrectType() throws JMSException {
void JmsReplyToIgnoredIfIncorrectType() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.REPLY_TO, "not-a-destination").build();
jakarta.jms.Message jmsMessage = new StubTextMessage();
@ -66,7 +65,7 @@ public class SimpleJmsHeaderMapperTests { @@ -66,7 +65,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsCorrelationIdMappedFromHeader() throws JMSException {
void jmsCorrelationIdMappedFromHeader() throws JMSException {
String jmsCorrelationId = "ABC-123";
Message<String> message = initBuilder()
.setHeader(JmsHeaders.CORRELATION_ID, jmsCorrelationId).build();
@ -77,7 +76,7 @@ public class SimpleJmsHeaderMapperTests { @@ -77,7 +76,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsCorrelationIdNumberConvertsToString() throws JMSException {
void jmsCorrelationIdNumberConvertsToString() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.CORRELATION_ID, 123).build();
jakarta.jms.Message jmsMessage = new StubTextMessage();
@ -86,7 +85,7 @@ public class SimpleJmsHeaderMapperTests { @@ -86,7 +85,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsCorrelationIdIgnoredIfIncorrectType() throws JMSException {
void jmsCorrelationIdIgnoredIfIncorrectType() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.CORRELATION_ID, new Date()).build();
jakarta.jms.Message jmsMessage = new StubTextMessage();
@ -95,7 +94,7 @@ public class SimpleJmsHeaderMapperTests { @@ -95,7 +94,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsTypeMappedFromHeader() throws JMSException {
void jmsTypeMappedFromHeader() throws JMSException {
String jmsType = "testing";
Message<String> message = initBuilder()
.setHeader(JmsHeaders.TYPE, jmsType).build();
@ -106,7 +105,7 @@ public class SimpleJmsHeaderMapperTests { @@ -106,7 +105,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsTypeIgnoredIfIncorrectType() throws JMSException {
void jmsTypeIgnoredIfIncorrectType() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.TYPE, 123).build();
jakarta.jms.Message jmsMessage = new StubTextMessage();
@ -115,7 +114,7 @@ public class SimpleJmsHeaderMapperTests { @@ -115,7 +114,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsReadOnlyPropertiesNotMapped() throws JMSException {
void jmsReadOnlyPropertiesNotMapped() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.DESTINATION, new Destination() {})
.setHeader(JmsHeaders.DELIVERY_MODE, DeliveryMode.NON_PERSISTENT)
@ -137,7 +136,7 @@ public class SimpleJmsHeaderMapperTests { @@ -137,7 +136,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void contentTypePropertyMappedFromHeader() throws JMSException {
void contentTypePropertyMappedFromHeader() throws JMSException {
Message<String> message = initBuilder()
.setHeader(MessageHeaders.CONTENT_TYPE, "foo")
.build();
@ -149,20 +148,18 @@ public class SimpleJmsHeaderMapperTests { @@ -149,20 +148,18 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void userDefinedPropertyMappedFromHeader() throws JMSException {
void userDefinedPropertyMappedFromHeader() throws JMSException {
Message<String> message = initBuilder()
.setHeader("foo", 123)
.build();
jakarta.jms.Message jmsMessage = new StubTextMessage();
mapper.fromHeaders(message.getHeaders(), jmsMessage);
Object value = jmsMessage.getObjectProperty("foo");
assertThat(value).isNotNull();
assertThat(value.getClass()).isEqualTo(Integer.class);
assertThat(((Integer) value).intValue()).isEqualTo(123);
assertThat(value).isExactlyInstanceOf(Integer.class).isEqualTo(123);
}
@Test
public void userDefinedPropertyMappedFromHeaderWithCustomPrefix() throws JMSException {
void userDefinedPropertyMappedFromHeaderWithCustomPrefix() throws JMSException {
Message<String> message = initBuilder()
.setHeader("foo", 123)
.build();
@ -170,13 +167,11 @@ public class SimpleJmsHeaderMapperTests { @@ -170,13 +167,11 @@ public class SimpleJmsHeaderMapperTests {
jakarta.jms.Message jmsMessage = new StubTextMessage();
mapper.fromHeaders(message.getHeaders(), jmsMessage);
Object value = jmsMessage.getObjectProperty("custom_foo");
assertThat(value).isNotNull();
assertThat(value.getClass()).isEqualTo(Integer.class);
assertThat(((Integer) value).intValue()).isEqualTo(123);
assertThat(value).isExactlyInstanceOf(Integer.class).isEqualTo(123);
}
@Test
public void userDefinedPropertyWithUnsupportedType() throws JMSException {
void userDefinedPropertyWithUnsupportedType() throws JMSException {
Destination destination = new Destination() {};
Message<String> message = initBuilder()
.setHeader("destination", destination)
@ -188,7 +183,7 @@ public class SimpleJmsHeaderMapperTests { @@ -188,7 +183,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedCorrelationIdPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedCorrelationIdPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public String getJMSCorrelationID() throws JMSException {
@ -199,7 +194,7 @@ public class SimpleJmsHeaderMapperTests { @@ -199,7 +194,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedDestinationPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedDestinationPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public Destination getJMSDestination() throws JMSException {
@ -210,7 +205,7 @@ public class SimpleJmsHeaderMapperTests { @@ -210,7 +205,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedDeliveryModePropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedDeliveryModePropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public int getJMSDeliveryMode() throws JMSException {
@ -221,7 +216,7 @@ public class SimpleJmsHeaderMapperTests { @@ -221,7 +216,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedExpirationPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedExpirationPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public long getJMSExpiration() throws JMSException {
@ -232,7 +227,7 @@ public class SimpleJmsHeaderMapperTests { @@ -232,7 +227,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedMessageIdPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedMessageIdPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public String getJMSMessageID() throws JMSException {
@ -243,7 +238,7 @@ public class SimpleJmsHeaderMapperTests { @@ -243,7 +238,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedPriorityPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedPriorityPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public int getJMSPriority() throws JMSException {
@ -254,7 +249,7 @@ public class SimpleJmsHeaderMapperTests { @@ -254,7 +249,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedReplyToPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedReplyToPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public Destination getJMSReplyTo() throws JMSException {
@ -265,7 +260,7 @@ public class SimpleJmsHeaderMapperTests { @@ -265,7 +260,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedRedeliveredPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedRedeliveredPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public boolean getJMSRedelivered() throws JMSException {
@ -276,7 +271,7 @@ public class SimpleJmsHeaderMapperTests { @@ -276,7 +271,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedTypePropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedTypePropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public String getJMSType() throws JMSException {
@ -287,7 +282,7 @@ public class SimpleJmsHeaderMapperTests { @@ -287,7 +282,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedTimestampPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedTimestampPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public long getJMSTimestamp() throws JMSException {
@ -298,7 +293,7 @@ public class SimpleJmsHeaderMapperTests { @@ -298,7 +293,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToReadDisallowedUserPropertyIsNotFatal() throws JMSException {
void attemptToReadDisallowedUserPropertyIsNotFatal() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public Object getObjectProperty(String name) throws JMSException {
@ -318,7 +313,7 @@ public class SimpleJmsHeaderMapperTests { @@ -318,7 +313,7 @@ public class SimpleJmsHeaderMapperTests {
// Inbound mapping
@Test
public void jmsCorrelationIdMappedToHeader() throws JMSException {
void jmsCorrelationIdMappedToHeader() throws JMSException {
String correlationId = "ABC-123";
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSCorrelationID(correlationId);
@ -326,7 +321,7 @@ public class SimpleJmsHeaderMapperTests { @@ -326,7 +321,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void destinationMappedToHeader() throws JMSException {
void destinationMappedToHeader() throws JMSException {
Destination destination = new Destination() {};
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSDestination(destination);
@ -334,7 +329,7 @@ public class SimpleJmsHeaderMapperTests { @@ -334,7 +329,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsDeliveryModeMappedToHeader() throws JMSException {
void jmsDeliveryModeMappedToHeader() throws JMSException {
int deliveryMode = 1;
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSDeliveryMode(deliveryMode);
@ -342,7 +337,7 @@ public class SimpleJmsHeaderMapperTests { @@ -342,7 +337,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsExpirationMappedToHeader() throws JMSException {
void jmsExpirationMappedToHeader() throws JMSException {
long expiration = 1000L;
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSExpiration(expiration);
@ -350,7 +345,7 @@ public class SimpleJmsHeaderMapperTests { @@ -350,7 +345,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsMessageIdMappedToHeader() throws JMSException {
void jmsMessageIdMappedToHeader() throws JMSException {
String messageId = "ID:ABC-123";
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSMessageID(messageId);
@ -358,7 +353,7 @@ public class SimpleJmsHeaderMapperTests { @@ -358,7 +353,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsPriorityMappedToHeader() throws JMSException {
void jmsPriorityMappedToHeader() throws JMSException {
int priority = 8;
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSPriority(priority);
@ -366,7 +361,7 @@ public class SimpleJmsHeaderMapperTests { @@ -366,7 +361,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsReplyToMappedToHeader() throws JMSException {
void jmsReplyToMappedToHeader() throws JMSException {
Destination replyTo = new Destination() {};
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSReplyTo(replyTo);
@ -374,7 +369,7 @@ public class SimpleJmsHeaderMapperTests { @@ -374,7 +369,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsTypeMappedToHeader() throws JMSException {
void jmsTypeMappedToHeader() throws JMSException {
String type = "testing";
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSType(type);
@ -382,7 +377,7 @@ public class SimpleJmsHeaderMapperTests { @@ -382,7 +377,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void jmsTimestampMappedToHeader() throws JMSException {
void jmsTimestampMappedToHeader() throws JMSException {
long timestamp = 123L;
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setJMSTimestamp(timestamp);
@ -390,21 +385,21 @@ public class SimpleJmsHeaderMapperTests { @@ -390,21 +385,21 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void contentTypePropertyMappedToHeader() throws JMSException {
void contentTypePropertyMappedToHeader() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setStringProperty("content_type", "foo");
assertInboundHeader(jmsMessage, MessageHeaders.CONTENT_TYPE, "foo");
}
@Test
public void userDefinedPropertyMappedToHeader() throws JMSException {
void userDefinedPropertyMappedToHeader() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setIntProperty("foo", 123);
assertInboundHeader(jmsMessage, "foo", 123);
}
@Test
public void userDefinedPropertyMappedToHeaderWithCustomPrefix() throws JMSException {
void userDefinedPropertyMappedToHeaderWithCustomPrefix() throws JMSException {
jakarta.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setIntProperty("foo", 123);
mapper.setInboundPrefix("custom_");
@ -412,7 +407,7 @@ public class SimpleJmsHeaderMapperTests { @@ -412,7 +407,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void propertyMappingExceptionIsNotFatal() throws JMSException {
void propertyMappingExceptionIsNotFatal() throws JMSException {
Message<String> message = initBuilder()
.setHeader("foo", 123)
.setHeader("bad", 456)
@ -437,7 +432,7 @@ public class SimpleJmsHeaderMapperTests { @@ -437,7 +432,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void illegalArgumentExceptionIsNotFatal() throws JMSException {
void illegalArgumentExceptionIsNotFatal() throws JMSException {
Message<String> message = initBuilder()
.setHeader("foo", 123)
.setHeader("bad", 456)
@ -462,7 +457,7 @@ public class SimpleJmsHeaderMapperTests { @@ -462,7 +457,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToWriteDisallowedReplyToPropertyIsNotFatal() throws JMSException {
void attemptToWriteDisallowedReplyToPropertyIsNotFatal() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.REPLY_TO, new Destination() {})
.setHeader("foo", "bar")
@ -480,7 +475,7 @@ public class SimpleJmsHeaderMapperTests { @@ -480,7 +475,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToWriteDisallowedTypePropertyIsNotFatal() throws JMSException {
void attemptToWriteDisallowedTypePropertyIsNotFatal() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.TYPE, "someType")
.setHeader("foo", "bar")
@ -498,7 +493,7 @@ public class SimpleJmsHeaderMapperTests { @@ -498,7 +493,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToWriteDisallowedCorrelationIdStringPropertyIsNotFatal() throws JMSException {
void attemptToWriteDisallowedCorrelationIdStringPropertyIsNotFatal() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.CORRELATION_ID, "abc")
.setHeader("foo", "bar")
@ -516,7 +511,7 @@ public class SimpleJmsHeaderMapperTests { @@ -516,7 +511,7 @@ public class SimpleJmsHeaderMapperTests {
}
@Test
public void attemptToWriteDisallowedCorrelationIdNumberPropertyIsNotFatal() throws JMSException {
void attemptToWriteDisallowedCorrelationIdNumberPropertyIsNotFatal() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.CORRELATION_ID, 123)
.setHeader("foo", "bar")

8
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/AbstractDatabaseClientIntegrationTests.java

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Paluch
* @author Mingyuan Wu
*/
public abstract class AbstractDatabaseClientIntegrationTests {
abstract class AbstractDatabaseClientIntegrationTests {
private ConnectionFactory connectionFactory;
@ -88,10 +88,8 @@ public abstract class AbstractDatabaseClientIntegrationTests { @@ -88,10 +88,8 @@ public abstract class AbstractDatabaseClientIntegrationTests {
.map(row -> row.get("id"))
.first()
.as(StepVerifier::create)
.assertNext(actual -> {
assertThat(actual).isInstanceOf(Number.class);
assertThat(((Number) actual).intValue()).isEqualTo(42055);
}).verifyComplete();
.assertNext(actual -> assertThat(actual).isInstanceOf(Number.class).isEqualTo(42055))
.verifyComplete();
}
@Test

6
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/AbstractTransactionalDatabaseClientIntegrationTests.java

@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Paluch
* @author Christoph Strobl
*/
public abstract class AbstractTransactionalDatabaseClientIntegrationTests {
abstract class AbstractTransactionalDatabaseClientIntegrationTests {
private ConnectionFactory connectionFactory;
@ -184,8 +184,8 @@ public abstract class AbstractTransactionalDatabaseClientIntegrationTests { @@ -184,8 +184,8 @@ public abstract class AbstractTransactionalDatabaseClientIntegrationTests {
}
private Condition<? super Object> numberOf(int expected) {
return new Condition<>(object -> object instanceof Number &&
((Number) object).intValue() == expected, "Number %d", expected);
return new Condition<>(object -> object instanceof Number num &&
num.intValue() == expected, "Number %d", expected);
}

13
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/H2DatabaseClientIntegrationTests.java

@ -26,12 +26,13 @@ import io.r2dbc.spi.ConnectionFactory; @@ -26,12 +26,13 @@ import io.r2dbc.spi.ConnectionFactory;
*/
public class H2DatabaseClientIntegrationTests extends AbstractDatabaseClientIntegrationTests {
public static String CREATE_TABLE_LEGOSET = "CREATE TABLE legoset (\n" //
+ " id serial CONSTRAINT id PRIMARY KEY,\n" //
+ " version integer NULL,\n" //
+ " name varchar(255) NOT NULL,\n" //
+ " manual integer NULL\n" //
+ ");";
private static final String CREATE_TABLE_LEGOSET = """
CREATE TABLE legoset (
id serial CONSTRAINT id PRIMARY KEY,
version integer NULL,
name varchar(255) NOT NULL,
manual integer NULL
);""";
@Override
protected ConnectionFactory createConnectionFactory() {

13
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/H2TransactionalDatabaseClientIntegrationTests.java

@ -26,12 +26,13 @@ import io.r2dbc.spi.ConnectionFactory; @@ -26,12 +26,13 @@ import io.r2dbc.spi.ConnectionFactory;
*/
public class H2TransactionalDatabaseClientIntegrationTests extends AbstractTransactionalDatabaseClientIntegrationTests {
public static String CREATE_TABLE_LEGOSET = "CREATE TABLE legoset (\n" //
+ " id integer CONSTRAINT id PRIMARY KEY,\n" //
+ " version integer NULL,\n" //
+ " name varchar(255) NOT NULL,\n" //
+ " manual integer NULL\n" //
+ ");";
private static final String CREATE_TABLE_LEGOSET = """
CREATE TABLE legoset (
id serial CONSTRAINT id PRIMARY KEY,
version integer NULL,
name varchar(255) NOT NULL,
manual integer NULL
);""";
@Override
protected ConnectionFactory createConnectionFactory() {

2
spring-test/src/test/java/org/springframework/test/context/cache/MethodLevelDirtiesContextTests.java vendored

@ -91,7 +91,7 @@ class MethodLevelDirtiesContextTests { @@ -91,7 +91,7 @@ class MethodLevelDirtiesContextTests {
assertThat(this.context.isActive()).as("context must be active").isTrue();
assertThat(this.count).as("count must not be null").isNotNull();
assertThat(this.count.intValue()).as("count: ").isEqualTo(expectedContextCreationCount);
assertThat(this.count).as("count").isEqualTo(expectedContextCreationCount);
assertThat(contextCount.get()).as("context creation count: ").isEqualTo(expectedContextCreationCount);
}

2
spring-test/src/test/java/org/springframework/test/context/env/MergedPropertiesFilesTestPropertySourceTests.java vendored

@ -35,7 +35,7 @@ class MergedPropertiesFilesTestPropertySourceTests extends @@ -35,7 +35,7 @@ class MergedPropertiesFilesTestPropertySourceTests extends
@Test
void verifyExtendedPropertiesAreAvailableInEnvironment() {
assertThat(env.getProperty("extended", Integer.class).intValue()).isEqualTo(42);
assertThat(env.getProperty("extended", Integer.class)).isEqualTo(42);
}
}

6
spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java

@ -325,7 +325,7 @@ class ReflectionTestUtilsTests { @@ -325,7 +325,7 @@ class ReflectionTestUtilsTests {
void invokeMethodWithAutoboxingAndUnboxing() {
// IntelliJ IDEA 11 won't accept int assignment here
Integer difference = invokeMethod(component, "subtract", 5, 2);
assertThat(difference.intValue()).as("subtract(5, 2)").isEqualTo(3);
assertThat(difference).as("subtract(5, 2)").isEqualTo(3);
}
@Test
@ -333,14 +333,14 @@ class ReflectionTestUtilsTests { @@ -333,14 +333,14 @@ class ReflectionTestUtilsTests {
void invokeMethodWithPrimitiveVarArgs() {
// IntelliJ IDEA 11 won't accept int assignment here
Integer sum = invokeMethod(component, "add", 1, 2, 3, 4);
assertThat(sum.intValue()).as("add(1,2,3,4)").isEqualTo(10);
assertThat(sum).as("add(1,2,3,4)").isEqualTo(10);
}
@Test
void invokeMethodWithPrimitiveVarArgsAsSingleArgument() {
// IntelliJ IDEA 11 won't accept int assignment here
Integer sum = invokeMethod(component, "add", new int[] { 1, 2, 3, 4 });
assertThat(sum.intValue()).as("add(1,2,3,4)").isEqualTo(10);
assertThat(sum).as("add(1,2,3,4)").isEqualTo(10);
}
@Test

10
spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java

@ -79,15 +79,15 @@ public class SessionScopeTests { @@ -79,15 +79,15 @@ public class SessionScopeTests {
String name = "sessionScopedObject";
assertThat(session.getAttribute(name)).isNull();
TestBean bean = (TestBean) this.beanFactory.getBean(name);
assertThat(count.intValue()).isEqualTo(1);
assertThat(count.get()).isEqualTo(1);
assertThat(bean).isEqualTo(session.getAttribute(name));
assertThat(this.beanFactory.getBean(name)).isSameAs(bean);
assertThat(count.intValue()).isEqualTo(1);
assertThat(count.get()).isEqualTo(1);
// should re-propagate updated attribute
requestAttributes.requestCompleted();
assertThat(bean).isEqualTo(session.getAttribute(name));
assertThat(count.intValue()).isEqualTo(2);
assertThat(count.get()).isEqualTo(2);
}
@Test
@ -108,12 +108,12 @@ public class SessionScopeTests { @@ -108,12 +108,12 @@ public class SessionScopeTests {
String name = "sessionScopedObject";
assertThat(session.getAttribute(name)).isNull();
TestBean bean = (TestBean) this.beanFactory.getBean(name);
assertThat(count.intValue()).isEqualTo(1);
assertThat(count.get()).isEqualTo(1);
// should re-propagate updated attribute
requestAttributes.requestCompleted();
assertThat(bean).isEqualTo(session.getAttribute(name));
assertThat(count.intValue()).isEqualTo(2);
assertThat(count.get()).isEqualTo(2);
}
@Test

53
spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java

@ -65,7 +65,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -65,7 +65,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 18.06.2003
*/
@SuppressWarnings("deprecation")
public class ViewResolverTests {
class ViewResolverTests {
private final StaticWebApplicationContext wac = new StaticWebApplicationContext();
private final MockServletContext sc = new MockServletContext();
@ -73,12 +73,12 @@ public class ViewResolverTests { @@ -73,12 +73,12 @@ public class ViewResolverTests {
private final HttpServletResponse response = new MockHttpServletResponse();
@BeforeEach
public void setUp() {
void setUp() {
this.wac.setServletContext(this.sc);
}
@Test
public void beanNameViewResolver() {
void beanNameViewResolver() {
MutablePropertyValues pvs1 = new MutablePropertyValues();
pvs1.addPropertyValue(new PropertyValue("url", "/example1.jsp"));
this.wac.registerSingleton("example1", InternalResourceView.class, pvs1);
@ -99,7 +99,7 @@ public class ViewResolverTests { @@ -99,7 +99,7 @@ public class ViewResolverTests {
}
@Test
public void urlBasedViewResolverOverridesCustomRequestContextAttributeWithNonNullValue() throws Exception {
void urlBasedViewResolverOverridesCustomRequestContextAttributeWithNonNullValue() throws Exception {
assertThat(new TestView().getRequestContextAttribute())
.as("requestContextAttribute when instantiated directly")
.isEqualTo("testRequestContext");
@ -118,7 +118,7 @@ public class ViewResolverTests { @@ -118,7 +118,7 @@ public class ViewResolverTests {
}
@Test
public void urlBasedViewResolverDoesNotOverrideCustomRequestContextAttributeWithNull() throws Exception {
void urlBasedViewResolverDoesNotOverrideCustomRequestContextAttributeWithNull() throws Exception {
assertThat(new TestView().getRequestContextAttribute())
.as("requestContextAttribute when instantiated directly")
.isEqualTo("testRequestContext");
@ -136,26 +136,26 @@ public class ViewResolverTests { @@ -136,26 +136,26 @@ public class ViewResolverTests {
}
@Test
public void urlBasedViewResolverWithoutPrefixes() throws Exception {
void urlBasedViewResolverWithoutPrefixes() throws Exception {
UrlBasedViewResolver vr = new UrlBasedViewResolver();
vr.setViewClass(JstlView.class);
doTestUrlBasedViewResolverWithoutPrefixes(vr);
}
@Test
public void urlBasedViewResolverWithPrefixes() throws Exception {
void urlBasedViewResolverWithPrefixes() throws Exception {
UrlBasedViewResolver vr = new UrlBasedViewResolver();
vr.setViewClass(JstlView.class);
doTestUrlBasedViewResolverWithPrefixes(vr);
}
@Test
public void internalResourceViewResolverWithoutPrefixes() throws Exception {
void internalResourceViewResolverWithoutPrefixes() throws Exception {
doTestUrlBasedViewResolverWithoutPrefixes(new InternalResourceViewResolver());
}
@Test
public void internalResourceViewResolverWithPrefixes() throws Exception {
void internalResourceViewResolverWithPrefixes() throws Exception {
doTestUrlBasedViewResolverWithPrefixes(new InternalResourceViewResolver());
}
@ -220,7 +220,7 @@ public class ViewResolverTests { @@ -220,7 +220,7 @@ public class ViewResolverTests {
}
@Test
public void internalResourceViewResolverWithAttributes() throws Exception {
void internalResourceViewResolverWithAttributes() throws Exception {
this.wac.refresh();
InternalResourceViewResolver vr = new InternalResourceViewResolver();
Properties props = new Properties();
@ -259,7 +259,7 @@ public class ViewResolverTests { @@ -259,7 +259,7 @@ public class ViewResolverTests {
}
@Test
public void internalResourceViewResolverWithContextBeans() throws Exception {
void internalResourceViewResolverWithContextBeans() throws Exception {
this.wac.registerSingleton("myBean", TestBean.class);
this.wac.registerSingleton("myBean2", TestBean.class);
this.wac.refresh();
@ -295,7 +295,7 @@ public class ViewResolverTests { @@ -295,7 +295,7 @@ public class ViewResolverTests {
}
@Test
public void internalResourceViewResolverWithSpecificContextBeans() throws Exception {
void internalResourceViewResolverWithSpecificContextBeans() throws Exception {
this.wac.registerSingleton("myBean", TestBean.class);
this.wac.registerSingleton("myBean2", TestBean.class);
this.wac.refresh();
@ -331,7 +331,7 @@ public class ViewResolverTests { @@ -331,7 +331,7 @@ public class ViewResolverTests {
}
@Test
public void internalResourceViewResolverWithJstl() throws Exception {
void internalResourceViewResolverWithJstl() throws Exception {
Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH;
this.wac.addMessage("code1", locale, "messageX");
@ -364,7 +364,7 @@ public class ViewResolverTests { @@ -364,7 +364,7 @@ public class ViewResolverTests {
}
@Test
public void internalResourceViewResolverWithJstlAndContextParam() throws Exception {
void internalResourceViewResolverWithJstlAndContextParam() throws Exception {
Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH;
this.sc.addInitParameter(Config.FMT_LOCALIZATION_CONTEXT, "org/springframework/web/context/WEB-INF/context-messages");
@ -400,7 +400,7 @@ public class ViewResolverTests { @@ -400,7 +400,7 @@ public class ViewResolverTests {
@Test
@SuppressWarnings("deprecation")
public void xmlViewResolver() throws Exception {
void xmlViewResolver() throws Exception {
this.wac.registerSingleton("testBean", TestBean.class);
this.wac.refresh();
TestBean testBean = (TestBean) this.wac.getBean("testBean");
@ -440,7 +440,7 @@ public class ViewResolverTests { @@ -440,7 +440,7 @@ public class ViewResolverTests {
@Test
@SuppressWarnings("deprecation")
public void xmlViewResolverDefaultLocation() {
void xmlViewResolverDefaultLocation() {
StaticWebApplicationContext wac = new StaticWebApplicationContext() {
@Override
protected Resource getResourceByPath(String path) {
@ -457,7 +457,7 @@ public class ViewResolverTests { @@ -457,7 +457,7 @@ public class ViewResolverTests {
@Test
@SuppressWarnings("deprecation")
public void xmlViewResolverWithoutCache() throws Exception {
void xmlViewResolverWithoutCache() throws Exception {
StaticWebApplicationContext wac = new StaticWebApplicationContext() {
@Override
protected Resource getResourceByPath(String path) {
@ -475,7 +475,7 @@ public class ViewResolverTests { @@ -475,7 +475,7 @@ public class ViewResolverTests {
}
@Test
public void cacheRemoval() throws Exception {
void cacheRemoval() throws Exception {
this.wac.refresh();
InternalResourceViewResolver vr = new InternalResourceViewResolver();
vr.setViewClass(JstlView.class);
@ -492,7 +492,7 @@ public class ViewResolverTests { @@ -492,7 +492,7 @@ public class ViewResolverTests {
}
@Test
public void cacheUnresolved() throws Exception {
void cacheUnresolved() throws Exception {
final AtomicInteger count = new AtomicInteger();
AbstractCachingViewResolver viewResolver = new AbstractCachingViewResolver() {
@Override
@ -507,7 +507,7 @@ public class ViewResolverTests { @@ -507,7 +507,7 @@ public class ViewResolverTests {
viewResolver.resolveViewName("view", Locale.getDefault());
viewResolver.resolveViewName("view", Locale.getDefault());
assertThat(count.intValue()).isEqualTo(2);
assertThat(count.get()).isEqualTo(2);
viewResolver.setCacheUnresolved(true);
@ -517,11 +517,11 @@ public class ViewResolverTests { @@ -517,11 +517,11 @@ public class ViewResolverTests {
viewResolver.resolveViewName("view", Locale.getDefault());
viewResolver.resolveViewName("view", Locale.getDefault());
assertThat(count.intValue()).isEqualTo(3);
assertThat(count.get()).isEqualTo(3);
}
@Test
public void cacheFilterEnabled() throws Exception {
void cacheFilterEnabled() throws Exception {
AtomicInteger count = new AtomicInteger();
// filter is enabled by default
@ -538,11 +538,11 @@ public class ViewResolverTests { @@ -538,11 +538,11 @@ public class ViewResolverTests {
viewResolver.resolveViewName("view", Locale.getDefault());
viewResolver.resolveViewName("view", Locale.getDefault());
assertThat(count.intValue()).isEqualTo(1);
assertThat(count.get()).isEqualTo(1);
}
@Test
public void cacheFilterDisabled() throws Exception {
void cacheFilterDisabled() throws Exception {
AtomicInteger count = new AtomicInteger();
AbstractCachingViewResolver viewResolver = new AbstractCachingViewResolver() {
@ -558,16 +558,17 @@ public class ViewResolverTests { @@ -558,16 +558,17 @@ public class ViewResolverTests {
viewResolver.resolveViewName("view", Locale.getDefault());
viewResolver.resolveViewName("view", Locale.getDefault());
assertThat(count.intValue()).isEqualTo(2);
assertThat(count.get()).isEqualTo(2);
}
public static class TestView extends InternalResourceView {
private static class TestView extends InternalResourceView {
public TestView() {
setRequestContextAttribute("testRequestContext");
}
@SuppressWarnings("unused")
public void setLocation(Resource location) {
if (!(location instanceof ServletContextResource)) {
throw new IllegalArgumentException("Expecting ServletContextResource, not " + location.getClass().getName());

Loading…
Cancel
Save