|
37 | 37 | import org.springframework.boot.autoconfigure.web.WebProperties; |
38 | 38 | import org.springframework.boot.autoconfigure.web.WebProperties.Resources; |
39 | 39 | import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration; |
| 40 | +import org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration.LiveReloadForAdditionalPaths; |
40 | 41 | import org.springframework.boot.devtools.classpath.ClassPathChangedEvent; |
41 | 42 | import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher; |
42 | 43 | import org.springframework.boot.devtools.livereload.LiveReloadServer; |
|
70 | 71 | * @author Phillip Webb |
71 | 72 | * @author Andy Wilkinson |
72 | 73 | * @author Vladimir Tsanev |
| 74 | + * @author Akshay Dubey |
73 | 75 | */ |
74 | 76 | @ExtendWith(MockRestarter.class) |
75 | 77 | class LocalDevToolsAutoConfigurationTests { |
@@ -213,6 +215,20 @@ void watchingAdditionalPaths() throws Exception { |
213 | 215 | .containsKey(new File("src/test/java").getAbsoluteFile()); |
214 | 216 | } |
215 | 217 |
|
| 218 | + @Test |
| 219 | + void watchingAdditionalPathsForReload() throws Exception { |
| 220 | + Map<String, Object> properties = new HashMap<>(); |
| 221 | + properties.put("spring.devtools.livereload.additional-paths", "src/main/java,src/test/java"); |
| 222 | + this.context = getContext(() -> initializeAndRun(Config.class, properties)); |
| 223 | + LiveReloadForAdditionalPaths liveReloadForAdditionalPaths = this.context.getBean(LiveReloadForAdditionalPaths.class); |
| 224 | + Object watcher = ReflectionTestUtils.getField(liveReloadForAdditionalPaths, "fileSystemWatcher"); |
| 225 | + @SuppressWarnings("unchecked") |
| 226 | + Map<File, Object> directories = (Map<File, Object>) ReflectionTestUtils.getField(watcher, "directories"); |
| 227 | + assertThat(directories).hasSize(2) |
| 228 | + .containsKey(new File("src/main/java").getAbsoluteFile()) |
| 229 | + .containsKey(new File("src/test/java").getAbsoluteFile()); |
| 230 | + } |
| 231 | + |
216 | 232 | @Test |
217 | 233 | void devToolsSwitchesJspServletToDevelopmentMode() throws Exception { |
218 | 234 | this.context = getContext(() -> initializeAndRun(Config.class)); |
|
0 commit comments