Polishing
This commit is contained in:
parent
65f29a39ca
commit
58e9706991
|
|
@ -177,13 +177,15 @@ public class JdbcTemplateTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStringsWithEmptyPreparedStatementArgs() throws Exception {
|
public void testStringsWithEmptyPreparedStatementArgs() throws Exception {
|
||||||
doTestStrings(null, null, null, null, (template, sql, rch) -> template.query(sql, (Object[]) null, rch));
|
doTestStrings(null, null, null, null,
|
||||||
|
(template, sql, rch) -> template.query(sql, (Object[]) null, rch));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStringsWithPreparedStatementArgs() throws Exception {
|
public void testStringsWithPreparedStatementArgs() throws Exception {
|
||||||
final Integer argument = 99;
|
final Integer argument = 99;
|
||||||
doTestStrings(null, null, null, argument, (template, sql, rch) -> template.query(sql, new Object[] { argument }, rch));
|
doTestStrings(null, null, null, argument,
|
||||||
|
(template, sql, rch) -> template.query(sql, new Object[] {argument}, rch));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestStrings(Integer fetchSize, Integer maxRows, Integer queryTimeout,
|
private void doTestStrings(Integer fetchSize, Integer maxRows, Integer queryTimeout,
|
||||||
|
|
@ -363,7 +365,7 @@ public class JdbcTemplateTests {
|
||||||
given(this.preparedStatement.executeUpdate()).willReturn(rowsAffected);
|
given(this.preparedStatement.executeUpdate()).willReturn(rowsAffected);
|
||||||
|
|
||||||
int actualRowsAffected = this.template.update(sql,
|
int actualRowsAffected = this.template.update(sql,
|
||||||
new Object[] {4, new SqlParameterValue(Types.NUMERIC, 2, Float.valueOf(1.4142f))});
|
4, new SqlParameterValue(Types.NUMERIC, 2, Float.valueOf(1.4142f)));
|
||||||
assertTrue("Actual rows affected is correct", actualRowsAffected == rowsAffected);
|
assertTrue("Actual rows affected is correct", actualRowsAffected == rowsAffected);
|
||||||
verify(this.preparedStatement).setObject(1, 4);
|
verify(this.preparedStatement).setObject(1, 4);
|
||||||
verify(this.preparedStatement).setObject(2, Float.valueOf(1.4142f), Types.NUMERIC, 2);
|
verify(this.preparedStatement).setObject(2, Float.valueOf(1.4142f), Types.NUMERIC, 2);
|
||||||
|
|
@ -428,8 +430,7 @@ public class JdbcTemplateTests {
|
||||||
public void testBatchUpdateWithBatchFailure() throws Exception {
|
public void testBatchUpdateWithBatchFailure() throws Exception {
|
||||||
final String[] sql = {"A", "B", "C", "D"};
|
final String[] sql = {"A", "B", "C", "D"};
|
||||||
given(this.statement.executeBatch()).willThrow(
|
given(this.statement.executeBatch()).willThrow(
|
||||||
new BatchUpdateException(new int[] { 1, Statement.EXECUTE_FAILED, 1,
|
new BatchUpdateException(new int[] {1, Statement.EXECUTE_FAILED, 1, Statement.EXECUTE_FAILED}));
|
||||||
Statement.EXECUTE_FAILED }));
|
|
||||||
mockDatabaseMetaData(true);
|
mockDatabaseMetaData(true);
|
||||||
given(this.connection.createStatement()).willReturn(this.statement);
|
given(this.connection.createStatement()).willReturn(this.statement);
|
||||||
|
|
||||||
|
|
@ -496,11 +497,9 @@ public class JdbcTemplateTests {
|
||||||
given(this.preparedStatement.executeBatch()).willReturn(rowsAffected);
|
given(this.preparedStatement.executeBatch()).willReturn(rowsAffected);
|
||||||
mockDatabaseMetaData(true);
|
mockDatabaseMetaData(true);
|
||||||
|
|
||||||
BatchPreparedStatementSetter setter =
|
BatchPreparedStatementSetter setter = new BatchPreparedStatementSetter() {
|
||||||
new BatchPreparedStatementSetter() {
|
|
||||||
@Override
|
@Override
|
||||||
public void setValues(PreparedStatement ps, int i)
|
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||||
throws SQLException {
|
|
||||||
ps.setInt(1, ids[i]);
|
ps.setInt(1, ids[i]);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1050,8 +1049,7 @@ public class JdbcTemplateTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.template.query(con -> con.prepareStatement("my query"),
|
this.template.query(con -> con.prepareStatement("my query"), (ResultSetExtractor<Object>) rs2 -> {
|
||||||
(ResultSetExtractor<Object>) rs2 -> {
|
|
||||||
throw new InvalidDataAccessApiUsageException("");
|
throw new InvalidDataAccessApiUsageException("");
|
||||||
});
|
});
|
||||||
fail("Should have thrown InvalidDataAccessApiUsageException");
|
fail("Should have thrown InvalidDataAccessApiUsageException");
|
||||||
|
|
|
||||||
|
|
@ -71,13 +71,13 @@ class ControllerMethodResolver {
|
||||||
/**
|
/**
|
||||||
* MethodFilter that matches {@link InitBinder @InitBinder} methods.
|
* MethodFilter that matches {@link InitBinder @InitBinder} methods.
|
||||||
*/
|
*/
|
||||||
public static final MethodFilter INIT_BINDER_METHODS = method ->
|
private static final MethodFilter INIT_BINDER_METHODS = method ->
|
||||||
AnnotatedElementUtils.hasAnnotation(method, InitBinder.class);
|
AnnotatedElementUtils.hasAnnotation(method, InitBinder.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MethodFilter that matches {@link ModelAttribute @ModelAttribute} methods.
|
* MethodFilter that matches {@link ModelAttribute @ModelAttribute} methods.
|
||||||
*/
|
*/
|
||||||
public static final MethodFilter MODEL_ATTRIBUTE_METHODS = method ->
|
private static final MethodFilter MODEL_ATTRIBUTE_METHODS = method ->
|
||||||
(!AnnotatedElementUtils.hasAnnotation(method, RequestMapping.class) &&
|
(!AnnotatedElementUtils.hasAnnotation(method, RequestMapping.class) &&
|
||||||
AnnotatedElementUtils.hasAnnotation(method, ModelAttribute.class));
|
AnnotatedElementUtils.hasAnnotation(method, ModelAttribute.class));
|
||||||
|
|
||||||
|
|
@ -217,7 +217,6 @@ class ControllerMethodResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initControllerAdviceCaches(ApplicationContext applicationContext) {
|
private void initControllerAdviceCaches(ApplicationContext applicationContext) {
|
||||||
|
|
||||||
List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(applicationContext);
|
List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(applicationContext);
|
||||||
AnnotationAwareOrderComparator.sort(beans);
|
AnnotationAwareOrderComparator.sort(beans);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -66,7 +66,6 @@ public class HandlerMethodAnnotationDetectionTests {
|
||||||
@Parameters(name = "controller [{0}], auto-proxy [{1}]")
|
@Parameters(name = "controller [{0}], auto-proxy [{1}]")
|
||||||
public static Object[][] handlerTypes() {
|
public static Object[][] handlerTypes() {
|
||||||
return new Object[][] {
|
return new Object[][] {
|
||||||
|
|
||||||
{ SimpleController.class, true }, // CGLIB proxy
|
{ SimpleController.class, true }, // CGLIB proxy
|
||||||
{ SimpleController.class, false },
|
{ SimpleController.class, false },
|
||||||
|
|
||||||
|
|
@ -90,7 +89,6 @@ public class HandlerMethodAnnotationDetectionTests {
|
||||||
|
|
||||||
{ SupportClassController.class, true }, // CGLIB proxy
|
{ SupportClassController.class, true }, // CGLIB proxy
|
||||||
{ SupportClassController.class, false }
|
{ SupportClassController.class, false }
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2031,6 +2031,7 @@ through the `ObjectMapper` property for cases where custom JSON
|
||||||
serializers/deserializers need to be provided for specific types.
|
serializers/deserializers need to be provided for specific types.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[mvc-view-xml-mapping]]
|
[[mvc-view-xml-mapping]]
|
||||||
=== XML
|
=== XML
|
||||||
[.small]#<<web-reactive.adoc#webflux-view-httpmessagewriter,Same in Spring WebFlux>>#
|
[.small]#<<web-reactive.adoc#webflux-view-httpmessagewriter,Same in Spring WebFlux>>#
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue