List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudFoundryBootDashModel getApplication
private CloudAppDashElement getApplication(IProject project)
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void refreshClearsErrorState() throws Exception { final String appName = "foo"; String projectName = "to-deploy"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); space.defApp(appName);/*w ww .j a v a2 s. co m*/ final IProject project = projects.createProject(projectName); final CloudFoundryBootDashModel target = harness.createCfTarget(targetParams); waitForApps(target, appName); CloudAppDashElement appElement = target.getApplication(appName); appElement.setProject(project); waitForState(appElement, RunState.INACTIVE, 3000); //The state refressh is asynch so until state becomes 'INACTIVE' it will be unknown. appElement.setError(new IOException("Something bad happened")); waitForState(appElement, RunState.UNKNOWN, 3000); target.refresh(ui); waitForState(appElement, RunState.INACTIVE, 3000); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void simpleDeploy() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); harness.answerDeploymentPrompt(ui, appName, appName); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);// w ww . j av a 2 s . c o m CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, 10000); assertEquals((Integer) 1, space.getPushCount(appName).getValue()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void simpleDeployWithManifest() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); IFile manifestFile = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n" + " memory: 512M\n"); harness.answerDeploymentPrompt(ui, (dialog) -> { dialog.okPressed();/*from w w w.ja va 2 s . c o m*/ }); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName); CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, 10000); assertEquals((Integer) 1, space.getPushCount(appName).getValue()); assertEquals(manifestFile, app.getDeploymentManifestFile()); assertEquals(512, (int) app.getMemory()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void simpleDeployWithDefaultManualManifest() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = project.getName(); harness.answerDeploymentPrompt(ui, (dialog) -> { dialog.okPressed();//from w w w .ja va 2 s.c om }); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName); CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, 10000); assertEquals((Integer) 1, space.getPushCount(appName).getValue()); assertNull(app.getDeploymentManifestFile()); assertEquals(1024, (int) app.getMemory()); assertEquals(appName, app.getName()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void stopCancelsDeploy() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); clientFactory.setAppStartDelay(TimeUnit.MINUTES, 2); harness.answerDeploymentPrompt(ui, appName, appName); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);/* ww w. j av a 2s.c o m*/ CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.STARTING, 3000); ACondition.waitFor("stop hammering", 20000, () -> { app.stopAsync(ui); assertEquals(RunState.INACTIVE, app.getRunState()); }); //TODO: can we check that deployment related jobs are really canceled/finished somehow? // can we check that they didn't pop errors? }
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);/*from w w w . j a v a 2 s . c om*/ 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!"); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void stopCancelsRestartOnly() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createProject("to-deploy"); final String appName = "foo"; space.defApp(appName);//from ww w. j ava2 s . co 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.restartOnlyAsynch(ui, app.createCancelationToken()); waitForState(app, RunState.STARTING, 3000); app.stopAsync(ui); waitForState(app, RunState.INACTIVE, 20000); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void acceptDeployOfExistingApp() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = "foo"; MockCFApplication deployedApp = space.defApp(appName); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName);/* ww w . j a v a 2 s. c om*/ CloudAppDashElement app = model.getApplication(appName); app.setProject(null); assertNull(app.getProject()); assertEquals(RunState.INACTIVE, app.getRunState()); harness.answerDeploymentPrompt(ui, appName, appName); Mockito.doReturn(true).when(ui).confirmOperation(same("Replace Existing Application"), any()); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); System.out.println(app.getRunState()); waitForJobsToComplete(); System.out.println(app.getRunState()); assertEquals(project, app.getProject()); assertEquals(1, deployedApp.getPushCount()); verify(ui).confirmOperation(any(), any()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void cancelDeployOfExistingApp() 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"; MockCFApplication deployedApp = space.defApp(appName); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName);/*www . j ava 2s . c om*/ CloudAppDashElement app = model.getApplication(appName); app.setProject(null); assertNull(app.getProject()); harness.answerDeploymentPrompt(ui, appName, appName); doReturn(false).when(ui).confirmOperation(same("Replace Existing Application"), any()); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForJobsToComplete(); assertNull(app.getProject()); // since op was canceled it should not have set the project on the app. assertEquals(0, deployedApp.getPushCount()); // since op was canceled it should not have deployed the app. verify(ui).confirmOperation(any(), any()); }
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);// ww w . ja v a 2s. c o 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()); }