use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class WorkspaceRuntimesTest method stopsTheRunningWorkspaceAndRethrowsTheErrorDifferentFromServerException.
@Test
public void stopsTheRunningWorkspaceAndRethrowsTheErrorDifferentFromServerException() throws Exception {
setRuntime("workspace", WorkspaceStatus.RUNNING);
doThrow(new EnvironmentNotRunningException("no!")).when(envEngine).stop("workspace");
try {
runtimes.stop("workspace");
} catch (ServerException x) {
assertEquals(x.getMessage(), "no!");
assertTrue(x.getCause() instanceof EnvironmentNotRunningException);
}
verify(envEngine).stop("workspace");
assertFalse(runtimeStates.containsKey("workspace"));
verifyEventsSequence(event("workspace", WorkspaceStatus.RUNNING, WorkspaceStatus.STOPPING, EventType.STOPPING, null), event("workspace", WorkspaceStatus.STOPPING, WorkspaceStatus.STOPPED, EventType.ERROR, "no!"));
}
use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class WorkspaceRuntimesTest method failsToCreateSnapshotWhenDevMachineSnapshottingFailed.
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "can't save")
public void failsToCreateSnapshotWhenDevMachineSnapshottingFailed() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
setRuntime(workspace.getId(), WorkspaceStatus.RUNNING);
prepareMachines(workspace.getId(), "env-name");
when(envEngine.saveSnapshot(any(), any())).thenThrow(new ServerException("can't save"));
try {
runtimes.snapshot(workspace.getId());
} catch (Exception x) {
verifyEventsSequence(event(workspace.getId(), WorkspaceStatus.RUNNING, WorkspaceStatus.SNAPSHOTTING, EventType.SNAPSHOT_CREATING, null), event(workspace.getId(), WorkspaceStatus.SNAPSHOTTING, WorkspaceStatus.RUNNING, EventType.SNAPSHOT_CREATION_ERROR, "can't save"));
throw x;
}
}
use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class WorkspaceRuntimesTest method removesNewlyCreatedSnapshotsWhenFailedToSaveTheirsMetadata.
@Test
public void removesNewlyCreatedSnapshotsWhenFailedToSaveTheirsMetadata() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
setRuntime(workspace.getId(), WorkspaceStatus.RUNNING, "env-name");
doThrow(new SnapshotException("test")).when(snapshotDao).replaceSnapshots(any(), any(), any());
SnapshotImpl snapshot = mock(SnapshotImpl.class);
when(envEngine.saveSnapshot(any(), any())).thenReturn(snapshot);
try {
runtimes.snapshot(workspace.getId());
} catch (ServerException x) {
assertEquals(x.getMessage(), "test");
}
verify(snapshotDao).replaceSnapshots(any(), any(), snapshotsCaptor.capture());
verify(envEngine, times(snapshotsCaptor.getValue().size())).removeSnapshot(snapshot);
verifyEventsSequence(event(workspace.getId(), WorkspaceStatus.RUNNING, WorkspaceStatus.SNAPSHOTTING, EventType.SNAPSHOT_CREATING, null), event(workspace.getId(), WorkspaceStatus.SNAPSHOTTING, WorkspaceStatus.RUNNING, EventType.SNAPSHOT_CREATION_ERROR, "test"));
}
use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class WorkspaceRuntimesTest method stopsTheRunningWorkspaceWhileServerExceptionOccurs.
@Test
public void stopsTheRunningWorkspaceWhileServerExceptionOccurs() throws Exception {
setRuntime("workspace", WorkspaceStatus.RUNNING);
doThrow(new ServerException("no!")).when(envEngine).stop("workspace");
try {
runtimes.stop("workspace");
} catch (ServerException x) {
assertEquals(x.getMessage(), "no!");
}
verify(envEngine).stop("workspace");
assertFalse(runtimeStates.containsKey("workspace"));
verifyEventsSequence(event("workspace", WorkspaceStatus.RUNNING, WorkspaceStatus.STOPPING, EventType.STOPPING, null), event("workspace", WorkspaceStatus.STOPPING, WorkspaceStatus.STOPPED, EventType.ERROR, "no!"));
}
use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class WorkspaceManagerTest method shouldStopWorkspaceEventIfSnapshotCreationFailed.
@Test
public void shouldStopWorkspaceEventIfSnapshotCreationFailed() throws Exception {
WorkspaceImpl workspace = createAndMockWorkspace();
mockRuntime(workspace, RUNNING);
doThrow(new ServerException("Test")).when(runtimes).snapshot(workspace.getId());
workspaceManager.stopWorkspace(workspace.getId(), true);
captureRunAsyncCallsAndRunSynchronously();
verify(runtimes).stop(any());
}
Aggregations