matrei commented on code in PR #16040:
URL: https://github.com/apache/grails-core/pull/16040#discussion_r3628834010
##########
grails-controllers/src/test/groovy/org/grails/plugins/web/controllers/ControllersAutoConfigurationSpec.groovy:
##########
@@ -54,6 +57,27 @@ class ControllersAutoConfigurationSpec extends Specification
{
def autoConfiguration = new ControllersAutoConfiguration()
+ def "legacy multipart configuration fails startup with migration
instructions"() {
+ given:
+ def applicationContext = new AnnotationConfigWebApplicationContext()
+ applicationContext.servletContext = new MockServletContext()
+ applicationContext.environment.propertySources.addFirst(new
MapPropertySource('test', [
+ 'grails.controllers.upload.maxFileSize': 20000000,
+ ]))
+ applicationContext.register(ControllersAutoConfiguration)
+
+ when:
+ applicationContext.refresh()
+
+ then:
+ BeanCreationException exception = thrown()
Review Comment:
Consider using: `def exception = thrown(BeanCreationException)` (for
readability)?
##########
grails-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java:
##########
@@ -58,7 +63,15 @@
after = {GrailsDomainClassAutoConfiguration.class}
)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
-public class ControllersAutoConfiguration {
+public class ControllersAutoConfiguration implements EnvironmentAware {
+
+ private static final String LEGACY_MULTIPART_CONFIGURATION =
"grails.controllers.upload";
+
+ static final String LEGACY_MULTIPART_CONFIGURATION_ERROR =
Review Comment:
`private`?
##########
grails-controllers/src/test/groovy/org/grails/plugins/web/controllers/ControllersAutoConfigurationSpec.groovy:
##########
@@ -54,6 +57,27 @@ class ControllersAutoConfigurationSpec extends Specification
{
def autoConfiguration = new ControllersAutoConfiguration()
+ def "legacy multipart configuration fails startup with migration
instructions"() {
+ given:
+ def applicationContext = new AnnotationConfigWebApplicationContext()
+ applicationContext.servletContext = new MockServletContext()
+ applicationContext.environment.propertySources.addFirst(new
MapPropertySource('test', [
+ 'grails.controllers.upload.maxFileSize': 20000000,
+ ]))
+ applicationContext.register(ControllersAutoConfiguration)
+
+ when:
+ applicationContext.refresh()
+
+ then:
+ BeanCreationException exception = thrown()
+ exception.rootCause instanceof IllegalStateException
+ exception.rootCause.message ==
ControllersAutoConfiguration.LEGACY_MULTIPART_CONFIGURATION_ERROR
Review Comment:
Consider not using constants in tests. Write out the expected value instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]