List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudAppDashElement getBaseRunStateExp
public LiveExpression<RunState> getBaseRunStateExp()
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void runstateBecomesUnknownWhenStartOperationFails() throws Exception { final String appName = "foo"; String projectName = "to-deploy"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); MockCFApplication app = space.defApp(appName); final IProject project = projects.createProject(projectName); final CloudFoundryBootDashModel target = harness.createCfTarget(targetParams); waitForApps(target, appName);//from w ww . java2s .co m CloudAppDashElement appElement = target.getApplication(appName); appElement.setProject(project); //The state refressh is asynch so until state becomes 'INACTIVE' it will be unknown. waitForState(appElement, RunState.INACTIVE, 3000); IAction restartAction = actions.getRestartOnlyApplicationAction(); RunStateHistory runstateHistory = new RunStateHistory(); appElement.getBaseRunStateExp().addListener(runstateHistory); doThrow(IOException.class).when(app).start(any()); System.out.println("restarting application..."); harness.selection.setElements(appElement); restartAction.run(); waitForState(appElement, RunState.UNKNOWN, 3000); runstateHistory.assertHistoryContains(RunState.INACTIVE, RunState.STARTING); runstateHistory.assertLast(RunState.UNKNOWN); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void stopCancelsStart() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator")); final String appName = "foo"; space.defApp(appName);//w w w. j a v a 2 s. c o m CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName); CloudAppDashElement app = model.getApplication(appName); app.setProject(project); waitForApps(model, appName); clientFactory.setAppStartDelay(TimeUnit.MINUTES, 2); app.getBaseRunStateExp().addListener(new ValueListener<RunState>() { @Override public void gotValue(LiveExpression<RunState> exp, RunState value) { System.out.println("Runstate -> " + value); } }); System.out.println("Restaring app..."); app.restart(RunState.RUNNING, ui); waitForState(app, RunState.STARTING, 30000); System.out.println("Stopping app..."); app.stopAsync(ui); waitForState(app, RunState.INACTIVE, 20000); System.out.println("Stopped!"); }