Skip to content

Commit 97a62cd

Browse files
test: Add unit test for #40342
1 parent 4d466c3 commit 97a62cd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.springframework.boot.autoconfigure.web.WebProperties;
3838
import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
3939
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
40+
import org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration.LiveReloadForAdditionalPaths;
4041
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
4142
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
4243
import org.springframework.boot.devtools.livereload.LiveReloadServer;
@@ -70,6 +71,7 @@
7071
* @author Phillip Webb
7172
* @author Andy Wilkinson
7273
* @author Vladimir Tsanev
74+
* @author Akshay Dubey
7375
*/
7476
@ExtendWith(MockRestarter.class)
7577
class LocalDevToolsAutoConfigurationTests {
@@ -213,6 +215,20 @@ void watchingAdditionalPaths() throws Exception {
213215
.containsKey(new File("src/test/java").getAbsoluteFile());
214216
}
215217

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+
216232
@Test
217233
void devToolsSwitchesJspServletToDevelopmentMode() throws Exception {
218234
this.context = getContext(() -> initializeAndRun(Config.class));

0 commit comments

Comments
 (0)