Polishing
This commit is contained in:
parent
9b2b485444
commit
00577ed80a
|
|
@ -81,9 +81,9 @@ class BeanWrapperGenericsTests {
|
|||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Set<TestBean> input = new HashSet<>();
|
||||
input.add(new TestBean());
|
||||
assertThatExceptionOfType(TypeMismatchException.class).isThrownBy(() ->
|
||||
bw.setPropertyValue("integerSet", input))
|
||||
.withMessageContaining("java.lang.Integer");
|
||||
assertThatExceptionOfType(TypeMismatchException.class)
|
||||
.isThrownBy(() -> bw.setPropertyValue("integerSet", input))
|
||||
.withMessageContaining("java.lang.Integer");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -103,13 +103,13 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
|||
pvs.addPropertyValue(new PropertyValue("age", "foobar"));
|
||||
pvs.addPropertyValue(new PropertyValue("name", newName));
|
||||
pvs.addPropertyValue(new PropertyValue("touchy", invalidTouchy));
|
||||
assertThatExceptionOfType(PropertyBatchUpdateException.class).isThrownBy(() ->
|
||||
accessor.setPropertyValues(pvs))
|
||||
.satisfies(ex -> {
|
||||
assertThat(ex.getExceptionCount()).isEqualTo(2);
|
||||
assertThat(ex.getPropertyAccessException("touchy").getPropertyChangeEvent()
|
||||
.getNewValue()).isEqualTo(invalidTouchy);
|
||||
});
|
||||
assertThatExceptionOfType(PropertyBatchUpdateException.class)
|
||||
.isThrownBy(() -> accessor.setPropertyValues(pvs))
|
||||
.satisfies(ex -> {
|
||||
assertThat(ex.getExceptionCount()).isEqualTo(2);
|
||||
assertThat(ex.getPropertyAccessException("touchy").getPropertyChangeEvent()
|
||||
.getNewValue()).isEqualTo(invalidTouchy);
|
||||
});
|
||||
// Test validly set property matches
|
||||
assertThat(target.getName()).as("Valid set property must stick").isEqualTo(newName);
|
||||
assertThat(target.getAge()).as("Invalid set property must retain old value").isEqualTo(0);
|
||||
|
|
@ -119,9 +119,9 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
|||
void checkNotWritablePropertyHoldPossibleMatches() {
|
||||
TestBean target = new TestBean();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() ->
|
||||
accessor.setPropertyValue("ag", "foobar"))
|
||||
.satisfies(ex -> assertThat(ex.getPossibleMatches()).containsExactly("age"));
|
||||
assertThatExceptionOfType(NotWritablePropertyException.class)
|
||||
.isThrownBy(() -> accessor.setPropertyValue("ag", "foobar"))
|
||||
.satisfies(ex -> assertThat(ex.getPossibleMatches()).containsExactly("age"));
|
||||
}
|
||||
|
||||
@Test // Can't be shared; there is no such thing as a read-only field
|
||||
|
|
@ -294,9 +294,9 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
|||
void incompletelyQuotedKeyLeadsToPropertyException() {
|
||||
TestBean target = new TestBean();
|
||||
BeanWrapper accessor = createAccessor(target);
|
||||
assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() ->
|
||||
accessor.setPropertyValue("[']", "foobar"))
|
||||
.satisfies(ex -> assertThat(ex.getPossibleMatches()).isNull());
|
||||
assertThatExceptionOfType(NotWritablePropertyException.class)
|
||||
.isThrownBy(() -> accessor.setPropertyValue("[']", "foobar"))
|
||||
.satisfies(ex -> assertThat(ex.getPossibleMatches()).isNull());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
|
|
@ -152,8 +152,7 @@ public interface Resource extends InputStreamSource {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of this resource as a string, using the specified
|
||||
* charset.
|
||||
* Return the contents of this resource as a string, using the specified charset.
|
||||
* @param charset the charset to use for decoding
|
||||
* @return the contents of this resource as a {@code String}
|
||||
* @throws java.io.FileNotFoundException if the resource cannot be resolved as
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
|
|
@ -45,8 +45,8 @@ import org.springframework.util.Assert;
|
|||
* lobCreator.setBlobAsBinaryStream(ps, 2, contentStream, contentLength);
|
||||
* lobCreator.setClobAsString(ps, 3, description);
|
||||
* }
|
||||
* }
|
||||
* );</pre>
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.0.2
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
|
|
@ -41,13 +41,13 @@ import org.springframework.lang.Nullable;
|
|||
* final LobHandler lobHandler = new DefaultLobHandler(); // reusable object
|
||||
*
|
||||
* jdbcTemplate.query(
|
||||
* "SELECT content FROM imagedb WHERE image_name=?", new Object[] {name},
|
||||
* new AbstractLobStreamingResultSetExtractor() {
|
||||
* public void streamData(ResultSet rs) throws SQLException, IOException {
|
||||
* FileCopyUtils.copy(lobHandler.getBlobAsBinaryStream(rs, 1), contentStream);
|
||||
* }
|
||||
* }
|
||||
* );</pre>
|
||||
* "SELECT content FROM imagedb WHERE image_name=?", new Object[] {name},
|
||||
* new AbstractLobStreamingResultSetExtractor() {
|
||||
* public void streamData(ResultSet rs) throws SQLException, IOException {
|
||||
* FileCopyUtils.copy(lobHandler.getBlobAsBinaryStream(rs, 1), contentStream);
|
||||
* }
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.0.2
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
|
|
@ -20,9 +20,7 @@ import org.springframework.jdbc.support.SqlValue;
|
|||
|
||||
/**
|
||||
* Subinterface of {@link org.springframework.jdbc.support.SqlValue}
|
||||
* that supports passing in XML data to specified column and adds a
|
||||
* cleanup callback, to be invoked after the value has been set and
|
||||
* the corresponding statement has been executed.
|
||||
* that specifically indicates passing in XML data to a specified column.
|
||||
*
|
||||
* @author Thomas Risberg
|
||||
* @since 2.5.5
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
|
|
@ -95,8 +95,7 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter<Str
|
|||
Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType());
|
||||
long length = inputMessage.getHeaders().getContentLength();
|
||||
byte[] bytes = (length >= 0 && length <= Integer.MAX_VALUE ?
|
||||
inputMessage.getBody().readNBytes((int) length) :
|
||||
inputMessage.getBody().readAllBytes());
|
||||
inputMessage.getBody().readNBytes((int) length) : inputMessage.getBody().readAllBytes());
|
||||
return new String(bytes, charset);
|
||||
}
|
||||
|
||||
|
|
@ -110,10 +109,9 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter<Str
|
|||
@Override
|
||||
protected void addDefaultHeaders(HttpHeaders headers, String s, @Nullable MediaType type) throws IOException {
|
||||
if (headers.getContentType() == null ) {
|
||||
if (type != null && type.isConcrete() &&
|
||||
(type.isCompatibleWith(MediaType.APPLICATION_JSON) ||
|
||||
if (type != null && type.isConcrete() && (type.isCompatibleWith(MediaType.APPLICATION_JSON) ||
|
||||
type.isCompatibleWith(APPLICATION_PLUS_JSON))) {
|
||||
// Prevent charset parameter for JSON..
|
||||
// Prevent charset parameter for JSON.
|
||||
headers.setContentType(type);
|
||||
}
|
||||
}
|
||||
|
|
@ -167,4 +165,5 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter<Str
|
|||
protected boolean supportsRepeatableWrites(String s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue