Example usage for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudAppDashElement getBaseRunStateExp

List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudAppDashElement getBaseRunStateExp

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudAppDashElement getBaseRunStateExp.

Prototype

public LiveExpression<RunState> getBaseRunStateExp() 

Source Link

Document

This method is mostly meant just for test purposes.

Usage

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!");
}