Browse Source

Polishing

(cherry picked from commit 1b728fb)
pull/1867/head
Juergen Hoeller 8 years ago
parent
commit
af0a82931e
  1. 27
      spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/ValidatorFactoryTests.java
  2. 13
      spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicatePostProcessingTests.java
  3. 27
      spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java
  4. 31
      src/docs/asciidoc/data-access.adoc

27
spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/ValidatorFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@ -61,7 +61,7 @@ import static org.junit.Assert.*; @@ -61,7 +61,7 @@ import static org.junit.Assert.*;
public class ValidatorFactoryTests {
@Test
public void testSimpleValidation() throws Exception {
public void testSimpleValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -87,7 +87,7 @@ public class ValidatorFactoryTests { @@ -87,7 +87,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSimpleValidationWithCustomProvider() throws Exception {
public void testSimpleValidationWithCustomProvider() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.setProviderClass(HibernateValidator.class);
validator.afterPropertiesSet();
@ -114,9 +114,10 @@ public class ValidatorFactoryTests { @@ -114,9 +114,10 @@ public class ValidatorFactoryTests {
}
@Test
public void testSimpleValidationWithClassLevel() throws Exception {
public void testSimpleValidationWithClassLevel() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
ValidPerson person = new ValidPerson();
person.setName("Juergen");
person.getAddress().setStreet("Juergen's Street");
@ -129,7 +130,7 @@ public class ValidatorFactoryTests { @@ -129,7 +130,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationFieldType() throws Exception {
public void testSpringValidationFieldType() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -144,7 +145,7 @@ public class ValidatorFactoryTests { @@ -144,7 +145,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidation() throws Exception {
public void testSpringValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -172,7 +173,7 @@ public class ValidatorFactoryTests { @@ -172,7 +173,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationWithClassLevel() throws Exception {
public void testSpringValidationWithClassLevel() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -190,7 +191,7 @@ public class ValidatorFactoryTests { @@ -190,7 +191,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationWithAutowiredValidator() throws Exception {
public void testSpringValidationWithAutowiredValidator() {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(
LocalValidatorFactoryBean.class);
LocalValidatorFactoryBean validator = ctx.getBean(LocalValidatorFactoryBean.class);
@ -211,7 +212,7 @@ public class ValidatorFactoryTests { @@ -211,7 +212,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationWithErrorInListElement() throws Exception {
public void testSpringValidationWithErrorInListElement() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -229,7 +230,7 @@ public class ValidatorFactoryTests { @@ -229,7 +230,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationWithErrorInSetElement() throws Exception {
public void testSpringValidationWithErrorInSetElement() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -247,7 +248,7 @@ public class ValidatorFactoryTests { @@ -247,7 +248,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testInnerBeanValidation() throws Exception {
public void testInnerBeanValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -259,7 +260,7 @@ public class ValidatorFactoryTests { @@ -259,7 +260,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testValidationWithOptionalField() throws Exception {
public void testValidationWithOptionalField() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -271,7 +272,7 @@ public class ValidatorFactoryTests { @@ -271,7 +272,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testListValidation() throws Exception {
public void testListValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();

13
spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicatePostProcessingTests.java

@ -18,7 +18,6 @@ package org.springframework.context.annotation.configuration; @@ -18,7 +18,6 @@ package org.springframework.context.annotation.configuration;
import org.junit.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.FactoryBean;
@ -67,7 +66,7 @@ public class DuplicatePostProcessingTests { @@ -67,7 +66,7 @@ public class DuplicatePostProcessingTests {
private final ExampleBean exampleBean = new ExampleBean();
@Override
public ExampleBean getObject() throws Exception {
public ExampleBean getObject() {
return this.exampleBean;
}
@ -87,14 +86,13 @@ public class DuplicatePostProcessingTests { @@ -87,14 +86,13 @@ public class DuplicatePostProcessingTests {
private ApplicationContext applicationContext;
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
public Object postProcessBeforeInitialization(Object bean, String beanName) {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof ExampleBean) {
this.applicationContext.publishEvent(new ExampleApplicationEvent(this));
}
@ -102,12 +100,13 @@ public class DuplicatePostProcessingTests { @@ -102,12 +100,13 @@ public class DuplicatePostProcessingTests {
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
}
@SuppressWarnings("serial")
static class ExampleApplicationEvent extends ApplicationEvent {
public ExampleApplicationEvent(Object source) {
@ -126,7 +125,7 @@ public class DuplicatePostProcessingTests { @@ -126,7 +125,7 @@ public class DuplicatePostProcessingTests {
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
}

27
spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@ -60,7 +60,7 @@ import static org.junit.Assert.*; @@ -60,7 +60,7 @@ import static org.junit.Assert.*;
public class ValidatorFactoryTests {
@Test
public void testSimpleValidation() throws Exception {
public void testSimpleValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -86,7 +86,7 @@ public class ValidatorFactoryTests { @@ -86,7 +86,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSimpleValidationWithCustomProvider() throws Exception {
public void testSimpleValidationWithCustomProvider() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.setProviderClass(HibernateValidator.class);
validator.afterPropertiesSet();
@ -113,9 +113,10 @@ public class ValidatorFactoryTests { @@ -113,9 +113,10 @@ public class ValidatorFactoryTests {
}
@Test
public void testSimpleValidationWithClassLevel() throws Exception {
public void testSimpleValidationWithClassLevel() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
ValidPerson person = new ValidPerson();
person.setName("Juergen");
person.getAddress().setStreet("Juergen's Street");
@ -128,7 +129,7 @@ public class ValidatorFactoryTests { @@ -128,7 +129,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationFieldType() throws Exception {
public void testSpringValidationFieldType() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -143,7 +144,7 @@ public class ValidatorFactoryTests { @@ -143,7 +144,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidation() throws Exception {
public void testSpringValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -171,7 +172,7 @@ public class ValidatorFactoryTests { @@ -171,7 +172,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationWithClassLevel() throws Exception {
public void testSpringValidationWithClassLevel() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -189,7 +190,7 @@ public class ValidatorFactoryTests { @@ -189,7 +190,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationWithAutowiredValidator() throws Exception {
public void testSpringValidationWithAutowiredValidator() {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(
LocalValidatorFactoryBean.class);
LocalValidatorFactoryBean validator = ctx.getBean(LocalValidatorFactoryBean.class);
@ -210,7 +211,7 @@ public class ValidatorFactoryTests { @@ -210,7 +211,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationWithErrorInListElement() throws Exception {
public void testSpringValidationWithErrorInListElement() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -228,7 +229,7 @@ public class ValidatorFactoryTests { @@ -228,7 +229,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testSpringValidationWithErrorInSetElement() throws Exception {
public void testSpringValidationWithErrorInSetElement() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -246,7 +247,7 @@ public class ValidatorFactoryTests { @@ -246,7 +247,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testInnerBeanValidation() throws Exception {
public void testInnerBeanValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -258,7 +259,7 @@ public class ValidatorFactoryTests { @@ -258,7 +259,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testValidationWithOptionalField() throws Exception {
public void testValidationWithOptionalField() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -270,7 +271,7 @@ public class ValidatorFactoryTests { @@ -270,7 +271,7 @@ public class ValidatorFactoryTests {
}
@Test
public void testListValidation() throws Exception {
public void testListValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();

31
src/docs/asciidoc/data-access.adoc

@ -2214,7 +2214,7 @@ configure the application context to take advantage of these annotations. @@ -2214,7 +2214,7 @@ configure the application context to take advantage of these annotations.
[[jdbc-introduction]]
=== Introduction to Spring Framework JDBC
=== Introduction to Spring Framework's JDBC support
The value-add provided by the Spring Framework JDBC abstraction is perhaps best shown by
the sequence of actions outlined in the table below. The table shows what actions Spring
@ -3826,7 +3826,7 @@ like: @@ -3826,7 +3826,7 @@ like:
[subs="verbatim,quotes"]
----
new SqlParameter("in_id", Types.NUMERIC),
new SqlOutParameter("out_first_name", Types.VARCHAR),
new SqlOutParameter("out_first_name", Types.VARCHAR),
----
The first line with the `SqlParameter` declares an IN parameter. IN parameters can be
@ -4141,7 +4141,7 @@ constants. @@ -4141,7 +4141,7 @@ constants.
[subs="verbatim,quotes"]
----
new SqlParameter("in_id", Types.NUMERIC),
new SqlOutParameter("out_first_name", Types.VARCHAR),
new SqlOutParameter("out_first_name", Types.VARCHAR),
----
The first line with the `SqlParameter` declares an IN parameter. IN parameters can be
@ -4149,10 +4149,10 @@ used for both stored procedure calls and for queries using the `SqlQuery` and it @@ -4149,10 +4149,10 @@ used for both stored procedure calls and for queries using the `SqlQuery` and it
subclasses covered in the following section.
The second line with the `SqlOutParameter` declares an `out` parameter to be used in the
stored procedure call. There is also an `SqlInOutParameter` for `I` `nOut` parameters,
stored procedure call. There is also an `SqlInOutParameter` for `InOut` parameters,
parameters that provide an `in` value to the procedure and that also return a value.
For `i` `n` parameters, in addition to the name and the SQL type, you can specify a
For `in` parameters, in addition to the name and the SQL type, you can specify a
scale for numeric data or a type name for custom database types. For `out` parameters
you can provide a `RowMapper` to handle mapping of rows returned from a REF cursor.
Another option is to specify an `SqlReturnType` that enables you to define customized
@ -4295,8 +4295,7 @@ the supplied `ResultSet`. @@ -4295,8 +4295,7 @@ the supplied `ResultSet`.
To pass parameters to a stored procedure that has one or more input parameters in its
definition in the RDBMS, you can code a strongly typed `execute(..)` method that would
delegate to the superclass' untyped `execute(Map parameters)` method (which has
`protected` access); for example:
delegate to the untyped `execute(Map)` method in the superclass; for example:
[source,java,indent=0]
[subs="verbatim,quotes"]
@ -4337,7 +4336,7 @@ delegate to the superclass' untyped `execute(Map parameters)` method (which has @@ -4337,7 +4336,7 @@ delegate to the superclass' untyped `execute(Map parameters)` method (which has
=== Common problems with parameter and data value handling
Common problems with parameters and data values exist in the different approaches
provided by the Spring Framework JDBC.
provided by Spring Framework's JDBC support.
[[jdbc-type-information]]
@ -4407,11 +4406,11 @@ dependency injection. @@ -4407,11 +4406,11 @@ dependency injection.
jdbcTemplate.execute(
"INSERT INTO lob_table (id, a_clob, a_blob) VALUES (?, ?, ?)",
new AbstractLobCreatingPreparedStatementCallback(lobHandler) { # <1>
new AbstractLobCreatingPreparedStatementCallback(lobHandler) { # <1>
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
ps.setLong(1, 1L);
lobCreator.setClobAsCharacterStream(ps, 2, clobReader, (int)clobIn.length()); # <2>
lobCreator.setBlobAsBinaryStream(ps, 3, blobIs, (int)blobIn.length()); # <3>
lobCreator.setClobAsCharacterStream(ps, 2, clobReader, (int)clobIn.length()); # <2>
lobCreator.setBlobAsBinaryStream(ps, 3, blobIs, (int)blobIn.length()); # <3>
}
}
);
@ -4449,9 +4448,13 @@ with the same instance variable `lobHandler` and a reference to a `DefaultLobHan @@ -4449,9 +4448,13 @@ with the same instance variable `lobHandler` and a reference to a `DefaultLobHan
new RowMapper<Map<String, Object>>() {
public Map<String, Object> mapRow(ResultSet rs, int i) throws SQLException {
Map<String, Object> results = new HashMap<String, Object>();
String clobText = lobHandler.getClobAsString(rs, "a_clob"); # <1>
results.put("CLOB", clobText); byte[] blobBytes = lobHandler.getBlobAsBytes(rs, "a_blob"); # <2>
results.put("BLOB", blobBytes); return results; } });
String clobText = lobHandler.getClobAsString(rs, "a_clob"); # <1>
results.put("CLOB", clobText);
byte[] blobBytes = lobHandler.getBlobAsBytes(rs, "a_blob"); # <2>
results.put("BLOB", blobBytes);
return results;
}
});
----
<1> Using the method `getClobAsString`, retrieve the contents of the CLOB.

Loading…
Cancel
Save