Browse Source

Polishing

pull/1918/merge
Juergen Hoeller 6 years ago
parent
commit
58e9706991
  1. 24
      spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java
  2. 5
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java
  3. 36
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java
  4. 1
      src/docs/asciidoc/web/webmvc-view.adoc

24
spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java

@ -177,13 +177,15 @@ public class JdbcTemplateTests { @@ -177,13 +177,15 @@ public class JdbcTemplateTests {
@Test
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
public void testStringsWithPreparedStatementArgs() throws Exception {
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,
@ -363,7 +365,7 @@ public class JdbcTemplateTests { @@ -363,7 +365,7 @@ public class JdbcTemplateTests {
given(this.preparedStatement.executeUpdate()).willReturn(rowsAffected);
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);
verify(this.preparedStatement).setObject(1, 4);
verify(this.preparedStatement).setObject(2, Float.valueOf(1.4142f), Types.NUMERIC, 2);
@ -428,8 +430,7 @@ public class JdbcTemplateTests { @@ -428,8 +430,7 @@ public class JdbcTemplateTests {
public void testBatchUpdateWithBatchFailure() throws Exception {
final String[] sql = {"A", "B", "C", "D"};
given(this.statement.executeBatch()).willThrow(
new BatchUpdateException(new int[] { 1, Statement.EXECUTE_FAILED, 1,
Statement.EXECUTE_FAILED }));
new BatchUpdateException(new int[] {1, Statement.EXECUTE_FAILED, 1, Statement.EXECUTE_FAILED}));
mockDatabaseMetaData(true);
given(this.connection.createStatement()).willReturn(this.statement);
@ -496,11 +497,9 @@ public class JdbcTemplateTests { @@ -496,11 +497,9 @@ public class JdbcTemplateTests {
given(this.preparedStatement.executeBatch()).willReturn(rowsAffected);
mockDatabaseMetaData(true);
BatchPreparedStatementSetter setter =
new BatchPreparedStatementSetter() {
BatchPreparedStatementSetter setter = new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i)
throws SQLException {
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setInt(1, ids[i]);
}
@Override
@ -1050,10 +1049,9 @@ public class JdbcTemplateTests { @@ -1050,10 +1049,9 @@ public class JdbcTemplateTests {
}
try {
this.template.query(con -> con.prepareStatement("my query"),
(ResultSetExtractor<Object>) rs2 -> {
throw new InvalidDataAccessApiUsageException("");
} );
this.template.query(con -> con.prepareStatement("my query"), (ResultSetExtractor<Object>) rs2 -> {
throw new InvalidDataAccessApiUsageException("");
});
fail("Should have thrown InvalidDataAccessApiUsageException");
}
catch (InvalidDataAccessApiUsageException ex) {

5
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java

@ -71,13 +71,13 @@ class ControllerMethodResolver { @@ -71,13 +71,13 @@ class ControllerMethodResolver {
/**
* 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);
/**
* 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, ModelAttribute.class));
@ -217,7 +217,6 @@ class ControllerMethodResolver { @@ -217,7 +217,6 @@ class ControllerMethodResolver {
}
private void initControllerAdviceCaches(ApplicationContext applicationContext) {
List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(applicationContext);
AnnotationAwareOrderComparator.sort(beans);

36
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -66,31 +66,29 @@ public class HandlerMethodAnnotationDetectionTests { @@ -66,31 +66,29 @@ public class HandlerMethodAnnotationDetectionTests {
@Parameters(name = "controller [{0}], auto-proxy [{1}]")
public static Object[][] handlerTypes() {
return new Object[][] {
{ SimpleController.class, true }, // CGLIB proxy
{ SimpleController.class, false },
{ SimpleController.class, true }, // CGLIB proxy
{ SimpleController.class, false },
{ AbstractClassController.class, true }, // CGLIB proxy
{ AbstractClassController.class, false },
{ AbstractClassController.class, true }, // CGLIB proxy
{ AbstractClassController.class, false },
{ ParameterizedAbstractClassController.class, true }, // CGLIB proxy
{ ParameterizedAbstractClassController.class, false },
{ ParameterizedAbstractClassController.class, true }, // CGLIB proxy
{ ParameterizedAbstractClassController.class, false },
{ ParameterizedSubclassOverridesDefaultMappings.class, true }, // CGLIB proxy
{ ParameterizedSubclassOverridesDefaultMappings.class, false },
{ ParameterizedSubclassOverridesDefaultMappings.class, true }, // CGLIB proxy
{ ParameterizedSubclassOverridesDefaultMappings.class, false },
// TODO [SPR-9517] Enable ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass test cases
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true }, // CGLIB proxy
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, false },
// TODO [SPR-9517] Enable ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass test cases
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true }, // CGLIB proxy
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, false },
{ InterfaceController.class, true }, // JDK dynamic proxy
{ InterfaceController.class, false },
{ InterfaceController.class, true }, // JDK dynamic proxy
{ InterfaceController.class, false },
{ ParameterizedInterfaceController.class, false }, // no AOP
{ SupportClassController.class, true }, // CGLIB proxy
{ SupportClassController.class, false }
{ ParameterizedInterfaceController.class, false }, // no AOP
{ SupportClassController.class, true }, // CGLIB proxy
{ SupportClassController.class, false }
};
}

1
src/docs/asciidoc/web/webmvc-view.adoc

@ -2031,6 +2031,7 @@ through the `ObjectMapper` property for cases where custom JSON @@ -2031,6 +2031,7 @@ through the `ObjectMapper` property for cases where custom JSON
serializers/deserializers need to be provided for specific types.
[[mvc-view-xml-mapping]]
=== XML
[.small]#<<web-reactive.adoc#webflux-view-httpmessagewriter,Same in Spring WebFlux>>#

Loading…
Cancel
Save