Search in sources :

Example 1 with ChangedFile

use of org.springframework.boot.devtools.filewatch.ChangedFile 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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ChangedFiles(org.springframework.boot.devtools.filewatch.ChangedFiles) ClassPathChangedEvent(org.springframework.boot.devtools.classpath.ClassPathChangedEvent) ChangedFile(org.springframework.boot.devtools.filewatch.ChangedFile) ClassLoaderFile(org.springframework.boot.devtools.restart.classloader.ClassLoaderFile) File(java.io.File) ChangedFile(org.springframework.boot.devtools.filewatch.ChangedFile)

Example 2 with ChangedFile

use of org.springframework.boot.devtools.filewatch.ChangedFile 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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ChangedFiles(org.springframework.boot.devtools.filewatch.ChangedFiles) File(java.io.File) ChangedFile(org.springframework.boot.devtools.filewatch.ChangedFile) ChangedFile(org.springframework.boot.devtools.filewatch.ChangedFile)

Aggregations

File (java.io.File)2 LinkedHashSet (java.util.LinkedHashSet)2 ChangedFile (org.springframework.boot.devtools.filewatch.ChangedFile)2 ChangedFiles (org.springframework.boot.devtools.filewatch.ChangedFiles)2 ClassPathChangedEvent (org.springframework.boot.devtools.classpath.ClassPathChangedEvent)1 ClassLoaderFile (org.springframework.boot.devtools.restart.classloader.ClassLoaderFile)1