Skip to content

Commit

Permalink
Polish contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Aug 6, 2015
1 parent 7568af1 commit 9fcc860
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ public class WebMvcAutoConfiguration {

@Bean
@ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
return new OrderedHiddenHttpMethodFilter();
}

@Bean
@ConditionalOnMissingBean(HttpPutFormContentFilter.class)
public HttpPutFormContentFilter httpPutFormContentFilter() {
public OrderedHttpPutFormContentFilter httpPutFormContentFilter() {
return new OrderedHttpPutFormContentFilter();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.context.web.OrderedHttpPutFormContentFilter;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -51,6 +52,7 @@
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.HttpPutFormContentFilter;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.LocaleResolver;
Expand Down Expand Up @@ -441,6 +443,22 @@ public void customAsyncRequestTimeout() throws Exception {
assertEquals(123456L, actual);
}

@Test
public void httpPutFormContentFilterIsAutoConfigured() {
load();
assertThat(this.context.getBeansOfType(OrderedHttpPutFormContentFilter.class)
.size(), is(equalTo(1)));
}

@Test
public void httpPutFormContentFilterCanBeOverridden() {
load(CustomHttpPutFormContentFilter.class);
assertThat(this.context.getBeansOfType(OrderedHttpPutFormContentFilter.class)
.size(), is(equalTo(0)));
assertThat(this.context.getBeansOfType(HttpPutFormContentFilter.class).size(),
is(equalTo(1)));
}

@SuppressWarnings("unchecked")
private void load(Class<?> config, String... environment) {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
Expand Down Expand Up @@ -552,4 +570,14 @@ public View resolveViewName(String viewName, Locale locale) throws Exception {

}

@Configuration
static class CustomHttpPutFormContentFilter {

@Bean
public HttpPutFormContentFilter customHttpPutFormContentFilter() {
return new HttpPutFormContentFilter();
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
* @author Joao Pedro Evangelista
* @since 1.3.0
*/
public class OrderedHttpPutFormContentFilter extends HttpPutFormContentFilter implements Ordered {
public class OrderedHttpPutFormContentFilter extends HttpPutFormContentFilter implements
Ordered {

/**
* Higher order to ensure the filter is applied before Spring Security.
Expand Down

0 comments on commit 9fcc860

Please sign in to comment.