Search in sources :

Example 1 with SystemServiceStoppedEvent

use of org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent in project che by eclipse.

the class DtoConverterTest method convertsSystemServiceStoppedEvent.

@Test
public void convertsSystemServiceStoppedEvent() {
    SystemServiceStoppedEvent event = new SystemServiceStoppedEvent("service1");
    SystemServiceEventDto dto = DtoConverter.asDto(event);
    assertEquals(dto.getType(), EventType.SERVICE_STOPPED);
    assertEquals(dto.getService(), event.getServiceName());
}
Also used : SystemServiceEventDto(org.eclipse.che.api.system.shared.dto.SystemServiceEventDto) SystemServiceStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent) Test(org.testng.annotations.Test)

Example 2 with SystemServiceStoppedEvent

use of org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent in project che by eclipse.

the class SystemEventsWebsocketBroadcasterTest method eventToDto.

@DataProvider(name = "eventToDto")
private static Object[][] eventToDto() {
    SystemStatusChangedEvent statusChanged = new SystemStatusChangedEvent(RUNNING, PREPARING_TO_SHUTDOWN);
    StoppingSystemServiceEvent stoppingService = new StoppingSystemServiceEvent("service1");
    SystemServiceStoppedEvent serviceStopped = new SystemServiceStoppedEvent("service1");
    SystemServiceItemStoppedEvent itemStopped = new SystemServiceItemStoppedEvent("service1", "item1", 5, 10);
    return new Object[][] { { statusChanged, DtoConverter.asDto(statusChanged) }, { stoppingService, DtoConverter.asDto(stoppingService) }, { serviceStopped, DtoConverter.asDto(serviceStopped) }, { itemStopped, DtoConverter.asDto(itemStopped) } };
}
Also used : SystemStatusChangedEvent(org.eclipse.che.api.system.shared.event.SystemStatusChangedEvent) SystemServiceItemStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent) StoppingSystemServiceEvent(org.eclipse.che.api.system.shared.event.service.StoppingSystemServiceEvent) SystemServiceStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent) DataProvider(org.testng.annotations.DataProvider)

Example 3 with SystemServiceStoppedEvent

use of org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent in project che by eclipse.

the class SystemEventsWebsocketBroadcasterTest method sendExceptionsAreLoggedAndNotThrown.

@Test
public void sendExceptionsAreLoggedAndNotThrown() throws Exception {
    doThrow(new IOException("exception!")).when(messageCustomer).writeLine(anyString());
    broadcaster.onEvent(new SystemServiceStoppedEvent("service1"));
}
Also used : IOException(java.io.IOException) SystemServiceStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent) Test(org.testng.annotations.Test)

Example 4 with SystemServiceStoppedEvent

use of org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent in project che by eclipse.

the class SystemTerminatorTest method executesTerminations.

@Test
public void executesTerminations() throws Exception {
    terminator.terminateAll();
    verify(termination1).terminate();
    verify(termination2).terminate();
    verify(eventService).publish(new StoppingSystemServiceEvent("service1"));
    verify(eventService).publish(new SystemServiceStoppedEvent("service1"));
    verify(eventService).publish(new StoppingSystemServiceEvent("service2"));
    verify(eventService).publish(new SystemServiceStoppedEvent("service2"));
}
Also used : StoppingSystemServiceEvent(org.eclipse.che.api.system.shared.event.service.StoppingSystemServiceEvent) SystemServiceStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent) Test(org.testng.annotations.Test)

Example 5 with SystemServiceStoppedEvent

use of org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent in project che by eclipse.

the class ServiceTerminator method terminateAll.

/**
     * Terminates system services.
     *
     * @throws InterruptedException
     *         when termination is interrupted
     */
void terminateAll() throws InterruptedException {
    for (ServiceTermination termination : terminations) {
        LOG.info("Shutting down '{}' service", termination.getServiceName());
        eventService.publish(new StoppingSystemServiceEvent(termination.getServiceName()));
        try {
            termination.terminate();
        } catch (InterruptedException x) {
            LOG.error("Interrupted while waiting for '{}' service to shutdown", termination.getServiceName());
            throw x;
        }
        LOG.info("Service '{}' is shut down", termination.getServiceName());
        eventService.publish(new SystemServiceStoppedEvent(termination.getServiceName()));
    }
}
Also used : StoppingSystemServiceEvent(org.eclipse.che.api.system.shared.event.service.StoppingSystemServiceEvent) SystemServiceStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent)

Aggregations

SystemServiceStoppedEvent (org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent)5 StoppingSystemServiceEvent (org.eclipse.che.api.system.shared.event.service.StoppingSystemServiceEvent)3 Test (org.testng.annotations.Test)3 IOException (java.io.IOException)1 SystemServiceEventDto (org.eclipse.che.api.system.shared.dto.SystemServiceEventDto)1 SystemStatusChangedEvent (org.eclipse.che.api.system.shared.event.SystemStatusChangedEvent)1 SystemServiceItemStoppedEvent (org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent)1 DataProvider (org.testng.annotations.DataProvider)1