Search in sources :

Example 1 with ClassPathChangedEvent

use of org.springframework.boot.devtools.classpath.ClassPathChangedEvent in project spring-boot by spring-projects.

the class LocalDevToolsAutoConfigurationTests method restartTriggeredOnClassPathChangeWithRestart.

@Test
public void restartTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(Config.class);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.<ChangedFiles>emptySet(), true);
    this.context.publishEvent(event);
    verify(this.mockRestarter.getMock()).restart(any(FailureHandler.class));
}
Also used : ClassPathChangedEvent(org.springframework.boot.devtools.classpath.ClassPathChangedEvent) FailureHandler(org.springframework.boot.devtools.restart.FailureHandler) Test(org.junit.Test)

Example 2 with ClassPathChangedEvent

use of org.springframework.boot.devtools.classpath.ClassPathChangedEvent in project spring-boot by spring-projects.

the class LocalDevToolsAutoConfigurationTests method liveReloadNotTriggeredOnClassPathChangeWithRestart.

@Test
public void liveReloadNotTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(ConfigWithMockLiveReload.class);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    reset(server);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.<ChangedFiles>emptySet(), true);
    this.context.publishEvent(event);
    verify(server, never()).triggerReload();
}
Also used : LiveReloadServer(org.springframework.boot.devtools.livereload.LiveReloadServer) ClassPathChangedEvent(org.springframework.boot.devtools.classpath.ClassPathChangedEvent) Test(org.junit.Test)

Example 3 with ClassPathChangedEvent

use of org.springframework.boot.devtools.classpath.ClassPathChangedEvent in project spring-boot by spring-projects.

the class LocalDevToolsAutoConfigurationTests method restartNotTriggeredOnClassPathChangeWithRestart.

@Test
public void restartNotTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(Config.class);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.<ChangedFiles>emptySet(), false);
    this.context.publishEvent(event);
    verify(this.mockRestarter.getMock(), never()).restart();
}
Also used : ClassPathChangedEvent(org.springframework.boot.devtools.classpath.ClassPathChangedEvent) Test(org.junit.Test)

Example 4 with ClassPathChangedEvent

use of org.springframework.boot.devtools.classpath.ClassPathChangedEvent 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 5 with ClassPathChangedEvent

use of org.springframework.boot.devtools.classpath.ClassPathChangedEvent in project spring-boot by spring-projects.

the class ClassPathChangeUploaderTests method sendsClassLoaderFiles.

@Test
public void sendsClassLoaderFiles() throws Exception {
    File sourceFolder = this.temp.newFolder();
    ClassPathChangedEvent event = createClassPathChangedEvent(sourceFolder);
    this.requestFactory.willRespond(HttpStatus.OK);
    this.uploader.onApplicationEvent(event);
    assertThat(this.requestFactory.getExecutedRequests()).hasSize(1);
    MockClientHttpRequest request = this.requestFactory.getExecutedRequests().get(0);
    verifyUploadRequest(sourceFolder, request);
}
Also used : ClassPathChangedEvent(org.springframework.boot.devtools.classpath.ClassPathChangedEvent) MockClientHttpRequest(org.springframework.mock.http.client.MockClientHttpRequest) ClassLoaderFile(org.springframework.boot.devtools.restart.classloader.ClassLoaderFile) File(java.io.File) ChangedFile(org.springframework.boot.devtools.filewatch.ChangedFile) Test(org.junit.Test)

Aggregations

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