Rely on auto-boxing in tests
This commit is contained in:
parent
1edc0d8002
commit
68f2b0ca59
|
|
@ -667,22 +667,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
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
|
||||
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 {
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
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 {
|
|||
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 {
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
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 {
|
|||
|
||||
// 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 {
|
|||
|
||||
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}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
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 {
|
|||
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 {
|
|||
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 {
|
|||
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 {
|
|||
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 {
|
|||
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 {
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
"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 {
|
|||
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 {
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
@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 {
|
|||
@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
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
// 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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
// 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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void attemptToWriteDisallowedCorrelationIdNumberPropertyIsNotFatal() throws JMSException {
|
||||
void attemptToWriteDisallowedCorrelationIdNumberPropertyIsNotFatal() throws JMSException {
|
||||
Message<String> message = initBuilder()
|
||||
.setHeader(JmsHeaders.CORRELATION_ID, 123)
|
||||
.setHeader("foo", "bar")
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
.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
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
|
||||
@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 {
|
|||
|
||||
@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 {
|
|||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
}
|
||||
|
||||
@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 {
|
|||
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 {
|
|||
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 {
|
|||
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 {
|
|||
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…
Reference in New Issue