Search in sources :

Example 6 with ClassPathChangedEvent

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

Example 7 with ClassPathChangedEvent

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

the class ClassPathChangeUploaderTests method retriesOnConnectException.

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

Example 8 with ClassPathChangedEvent

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

the class LocalDevToolsAutoConfigurationTests method liveReloadTriggeredOnClassPathChangeWithoutRestart.

@Test
public void liveReloadTriggeredOnClassPathChangeWithoutRestart() 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(), false);
    this.context.publishEvent(event);
    verify(server).triggerReload();
}
Also used : LiveReloadServer(org.springframework.boot.devtools.livereload.LiveReloadServer) ClassPathChangedEvent(org.springframework.boot.devtools.classpath.ClassPathChangedEvent) 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