mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Adapt to Spring Framework API change
This commit is contained in:
parent
cb7de2a963
commit
c0e45b7333
@ -85,7 +85,7 @@ public class ServerProperties {
|
||||
/**
|
||||
* Maximum size of the HTTP message header.
|
||||
*/
|
||||
private DataSize maxHttpHeaderSize = DataSize.ofKiloBytes(8);
|
||||
private DataSize maxHttpHeaderSize = DataSize.ofKilobytes(8);
|
||||
|
||||
/**
|
||||
* Time that connectors wait for another HTTP request before closing the connection.
|
||||
@ -335,7 +335,7 @@ public class ServerProperties {
|
||||
/**
|
||||
* Maximum amount of request body to swallow.
|
||||
*/
|
||||
private DataSize maxSwallowSize = DataSize.ofMegaBytes(2);
|
||||
private DataSize maxSwallowSize = DataSize.ofMegabytes(2);
|
||||
|
||||
/**
|
||||
* Whether requests to the context root should be redirected by appending a / to
|
||||
|
@ -64,13 +64,13 @@ public class MultipartProperties {
|
||||
* Max file size.
|
||||
*/
|
||||
@DataSizeUnit(DataUnit.MEGABYTES)
|
||||
private DataSize maxFileSize = DataSize.ofMegaBytes(1);
|
||||
private DataSize maxFileSize = DataSize.ofMegabytes(1);
|
||||
|
||||
/**
|
||||
* Max request size.
|
||||
*/
|
||||
@DataSizeUnit(DataUnit.MEGABYTES)
|
||||
private DataSize maxRequestSize = DataSize.ofMegaBytes(10);
|
||||
private DataSize maxRequestSize = DataSize.ofMegabytes(10);
|
||||
|
||||
/**
|
||||
* Threshold after which files are written to disk.
|
||||
|
@ -138,14 +138,14 @@ public class ServerPropertiesTests {
|
||||
public void testCustomizeHeaderSize() {
|
||||
bind("server.max-http-header-size", "1MB");
|
||||
assertThat(this.properties.getMaxHttpHeaderSize())
|
||||
.isEqualTo(DataSize.ofMegaBytes(1));
|
||||
.isEqualTo(DataSize.ofMegabytes(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomizeHeaderSizeUseBytesByDefault() {
|
||||
bind("server.max-http-header-size", "1024");
|
||||
assertThat(this.properties.getMaxHttpHeaderSize())
|
||||
.isEqualTo(DataSize.ofKiloBytes(1));
|
||||
.isEqualTo(DataSize.ofKilobytes(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -126,7 +126,7 @@ public class TomcatWebServerFactoryCustomizerTests {
|
||||
bind("server.max-http-header-size=1KB");
|
||||
customizeAndRunServer((server) -> assertThat(((AbstractHttp11Protocol<?>) server
|
||||
.getTomcat().getConnector().getProtocolHandler()).getMaxHttpHeaderSize())
|
||||
.isEqualTo(DataSize.ofKiloBytes(1).toBytes()));
|
||||
.isEqualTo(DataSize.ofKilobytes(1).toBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -136,7 +136,7 @@ public class TomcatWebServerFactoryCustomizerTests {
|
||||
"server.tomcat.max-http-header-size=1024");
|
||||
customizeAndRunServer((server) -> assertThat(((AbstractHttp11Protocol<?>) server
|
||||
.getTomcat().getConnector().getProtocolHandler()).getMaxHttpHeaderSize())
|
||||
.isEqualTo(DataSize.ofKiloBytes(1).toBytes()));
|
||||
.isEqualTo(DataSize.ofKilobytes(1).toBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -144,7 +144,7 @@ public class TomcatWebServerFactoryCustomizerTests {
|
||||
bind("server.tomcat.max-swallow-size=10MB");
|
||||
customizeAndRunServer((server) -> assertThat(((AbstractHttp11Protocol<?>) server
|
||||
.getTomcat().getConnector().getProtocolHandler()).getMaxSwallowSize())
|
||||
.isEqualTo(DataSize.ofMegaBytes(10).toBytes()));
|
||||
.isEqualTo(DataSize.ofMegabytes(10).toBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -213,8 +213,8 @@ public class DispatcherServletAutoConfigurationTests {
|
||||
@Bean
|
||||
public MultipartConfigElement multipartConfig() {
|
||||
MultipartConfigFactory factory = new MultipartConfigFactory();
|
||||
factory.setMaxFileSize(DataSize.ofKiloBytes(128));
|
||||
factory.setMaxRequestSize(DataSize.ofKiloBytes(128));
|
||||
factory.setMaxFileSize(DataSize.ofKilobytes(128));
|
||||
factory.setMaxRequestSize(DataSize.ofKilobytes(128));
|
||||
return factory.createMultipartConfig();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ import org.springframework.util.unit.DataUnit;
|
||||
public class AppIoProperties {
|
||||
|
||||
@DataSizeUnit(DataUnit.MEGABYTES)
|
||||
private DataSize bufferSize = DataSize.ofMegaBytes(2);
|
||||
private DataSize bufferSize = DataSize.ofMegabytes(2);
|
||||
|
||||
private DataSize sizeThreshold = DataSize.ofBytes(512);
|
||||
|
||||
|
@ -123,10 +123,10 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
|
||||
static {
|
||||
Map<String, String> values = new HashMap<>();
|
||||
values.put("Bytes", "B");
|
||||
values.put("KiloBytes", "KB");
|
||||
values.put("MegaBytes", "MB");
|
||||
values.put("GigaBytes", "GB");
|
||||
values.put("TeraBytes", "TB");
|
||||
values.put("Kilobytes", "KB");
|
||||
values.put("Megabytes", "MB");
|
||||
values.put("Gigabytes", "GB");
|
||||
values.put("Terabytes", "TB");
|
||||
DATA_SIZE_SUFFIX = Collections.unmodifiableMap(values);
|
||||
}
|
||||
|
||||
|
@ -97,10 +97,10 @@ public abstract class AbstractFieldValuesProcessorTests {
|
||||
assertThat(values.get("durationDays")).isEqualTo("50d");
|
||||
assertThat(values.get("dataSizeNone")).isNull();
|
||||
assertThat(values.get("dataSizeBytes")).isEqualTo("5B");
|
||||
assertThat(values.get("dataSizeKiloBytes")).isEqualTo("10KB");
|
||||
assertThat(values.get("dataSizeMegaBytes")).isEqualTo("20MB");
|
||||
assertThat(values.get("dataSizeGigaBytes")).isEqualTo("30GB");
|
||||
assertThat(values.get("dataSizeTeraBytes")).isEqualTo("40TB");
|
||||
assertThat(values.get("dataSizeKilobytes")).isEqualTo("10KB");
|
||||
assertThat(values.get("dataSizeMegabytes")).isEqualTo("20MB");
|
||||
assertThat(values.get("dataSizeGigabytes")).isEqualTo("30GB");
|
||||
assertThat(values.get("dataSizeTerabytes")).isEqualTo("40TB");
|
||||
}
|
||||
|
||||
@SupportedAnnotationTypes({
|
||||
|
@ -128,12 +128,12 @@ public class FieldValues {
|
||||
|
||||
private DataSize dataSizeBytes = DataSize.ofBytes(5);
|
||||
|
||||
private DataSize dataSizeKiloBytes = DataSize.ofKiloBytes(10);
|
||||
private DataSize dataSizeKilobytes = DataSize.ofKilobytes(10);
|
||||
|
||||
private DataSize dataSizeMegaBytes = DataSize.ofMegaBytes(20);
|
||||
private DataSize dataSizeMegabytes = DataSize.ofMegabytes(20);
|
||||
|
||||
private DataSize dataSizeGigaBytes = DataSize.ofGigaBytes(30);
|
||||
private DataSize dataSizeGigabytes = DataSize.ofGigabytes(30);
|
||||
|
||||
private DataSize dataSizeTeraBytes = DataSize.ofTeraBytes(40);
|
||||
private DataSize dataSizeTerabytes = DataSize.ofTerabytes(40);
|
||||
|
||||
}
|
||||
|
@ -774,8 +774,8 @@ public class ConfigurationPropertiesTests {
|
||||
public void loadWhenBindingToDataSizeShouldBind() {
|
||||
load(DataSizeProperties.class, "test.size=10GB", "test.another-size=5");
|
||||
DataSizeProperties bean = this.context.getBean(DataSizeProperties.class);
|
||||
assertThat(bean.getSize()).isEqualTo(DataSize.ofGigaBytes(10));
|
||||
assertThat(bean.getAnotherSize()).isEqualTo(DataSize.ofKiloBytes(5));
|
||||
assertThat(bean.getSize()).isEqualTo(DataSize.ofGigabytes(10));
|
||||
assertThat(bean.getAnotherSize()).isEqualTo(DataSize.ofKilobytes(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,9 +56,9 @@ public class NumberToDataSizeConverterTests {
|
||||
|
||||
@Test
|
||||
public void convertWhenSimpleWithoutSuffixButWithAnnotationShouldReturnDataSize() {
|
||||
assertThat(convert(10, DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKiloBytes(10));
|
||||
assertThat(convert(+10, DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKiloBytes(10));
|
||||
assertThat(convert(-10, DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKiloBytes(-10));
|
||||
assertThat(convert(10, DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKilobytes(10));
|
||||
assertThat(convert(+10, DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKilobytes(10));
|
||||
assertThat(convert(-10, DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKilobytes(-10));
|
||||
}
|
||||
|
||||
private DataSize convert(Integer source) {
|
||||
|
@ -57,31 +57,31 @@ public class StringToDataSizeConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenSimpleKiloBytesShouldReturnDataSize() {
|
||||
assertThat(convert("10KB")).isEqualTo(DataSize.ofKiloBytes(10));
|
||||
assertThat(convert("+10KB")).isEqualTo(DataSize.ofKiloBytes(10));
|
||||
assertThat(convert("-10KB")).isEqualTo(DataSize.ofKiloBytes(-10));
|
||||
public void convertWhenSimpleKilobytesShouldReturnDataSize() {
|
||||
assertThat(convert("10KB")).isEqualTo(DataSize.ofKilobytes(10));
|
||||
assertThat(convert("+10KB")).isEqualTo(DataSize.ofKilobytes(10));
|
||||
assertThat(convert("-10KB")).isEqualTo(DataSize.ofKilobytes(-10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenSimpleMegaBytesShouldReturnDataSize() {
|
||||
assertThat(convert("10MB")).isEqualTo(DataSize.ofMegaBytes(10));
|
||||
assertThat(convert("+10MB")).isEqualTo(DataSize.ofMegaBytes(10));
|
||||
assertThat(convert("-10MB")).isEqualTo(DataSize.ofMegaBytes(-10));
|
||||
public void convertWhenSimpleMegabytesShouldReturnDataSize() {
|
||||
assertThat(convert("10MB")).isEqualTo(DataSize.ofMegabytes(10));
|
||||
assertThat(convert("+10MB")).isEqualTo(DataSize.ofMegabytes(10));
|
||||
assertThat(convert("-10MB")).isEqualTo(DataSize.ofMegabytes(-10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenSimpleGigaBytesShouldReturnDataSize() {
|
||||
assertThat(convert("10GB")).isEqualTo(DataSize.ofGigaBytes(10));
|
||||
assertThat(convert("+10GB")).isEqualTo(DataSize.ofGigaBytes(10));
|
||||
assertThat(convert("-10GB")).isEqualTo(DataSize.ofGigaBytes(-10));
|
||||
public void convertWhenSimpleGigabytesShouldReturnDataSize() {
|
||||
assertThat(convert("10GB")).isEqualTo(DataSize.ofGigabytes(10));
|
||||
assertThat(convert("+10GB")).isEqualTo(DataSize.ofGigabytes(10));
|
||||
assertThat(convert("-10GB")).isEqualTo(DataSize.ofGigabytes(-10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenSimpleTeraBytesShouldReturnDataSize() {
|
||||
assertThat(convert("10TB")).isEqualTo(DataSize.ofTeraBytes(10));
|
||||
assertThat(convert("+10TB")).isEqualTo(DataSize.ofTeraBytes(10));
|
||||
assertThat(convert("-10TB")).isEqualTo(DataSize.ofTeraBytes(-10));
|
||||
public void convertWhenSimpleTerabytesShouldReturnDataSize() {
|
||||
assertThat(convert("10TB")).isEqualTo(DataSize.ofTerabytes(10));
|
||||
assertThat(convert("+10TB")).isEqualTo(DataSize.ofTerabytes(10));
|
||||
assertThat(convert("-10TB")).isEqualTo(DataSize.ofTerabytes(-10));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -93,11 +93,11 @@ public class StringToDataSizeConverterTests {
|
||||
|
||||
@Test
|
||||
public void convertWhenSimpleWithoutSuffixButWithAnnotationShouldReturnDataSize() {
|
||||
assertThat(convert("10", DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKiloBytes(10));
|
||||
assertThat(convert("10", DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKilobytes(10));
|
||||
assertThat(convert("+10", DataUnit.KILOBYTES))
|
||||
.isEqualTo(DataSize.ofKiloBytes(10));
|
||||
.isEqualTo(DataSize.ofKilobytes(10));
|
||||
assertThat(convert("-10", DataUnit.KILOBYTES))
|
||||
.isEqualTo(DataSize.ofKiloBytes(-10));
|
||||
.isEqualTo(DataSize.ofKilobytes(-10));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -74,8 +74,8 @@ public class MultipartConfigFactoryTests {
|
||||
public void createWithDataSizes() {
|
||||
MultipartConfigFactory factory = new MultipartConfigFactory();
|
||||
factory.setMaxFileSize(DataSize.ofBytes(1));
|
||||
factory.setMaxRequestSize(DataSize.ofKiloBytes(2));
|
||||
factory.setFileSizeThreshold(DataSize.ofMegaBytes(3));
|
||||
factory.setMaxRequestSize(DataSize.ofKilobytes(2));
|
||||
factory.setFileSizeThreshold(DataSize.ofMegabytes(3));
|
||||
MultipartConfigElement config = factory.createMultipartConfig();
|
||||
assertThat(config.getMaxFileSize()).isEqualTo(1L);
|
||||
assertThat(config.getMaxRequestSize()).isEqualTo(2 * 1024L);
|
||||
@ -86,8 +86,8 @@ public class MultipartConfigFactoryTests {
|
||||
public void createWithNegativeDataSizes() {
|
||||
MultipartConfigFactory factory = new MultipartConfigFactory();
|
||||
factory.setMaxFileSize(DataSize.ofBytes(-1));
|
||||
factory.setMaxRequestSize(DataSize.ofKiloBytes(-2));
|
||||
factory.setFileSizeThreshold(DataSize.ofMegaBytes(-3));
|
||||
factory.setMaxRequestSize(DataSize.ofKilobytes(-2));
|
||||
factory.setFileSizeThreshold(DataSize.ofMegabytes(-3));
|
||||
MultipartConfigElement config = factory.createMultipartConfig();
|
||||
assertThat(config.getMaxFileSize()).isEqualTo(-1L);
|
||||
assertThat(config.getMaxRequestSize()).isEqualTo(-1);
|
||||
|
Loading…
Reference in New Issue
Block a user