Search in sources :

Example 1 with ChangedFiles

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;
}
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 ChangedFiles

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);
}
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)

Example 3 with ChangedFiles

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();
}
Also used : LiveReloadConfiguration(org.springframework.boot.devtools.remote.client.RemoteClientConfiguration.LiveReloadConfiguration) ChangedFiles(org.springframework.boot.devtools.filewatch.ChangedFiles) OptionalLiveReloadServer(org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer) LiveReloadServer(org.springframework.boot.devtools.livereload.LiveReloadServer) ClassPathChangedEvent(org.springframework.boot.devtools.classpath.ClassPathChangedEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ChangedFiles (org.springframework.boot.devtools.filewatch.ChangedFiles)3 File (java.io.File)2 LinkedHashSet (java.util.LinkedHashSet)2 ClassPathChangedEvent (org.springframework.boot.devtools.classpath.ClassPathChangedEvent)2 ChangedFile (org.springframework.boot.devtools.filewatch.ChangedFile)2 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 OptionalLiveReloadServer (org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer)1 LiveReloadServer (org.springframework.boot.devtools.livereload.LiveReloadServer)1 LiveReloadConfiguration (org.springframework.boot.devtools.remote.client.RemoteClientConfiguration.LiveReloadConfiguration)1 ClassLoaderFile (org.springframework.boot.devtools.restart.classloader.ClassLoaderFile)1