Example usage for org.springframework.ide.eclipse.boot.dash.test BootJarPackagingTest packageAsJar

List of usage examples for org.springframework.ide.eclipse.boot.dash.test BootJarPackagingTest packageAsJar

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.test BootJarPackagingTest packageAsJar.

Prototype

public static File packageAsJar(IProject project, UserInteractions ui) throws Exception 

Source Link

Usage

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

@Test
public void testDeployManifestWithoutPathAttribute() throws Exception {
    String appName = "foo";
    CFClientParams targetParams = CfTestTargetParams.fromEnv();
    MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName());
    CloudFoundryBootDashModel model = harness.createCfTarget(targetParams);

    IProject project = projects.createBootWebProject("empty-web-app");
    IFile manifestFile = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n");
    File referenceJar = BootJarPackagingTest.packageAsJar(project, ui);

    harness.answerDeploymentPrompt(ui, manifestFile);
    model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING);
    waitForApps(model, appName);/*from w w w.ja  va2  s . com*/

    CloudAppDashElement app = model.getApplication(appName);
    waitForState(app, RunState.RUNNING, APP_DEPLOY_TIMEOUT);

    System.out.println("platform location = '" + Platform.getLocation() + "'");
    assertDeployedBytes(referenceJar, space.getApplication(appName));
}

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);/*  www.j av 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

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

    CancelationTokens cancelationTokens = new CancelationTokens();
    try (CFPushArguments params = new CFPushArguments()) {
        params.setAppName(appName);//from  w w  w. j  a v  a2 s. c o  m
        params.setRoutes(appName + "." + CFAPPS_IO());
        params.setApplicationData(jarFile);

        long starting = System.currentTimeMillis();
        Future<Void> pushResult = doAsync(() -> {
            System.out.println("Pushing...");
            client.push(params, cancelationTokens.create());
            long duration = System.currentTimeMillis() - starting;
            System.out.println("Pushing took: " + duration + " ms");
        });
        Thread.sleep(Duration.ofSeconds(10).toMillis());
        long cancelTime = System.currentTimeMillis();
        System.out.println("Canceling...");
        cancelationTokens.cancelAll();

        try {
            pushResult.get(5, TimeUnit.SECONDS); // Cancel should happen pretty 'fast'!
            fail("push completed but it should have been canceled");
        } catch (ExecutionException e) { // real exception is wrapped in EE by Future.get
            e.printStackTrace();
            long duration = System.currentTimeMillis() - cancelTime;
            assertEquals(OperationCanceledException.class, ExceptionUtil.getDeepestCause(e).getClass());
            System.out.println("\nPush Canceled after: " + duration + " ms");
        }
    }
}