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 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. ja v a 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()); }
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 ww w . j a v a 2s . c om*/ 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 w ww . j av a2 s . co 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.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 www. j a v a 2 s .co 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);//ww w .ja va 2 s . c o 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);//from w w w. j av a 2 s.c o m 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
@Test public void testSelectManifestActionEnablement() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project1 = projects.createProject("pr1"); IProject project2 = projects.createProject("pr2"); final String appName1 = "app1"; final String appName2 = "app2"; MockCFApplication cfApp1 = space.defApp(appName1); MockCFApplication cfApp2 = space.defApp(appName2); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName1, appName2); CloudAppDashElement app1 = model.getApplication(appName1); CloudAppDashElement app2 = model.getApplication(appName2); app1.setProject(project1);//www. j a va 2 s.c om app2.setProject(project2); IAction action = actions.getSelectManifestAction(); assertTrue(harness.selection.getElements().isEmpty()); assertFalse(action.isEnabled()); harness.selection.setElements(ImmutableSet.of(app1)); assertNotNull(app1.getProject()); assertTrue(action.isEnabled()); harness.selection.setElements(ImmutableSet.of(app1, app2)); assertFalse(action.isEnabled()); app1.setProject(null); harness.selection.setElements(ImmutableSet.of(app1)); assertFalse(action.isEnabled()); harness.selection.setElements(ImmutableSet.of(app2)); assertTrue(action.isEnabled()); action.run(); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testSelectManifestAction() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createProject("pr"); final String appName = "app"; IFile manifestFile = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n"); space.defApp(appName);/*from w ww.jav a 2 s . co m*/ CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName); CloudAppDashElement app = model.getApplication(appName); app.setProject(project); harness.selection.setElements(ImmutableSet.of(app)); harness.answerDeploymentPrompt(ui, manifestFile); assertNull(app.getDeploymentManifestFile()); actions.getSelectManifestAction().run(); waitForJobsToComplete(); assertEquals(manifestFile, app.getDeploymentManifestFile()); verify(ui).promptApplicationDeploymentProperties(any()); verifyNoMoreInteractions(ui); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void updateTargetPasswordInvalid() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); String appName = "someApp"; space.defApp(appName);/*from w w w. j a v a 2 s .c o m*/ CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName); harness.sectionSelection.setValue(model); IAction updatePassword = actions.getUpdatePasswordAction(); assertTrue(updatePassword.isEnabled()); harness.answerPasswordPrompt(ui, (d) -> { d.getPasswordVar().setValue(targetParams.getCredentials().getPassword()); d.performOk(); }); updatePassword.run(); waitForJobsToComplete(); assertNotNull(model.getApplication(appName)); assertTrue(model.isConnected()); assertEquals(RefreshState.READY, model.getRefreshState()); // Clear out any mocks on the ui object set above reset(ui); harness.answerPasswordPrompt(ui, (d) -> { d.getPasswordVar().setValue("wrong password"); d.performOk(); }); updatePassword.run(); waitForJobsToComplete(); assertNull(model.getApplication(appName)); assertFalse(model.isConnected()); assertTrue(model.getRefreshState().isError()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void updateTargetPasswordAndStoreNothing() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); String appName = "someApp"; space.defApp(appName);//from w w w. ja v a2 s . c om CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName); harness.sectionSelection.setValue(model); IAction updatePassword = actions.getUpdatePasswordAction(); assertTrue(updatePassword.isEnabled()); // Clear out any mocks on the ui object reset(ui); harness.answerPasswordPrompt(ui, (d) -> { d.getPasswordVar().setValue(targetParams.getCredentials().getPassword()); d.getStoreVar().setValue(StoreCredentialsMode.STORE_NOTHING); d.performOk(); }); updatePassword.run(); waitForJobsToComplete(); assertTrue(model.isConnected()); assertNotNull(model.getApplication(appName)); assertEquals(RefreshState.READY, model.getRefreshState()); { assertNull(harness.getCredentialsStore().getCredentials(harness.secureStoreKey(model))); assertNull(harness.getPrivateStore().get(harness.privateStoreKey(model))); } actions.getToggleTargetConnectionAction().run(); waitForJobsToComplete(); assertFalse(model.isConnected()); // Clear out any mocks on the ui object to get the right count below reset(ui); actions.getToggleTargetConnectionAction().run(); waitForJobsToComplete(); assertFalse(model.isConnected()); assertEquals(RefreshState.READY, model.getRefreshState()); assertNull(model.getApplication(appName)); verify(ui).openPasswordDialog(any()); verifyNoMoreInteractions(ui); }