Example usage for org.springframework.ide.eclipse.boot.dash.test.mocks MockCFApplication start

List of usage examples for org.springframework.ide.eclipse.boot.dash.test.mocks MockCFApplication start

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.test.mocks MockCFApplication start.

Prototype

public void start(CancelationToken cancelationToken) throws Exception 

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java

@Test
public void testRefreshAppsRunState() throws Exception {
    CFClientParams targetParams = CfTestTargetParams.fromEnv();

    MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName());

    final MockCFApplication foo = space.defApp("foo");
    space.defApp("bar");

    final CloudFoundryBootDashModel target = harness.createCfTarget(targetParams);

    waitForApps(target, "foo", "bar");

    foo.start(CancelationTokens.NULL);

    target.refresh(ui);/*w w w. ja  va2 s. c om*/

    new ACondition("wait for app states", 3000) {
        @Override
        public boolean test() throws Exception {
            ImmutableSet<String> appNames = getNames(target.getApplications().getValues());
            assertEquals(ImmutableSet.of("foo", "bar"), appNames);
            CloudAppDashElement appElement = harness.getCfTargetModel().getApplication("foo");
            assertEquals(RunState.RUNNING, appElement.getRunState());

            appElement = harness.getCfTargetModel().getApplication("bar");
            assertEquals(RunState.INACTIVE, appElement.getRunState());

            return true;
        }
    };
}

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java

@Test
public void manifestDiffDialogNotShownWhenNothingChanged() throws Exception {
    final String appName = "foo";

    CFClientParams targetParams = CfTestTargetParams.fromEnv();
    MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName());
    IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator"));
    createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n");
    MockCFApplication deployedApp = space.defApp(appName);
    deployedApp.start(CancelationTokens.NULL);

    CloudFoundryBootDashModel model = harness.createCfTarget(targetParams);
    waitForApps(model, appName);/*from w  w w  .jav  a 2 s.c om*/

    CloudAppDashElement app = model.getApplication(appName);
    app.setDeploymentManifestFile(project.getFile("manifest.yml"));
    app.setProject(project);
    assertEquals(1, app.getActualInstances());

    //      deployedApp.scaleInstances(2); // change it 'externally'
    assertEquals(1, app.getActualInstances()); //The model doesn't know yet that it has changed!

    //      harness.answerDeploymentPrompt(ui, appName, appName);

    app.restart(RunState.RUNNING, ui);

    waitForJobsToComplete();

    //If no change was detected the manfiest compare dialog shouldn't have popped.
    verify(ui, never()).openManifestDiffDialog(any());
}

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java

@Test
public void manifestDiffDialogShownWhenInstancesChangedExternally() throws Exception {
    final String appName = "foo";

    CFClientParams targetParams = CfTestTargetParams.fromEnv();
    MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName());
    IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator"));
    createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n");
    MockCFApplication deployedApp = space.defApp(appName);
    deployedApp.start(CancelationTokens.NULL);

    CloudFoundryBootDashModel model = harness.createCfTarget(targetParams);
    waitForApps(model, appName);/*from w w w. j a  va  2 s. c o  m*/
    waitForJobsToComplete();

    CloudAppDashElement app = model.getApplication(appName);
    app.setDeploymentManifestFile(project.getFile("manifest.yml"));
    app.setProject(project);
    assertEquals(1, app.getActualInstances());

    deployedApp.scaleInstances(2); // change it 'externally'
    assertEquals(1, app.getActualInstances()); //The model doesn't know yet that it has changed!

    app.restart(RunState.RUNNING, ui);

    waitForJobsToComplete();

    //If the change was detected the deployment props dialog should have popped exactly once.
    verify(ui).openManifestDiffDialog(any());
}