Example usage for org.springframework.ide.eclipse.boot.dash.util CancelationTokens NULL

List of usage examples for org.springframework.ide.eclipse.boot.dash.util CancelationTokens NULL

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.util CancelationTokens NULL.

Prototype

CancelationToken NULL

To view the source code for org.springframework.ide.eclipse.boot.dash.util CancelationTokens NULL.

Click Source Link

Document

An uncancelable token that can be used by operations that don't need cancelation support.

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);/*from   w ww . j  av a  2s . c o m*/

    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   ww  w .  j  av a  2 s  .co m*/

    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);//ww  w .ja  v a2  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());
}

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

@Test
public void testGetApplicationDetails() throws Exception {
    String appName = appHarness.randomAppName();

    try (CFPushArguments params = new CFPushArguments()) {
        params.setAppName(appName);/*from  w w  w. j av a 2 s .c  om*/
        params.setApplicationData(getTestZip("testapp"));
        params.setBuildpack("staticfile_buildpack");
        params.setNoStart(true);
        push(params);
    }

    {
        CFApplicationDetail appDetails = client.getApplication(appName);
        assertEquals(0, appDetails.getRunningInstances());
        assertEquals(CFAppState.STOPPED, appDetails.getState());
        assertEquals(ImmutableList.of(), appDetails.getInstanceDetails());
    }

    client.restartApplication(appName, CancelationTokens.NULL);
    {
        CFApplicationDetail appDetails = client.getApplication(appName);
        assertEquals(1, appDetails.getRunningInstances());
        assertEquals(CFAppState.STARTED, appDetails.getState());
        assertEquals(1, appDetails.getInstanceDetails().size());
    }
}

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

@Test
public void startCanBeCanceled() throws Exception {
    IProject project = projects.createBootWebProject("slow-starter");
    File jarFile = BootJarPackagingTest.packageAsJar(project, ui);

    String appName = appHarness.randomAppName();
    try (CFPushArguments params = new CFPushArguments()) {
        params.setAppName(appName);/*from ww w .  j  a  v a 2  s. com*/
        params.setRoutes(appName + "." + CFAPPS_IO());
        params.setApplicationData(jarFile);
        params.setNoStart(true);

        long starting = System.currentTimeMillis();
        System.out.println("Pushing...");
        client.push(params, CancelationTokens.NULL);
        long duration = System.currentTimeMillis() - starting;
        System.out.println("Pushing took: " + duration + " ms");
    }

    CancelationTokens cancelationTokens = new CancelationTokens();
    long starting = System.currentTimeMillis();
    System.out.println("Starting...");
    Future<Void> startResult = doAsync(() -> {
        client.restartApplication(appName, cancelationTokens.create());
        long duration = System.currentTimeMillis() - starting;
        System.out.println("started in " + duration + " ms");
    });

    Thread.sleep(5000);
    long cancelTime = System.currentTimeMillis();
    cancelationTokens.cancelAll();
    try {
        startResult.get(5, TimeUnit.SECONDS);
    } catch (ExecutionException e) {
        e.printStackTrace();
        long duration = System.currentTimeMillis() - cancelTime;
        assertEquals(OperationCanceledException.class, ExceptionUtil.getDeepestCause(e).getClass());
        System.out.println("\nRestart Canceled after " + duration + " ms");
    }
}

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

private void push(CFPushArguments _params) throws Exception {
    try (CFPushArguments params = _params) {
        client.push(params, CancelationTokens.NULL);
    }/*from   w ww.  j  a  v  a  2  s .  c o m*/
}