use of org.springframework.boot.devtools.filewatch.ChangedFiles in project spring-boot by spring-projects.
the class ClassPathChangeUploaderTests method createClassPathChangedEvent.
private ClassPathChangedEvent createClassPathChangedEvent(File sourceFolder) throws IOException {
Set<ChangedFile> files = new LinkedHashSet<>();
File file1 = createFile(sourceFolder, "File1");
File file2 = createFile(sourceFolder, "File2");
File file3 = createFile(sourceFolder, "File3");
files.add(new ChangedFile(sourceFolder, file1, Type.ADD));
files.add(new ChangedFile(sourceFolder, file2, Type.MODIFY));
files.add(new ChangedFile(sourceFolder, file3, Type.DELETE));
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
changeSet.add(new ChangedFiles(sourceFolder, files));
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
return event;
}
use of org.springframework.boot.devtools.filewatch.ChangedFiles in project spring-boot by spring-projects.
the class ClassPathFileChangeListenerTests method testSendsEvent.
private void testSendsEvent(boolean restart) {
ClassPathFileChangeListener listener = new ClassPathFileChangeListener(this.eventPublisher, this.restartStrategy, this.fileSystemWatcher);
File folder = new File("s1");
File file = new File("f1");
ChangedFile file1 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
ChangedFile file2 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
Set<ChangedFile> files = new LinkedHashSet<>();
files.add(file1);
files.add(file2);
ChangedFiles changedFiles = new ChangedFiles(new File("source"), files);
Set<ChangedFiles> changeSet = Collections.singleton(changedFiles);
if (restart) {
given(this.restartStrategy.isRestartRequired(file2)).willReturn(true);
}
listener.onChange(changeSet);
verify(this.eventPublisher).publishEvent(this.eventCaptor.capture());
ClassPathChangedEvent actualEvent = (ClassPathChangedEvent) this.eventCaptor.getValue();
assertThat(actualEvent.getChangeSet()).isEqualTo(changeSet);
assertThat(actualEvent.isRestartRequired()).isEqualTo(restart);
}
use of org.springframework.boot.devtools.filewatch.ChangedFiles in project spring-boot by spring-projects.
the class RemoteClientConfigurationTests method liveReloadOnClassPathChanged.
@Test
public void liveReloadOnClassPathChanged() throws Exception {
configure();
Set<ChangedFiles> changeSet = new HashSet<>();
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
this.context.publishEvent(event);
LiveReloadConfiguration configuration = this.context.getBean(LiveReloadConfiguration.class);
configuration.getExecutor().shutdown();
configuration.getExecutor().awaitTermination(2, TimeUnit.SECONDS);
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
verify(server).triggerReload();
}
Aggregations