|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2012-2017 the original author or authors. |
|
|
|
* Copyright 2012-2018 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,8 +17,10 @@ |
|
|
|
package org.springframework.boot.autoconfigure.freemarker; |
|
|
|
package org.springframework.boot.autoconfigure.freemarker; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.StringWriter; |
|
|
|
import java.io.StringWriter; |
|
|
|
|
|
|
|
import java.util.EnumSet; |
|
|
|
import java.util.Locale; |
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.DispatcherType; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.After; |
|
|
|
import org.junit.After; |
|
|
|
@ -26,6 +28,7 @@ import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.test.util.TestPropertyValues; |
|
|
|
import org.springframework.boot.test.util.TestPropertyValues; |
|
|
|
|
|
|
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
|
|
|
import org.springframework.mock.web.MockHttpServletRequest; |
|
|
|
import org.springframework.mock.web.MockHttpServletRequest; |
|
|
|
import org.springframework.mock.web.MockHttpServletResponse; |
|
|
|
import org.springframework.mock.web.MockHttpServletResponse; |
|
|
|
import org.springframework.mock.web.MockServletContext; |
|
|
|
import org.springframework.mock.web.MockServletContext; |
|
|
|
@ -153,14 +156,18 @@ public class FreeMarkerAutoConfigurationServletIntegrationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void registerResourceHandlingFilterDisabledByDefault() { |
|
|
|
public void registerResourceHandlingFilterDisabledByDefault() { |
|
|
|
registerAndRefreshContext(); |
|
|
|
registerAndRefreshContext(); |
|
|
|
assertThat(this.context.getBeansOfType(ResourceUrlEncodingFilter.class)) |
|
|
|
assertThat(this.context.getBeansOfType(FilterRegistrationBean.class)).isEmpty(); |
|
|
|
.isEmpty(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() { |
|
|
|
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() { |
|
|
|
registerAndRefreshContext("spring.resources.chain.enabled:true"); |
|
|
|
registerAndRefreshContext("spring.resources.chain.enabled:true"); |
|
|
|
assertThat(this.context.getBean(ResourceUrlEncodingFilter.class)).isNotNull(); |
|
|
|
FilterRegistrationBean<?> registration = this.context |
|
|
|
|
|
|
|
.getBean(FilterRegistrationBean.class); |
|
|
|
|
|
|
|
assertThat(registration.getFilter()) |
|
|
|
|
|
|
|
.isInstanceOf(ResourceUrlEncodingFilter.class); |
|
|
|
|
|
|
|
assertThat(registration).hasFieldOrPropertyWithValue("dispatcherTypes", |
|
|
|
|
|
|
|
EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void registerAndRefreshContext(String... env) { |
|
|
|
private void registerAndRefreshContext(String... env) { |
|
|
|
|