Merge branch '1.5.x'
This commit is contained in:
@@ -117,6 +117,11 @@
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-client</artifactId>
|
||||
|
||||
@@ -52,6 +52,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
|
||||
properties.put("spring.resources.cache-period", "0");
|
||||
properties.put("spring.template.provider.cache", "false");
|
||||
properties.put("spring.mvc.log-resolved-exception", "true");
|
||||
properties.put("server.jsp-servlet.init-parameters.development", "true");
|
||||
PROPERTIES = Collections.unmodifiableMap(properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.catalina.Container;
|
||||
import org.apache.catalina.core.StandardWrapper;
|
||||
import org.apache.jasper.EmbeddedServletOptions;
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -30,7 +33,12 @@ import org.thymeleaf.templateresolver.TemplateResolver;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ResourceProperties;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
||||
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
||||
import org.springframework.boot.devtools.filewatch.ChangedFiles;
|
||||
@@ -234,6 +242,18 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
.containsKey(new File("src/test/java").getAbsoluteFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void devToolsSwitchesJspServletToDevelopmentMode() {
|
||||
this.context = initializeAndRun(Config.class);
|
||||
TomcatEmbeddedServletContainer tomcatContainer = (TomcatEmbeddedServletContainer) ((EmbeddedWebApplicationContext) this.context)
|
||||
.getEmbeddedServletContainer();
|
||||
Container context = tomcatContainer.getTomcat().getHost().findChildren()[0];
|
||||
StandardWrapper jspServletWrapper = (StandardWrapper) context.findChild("jsp");
|
||||
EmbeddedServletOptions options = (EmbeddedServletOptions) ReflectionTestUtils
|
||||
.getField(jspServletWrapper.getServlet(), "options");
|
||||
assertThat(options.getDevelopment()).isEqualTo(true);
|
||||
}
|
||||
|
||||
private ConfigurableApplicationContext initializeAndRun(Class<?> config,
|
||||
String... args) {
|
||||
return initializeAndRun(config, Collections.<String, Object>emptyMap(), args);
|
||||
@@ -244,7 +264,6 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
Restarter.initialize(new String[0], false, new MockRestartInitializer(), false);
|
||||
SpringApplication application = new SpringApplication(config);
|
||||
application.setDefaultProperties(getDefaultProperties(properties));
|
||||
application.setWebEnvironment(false);
|
||||
ConfigurableApplicationContext context = application.run(args);
|
||||
return context;
|
||||
}
|
||||
@@ -254,18 +273,22 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put("spring.thymeleaf.check-template-location", false);
|
||||
properties.put("spring.devtools.livereload.port", this.liveReloadPort);
|
||||
properties.put("server.port", 0);
|
||||
properties.putAll(specifiedProperties);
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import({ LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
||||
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
||||
@EnableConfigurationProperties(ServerProperties.class)
|
||||
public static class Config {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import({ LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
||||
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
||||
public static class ConfigWithMockLiveReload {
|
||||
|
||||
@Bean
|
||||
@@ -276,7 +299,8 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import({ LocalDevToolsAutoConfiguration.class, ResourceProperties.class })
|
||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
||||
LocalDevToolsAutoConfiguration.class, ResourceProperties.class })
|
||||
public static class WebResourcesConfig {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user