Skip to content

Commit 896f20e

Browse files
committed
Improve diagnostics of ClassPathFileSystemWatcherTests
Closes gh-25821
1 parent c4b84ae commit 896f20e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/classpath/ClassPathChangedEvent.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.boot.devtools.filewatch.ChangedFiles;
2222
import org.springframework.context.ApplicationEvent;
23+
import org.springframework.core.style.ToStringCreator;
2324
import org.springframework.util.Assert;
2425

2526
/**
@@ -64,4 +65,10 @@ public boolean isRestartRequired() {
6465
return this.restartRequired;
6566
}
6667

68+
@Override
69+
public String toString() {
70+
return new ToStringCreator(this).append("changeSet", this.changeSet)
71+
.append("restartRequired", this.restartRequired).toString();
72+
}
73+
6774
}

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileSystemWatcherTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import org.junit.jupiter.api.Test;
2828
import org.junit.jupiter.api.io.TempDir;
2929

30+
import org.springframework.boot.devtools.filewatch.ChangedFile;
3031
import org.springframework.boot.devtools.filewatch.FileSystemWatcher;
3132
import org.springframework.boot.devtools.filewatch.FileSystemWatcherFactory;
3233
import org.springframework.context.ApplicationListener;
@@ -79,9 +80,9 @@ void configuredWithRestartStrategy(@TempDir File directory) throws Exception {
7980
}
8081
Thread.sleep(500);
8182
}
82-
assertThat(events.size()).isEqualTo(1);
83-
assertThat(events.get(0).getChangeSet().iterator().next().getFiles().iterator().next().getFile())
84-
.isEqualTo(classFile);
83+
assertThat(events).hasSize(1);
84+
assertThat(events.get(0).getChangeSet().iterator().next()).extracting(ChangedFile::getFile)
85+
.containsExactly(classFile);
8586
context.close();
8687
}
8788

0 commit comments

Comments
 (0)