List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudFoundryBootDashModel performDeployment
public void performDeployment(final Set<IProject> projectsToDeploy, final UserInteractions ui, RunState runOrDebug) throws Exception
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);/* w ww. j a v a 2 s . 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 manifestDiffDialogChooseUseManfifest() throws Exception { //Setup initial state for our test 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")); IFile manifest = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n" + " memory: 1111M\n"); harness.answerDeploymentPrompt(ui, manifest); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);/*from w w w . ja v a 2 s . c o m*/ CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, APP_DEPLOY_TIMEOUT); { MockCFApplication appInCloud = space.getApplication(appName); assertEquals(1111, appInCloud.getMemory()); Mockito.reset(ui); //// real test begins here appInCloud.setMemory(2222); } harness.answerManifestDiffDialog(ui, (ManifestDiffDialogModel dialog) -> { //??? code to check what's in the dialog??? return ManifestDiffDialogModel.Result.USE_MANIFEST; }); app.restart(RunState.RUNNING, ui); waitForJobsToComplete(); { MockCFApplication appInCloud = space.getApplication(appName); assertEquals(2, appInCloud.getPushCount()); assertEquals(RunState.RUNNING, app.getRunState()); assertEquals(1111, appInCloud.getMemory()); assertEquals(1111, (int) app.getMemory()); } }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void manifestDiffDialogChooseForgetManfifest() throws Exception { //Setup initial state for our test 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")); IFile manifest = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n" + " memory: 1111M\n"); harness.answerDeploymentPrompt(ui, manifest); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);/*from www .j av a 2s. com*/ CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, APP_DEPLOY_TIMEOUT); MockCFApplication appInCloud = space.getApplication(appName); assertEquals(1111, appInCloud.getMemory()); Mockito.reset(ui); //// real test begins here appInCloud.setMemory(2222); harness.answerManifestDiffDialog(ui, (ManifestDiffDialogModel dialog) -> { //??? code to check what's in the dialog??? return ManifestDiffDialogModel.Result.FORGET_MANIFEST; }); app.restart(RunState.RUNNING, ui); waitForJobsToComplete(); assertEquals(2, appInCloud.getPushCount()); assertEquals(RunState.RUNNING, app.getRunState()); assertEquals(2222, appInCloud.getMemory()); assertEquals(2222, (int) app.getMemory()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testDeployManifestWithAbsolutePathAttribute() throws Exception { final String appName = "foo"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createProject("to-deploy"); File zipFile = getTestZip("testapp"); IFile manifestFile = createFile(project, "manifest.yml", "applications:\n" + "- name: foo\n" + " path: " + zipFile.getAbsolutePath() + "\n" + " buildpack: staticfile_buildpack"); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); harness.answerDeploymentPrompt(ui, manifestFile); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, "foo"); CloudAppDashElement app = model.getApplication("foo"); waitForState(app, RunState.RUNNING, APP_DELETE_TIMEOUT); assertEquals(project, app.getProject()); assertEquals("some content here\n", space.getApplication(appName).getFileContents("test.txt")); verify(ui).promptApplicationDeploymentProperties(any()); verifyNoMoreInteractions(ui);//from w w w. j a va 2 s. c o m }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testDeployManifestWithRelativePathAttribute() throws Exception { final String appName = "foo"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createProject("to-deploy"); File zipFile = getTestZip("testapp"); project.getFolder("zips").create(true, true, new NullProgressMonitor()); project.getFolder("manifests").create(true, true, new NullProgressMonitor()); createFile(project, "zips/testapp.zip", zipFile); IFile manifestFile = createFile(project, "manifests/manifest.yml", "applications:\n" + "- name: foo\n" + " path: ../zips/testapp.zip\n" + " buildpack: staticfile_buildpack"); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); harness.answerDeploymentPrompt(ui, manifestFile); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, "foo"); CloudAppDashElement app = model.getApplication("foo"); waitForState(app, RunState.RUNNING, APP_DEPLOY_TIMEOUT); assertEquals(project, app.getProject()); assertEquals("some content here\n", space.getApplication(appName).getFileContents("test.txt")); verify(ui).promptApplicationDeploymentProperties(any()); verifyNoMoreInteractions(ui);/*from w w w .j a v a2 s.co m*/ }
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);/* ww w . j av a 2 s . c om*/ 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.CloudFoundryBootDashModelMockingTest.java
protected CloudAppDashElement deployApp(final CloudFoundryBootDashModel model, final String appName, IProject project) throws Exception { harness.answerDeploymentPrompt(ui, appName, appName); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);/*from w ww.j a va2s. c om*/ new ACondition("wait for app '" + appName + "'to be RUNNING", 30000) { //why so long? JDT searching for main type. public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.RUNNING, element.getRunState()); return true; } }; return model.getApplication(appName); }