Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
a83d999f
Commit
a83d999f
authored
Jun 15, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing MultipartProperties.enabled property
Fixes gh-3209
parent
135e9d10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
14 deletions
+40
-14
MultipartProperties.java
...framework/boot/autoconfigure/web/MultipartProperties.java
+14
-1
MultipartAutoConfigurationTests.java
...ot/autoconfigure/web/MultipartAutoConfigurationTests.java
+26
-13
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/MultipartProperties.java
View file @
a83d999f
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -50,6 +50,11 @@ import org.springframework.util.StringUtils;
...
@@ -50,6 +50,11 @@ import org.springframework.util.StringUtils;
@ConfigurationProperties
(
prefix
=
"multipart"
,
ignoreUnknownFields
=
false
)
@ConfigurationProperties
(
prefix
=
"multipart"
,
ignoreUnknownFields
=
false
)
public
class
MultipartProperties
{
public
class
MultipartProperties
{
/**
* Enable multipart upload handling.
*/
private
boolean
enabled
;
/**
/**
* Intermediate location of uploaded files.
* Intermediate location of uploaded files.
*/
*/
...
@@ -73,6 +78,14 @@ public class MultipartProperties {
...
@@ -73,6 +78,14 @@ public class MultipartProperties {
*/
*/
private
String
fileSizeThreshold
=
"0"
;
private
String
fileSizeThreshold
=
"0"
;
public
boolean
getEnabled
()
{
return
this
.
enabled
;
}
public
void
setEnabled
(
boolean
enabled
)
{
this
.
enabled
=
enabled
;
}
public
String
getMaxFileSize
()
{
public
String
getMaxFileSize
()
{
return
this
.
maxFileSize
;
return
this
.
maxFileSize
;
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java
View file @
a83d999f
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
import
java.net.URI
;
import
java.net.URI
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
javax.servlet.MultipartConfigElement
;
import
javax.servlet.MultipartConfigElement
;
...
@@ -24,14 +26,16 @@ import org.junit.After;
...
@@ -24,14 +26,16 @@ import org.junit.After;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
;
import
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
;
import
org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.
Map
PropertySource
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.client.ClientHttpRequest
;
import
org.springframework.http.client.ClientHttpRequest
;
...
@@ -196,22 +200,27 @@ public class MultipartAutoConfigurationTests {
...
@@ -196,22 +200,27 @@ public class MultipartAutoConfigurationTests {
@Test
@Test
public
void
containerWithMultipartConfigDisabled
()
{
public
void
containerWithMultipartConfigDisabled
()
{
testContainerWithCustomMultipartConfigEnabledSetting
(
"false"
,
0
);
}
@Test
public
void
containerWithMultipartConfigEnabled
()
{
testContainerWithCustomMultipartConfigEnabledSetting
(
"true"
,
1
);
}
private
void
testContainerWithCustomMultipartConfigEnabledSetting
(
final
String
propertyValue
,
int
expectedNumberOfMultipartConfigElementBeans
)
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
getEnvironment
().
getPropertySources
()
Map
<
String
,
Object
>
poperties
=
new
LinkedHashMap
<
String
,
Object
>();
.
addFirst
(
new
PropertySource
<
Object
>(
"test"
)
{
poperties
.
put
(
"multipart.enabled"
,
propertyValue
);
@Override
MapPropertySource
propertySource
=
new
MapPropertySource
(
"test"
,
poperties
);
public
Object
getProperty
(
String
name
)
{
this
.
context
.
getEnvironment
().
getPropertySources
().
addFirst
(
propertySource
);
if
(
name
.
toLowerCase
().
contains
(
"multipart.enabled"
))
{
return
"false"
;
}
return
null
;
}
});
this
.
context
.
register
(
ContainerWithNoMultipartTomcat
.
class
,
this
.
context
.
register
(
ContainerWithNoMultipartTomcat
.
class
,
BaseConfiguration
.
class
);
BaseConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
0
,
this
.
context
.
getBeansOfType
(
MultipartConfigElement
.
class
).
size
());
this
.
context
.
getBean
(
MultipartProperties
.
class
);
assertEquals
(
expectedNumberOfMultipartConfigElementBeans
,
this
.
context
.
getBeansOfType
(
MultipartConfigElement
.
class
).
size
());
}
}
@Test
@Test
...
@@ -245,8 +254,12 @@ public class MultipartAutoConfigurationTests {
...
@@ -245,8 +254,12 @@ public class MultipartAutoConfigurationTests {
@Import
({
EmbeddedServletContainerAutoConfiguration
.
class
,
@Import
({
EmbeddedServletContainerAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
MultipartAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
MultipartAutoConfiguration
.
class
,
ServerPropertiesAutoConfiguration
.
class
})
ServerPropertiesAutoConfiguration
.
class
})
@EnableConfigurationProperties
(
MultipartProperties
.
class
)
protected
static
class
BaseConfiguration
{
protected
static
class
BaseConfiguration
{
@Autowired
private
MultipartProperties
properties
;
@Bean
@Bean
public
ServerProperties
serverProperties
()
{
public
ServerProperties
serverProperties
()
{
ServerProperties
properties
=
new
ServerProperties
();
ServerProperties
properties
=
new
ServerProperties
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment