|
|
|
@ -21,6 +21,9 @@ import java.util.Collections; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
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.After; |
|
|
|
import org.junit.Rule; |
|
|
|
import org.junit.Rule; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
@ -30,7 +33,12 @@ import org.thymeleaf.templateresolver.TemplateResolver; |
|
|
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException; |
|
|
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException; |
|
|
|
import org.springframework.boot.SpringApplication; |
|
|
|
import org.springframework.boot.SpringApplication; |
|
|
|
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; |
|
|
|
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.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.ClassPathChangedEvent; |
|
|
|
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher; |
|
|
|
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher; |
|
|
|
import org.springframework.boot.devtools.filewatch.ChangedFiles; |
|
|
|
import org.springframework.boot.devtools.filewatch.ChangedFiles; |
|
|
|
@ -234,6 +242,18 @@ public class LocalDevToolsAutoConfigurationTests { |
|
|
|
.containsKey(new File("src/test/java").getAbsoluteFile()); |
|
|
|
.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, |
|
|
|
private ConfigurableApplicationContext initializeAndRun(Class<?> config, |
|
|
|
String... args) { |
|
|
|
String... args) { |
|
|
|
return initializeAndRun(config, Collections.<String, Object>emptyMap(), 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); |
|
|
|
Restarter.initialize(new String[0], false, new MockRestartInitializer(), false); |
|
|
|
SpringApplication application = new SpringApplication(config); |
|
|
|
SpringApplication application = new SpringApplication(config); |
|
|
|
application.setDefaultProperties(getDefaultProperties(properties)); |
|
|
|
application.setDefaultProperties(getDefaultProperties(properties)); |
|
|
|
application.setWebEnvironment(false); |
|
|
|
|
|
|
|
ConfigurableApplicationContext context = application.run(args); |
|
|
|
ConfigurableApplicationContext context = application.run(args); |
|
|
|
return context; |
|
|
|
return context; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -254,18 +273,22 @@ public class LocalDevToolsAutoConfigurationTests { |
|
|
|
Map<String, Object> properties = new HashMap<String, Object>(); |
|
|
|
Map<String, Object> properties = new HashMap<String, Object>(); |
|
|
|
properties.put("spring.thymeleaf.check-template-location", false); |
|
|
|
properties.put("spring.thymeleaf.check-template-location", false); |
|
|
|
properties.put("spring.devtools.livereload.port", this.liveReloadPort); |
|
|
|
properties.put("spring.devtools.livereload.port", this.liveReloadPort); |
|
|
|
|
|
|
|
properties.put("server.port", 0); |
|
|
|
properties.putAll(specifiedProperties); |
|
|
|
properties.putAll(specifiedProperties); |
|
|
|
return properties; |
|
|
|
return properties; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
@Import({ LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class }) |
|
|
|
@Import({ EmbeddedServletContainerAutoConfiguration.class, |
|
|
|
|
|
|
|
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class }) |
|
|
|
|
|
|
|
@EnableConfigurationProperties(ServerProperties.class) |
|
|
|
public static class Config { |
|
|
|
public static class Config { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
@Import({ LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class }) |
|
|
|
@Import({ EmbeddedServletContainerAutoConfiguration.class, |
|
|
|
|
|
|
|
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class }) |
|
|
|
public static class ConfigWithMockLiveReload { |
|
|
|
public static class ConfigWithMockLiveReload { |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
@ -276,7 +299,8 @@ public class LocalDevToolsAutoConfigurationTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
@Import({ LocalDevToolsAutoConfiguration.class, ResourceProperties.class }) |
|
|
|
@Import({ EmbeddedServletContainerAutoConfiguration.class, |
|
|
|
|
|
|
|
LocalDevToolsAutoConfiguration.class, ResourceProperties.class }) |
|
|
|
public static class WebResourcesConfig { |
|
|
|
public static class WebResourcesConfig { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|