List of usage examples for org.springframework.ide.eclipse.boot.dash.test CfTestTargetParams fromEnv
public static CFClientParams fromEnv()
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testCreateCfTarget() throws Exception { CloudFoundryBootDashModel target = harness.createCfTarget(CfTestTargetParams.fromEnv()); assertNotNull(target);/*from ww w .ja v a 2s .c o m*/ assertNotNull(target.getRunTarget().getTargetProperties().getCredentials().getPassword()); assertEquals(1, harness.getCfRunTargetModels().size()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testCreateCfTargetAndStoreToken() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); CloudFoundryBootDashModel target = harness.createCfTarget(targetParams, StoreCredentialsMode.STORE_TOKEN); assertNotNull(target);/*w w w . java 2 s .com*/ assertTrue(target.isConnected()); assertNotNull(target.getRunTarget().getTargetProperties().getCredentials().getRefreshToken()); assertEquals(1, harness.getCfRunTargetModels().size()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
/** * Test that tests a bunch of things./*from w w w . j ava2s . co m*/ * TODO: It isn't good practice to create 'test everything' tests... * but we do it anyway because ramping up a test that deploys an app takes about 90 seconds... * Maybe we can factor this better somehow so we have separate tests, but only deploy app once? */ @Test public void testDeployAppAndDeleteAndStuff() throws Exception { harness.createCfTarget(CfTestTargetParams.fromEnv()); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); final BootProjectDashElement project = harness .getElementFor(projects.createBootProject("to-deploy", withStarters("actuator", "web"))); final String appName = appHarness.randomAppName(); harness.answerDeploymentPrompt(ui, appName, appName); model.add(ImmutableList.<Object>of(project), ui); //The resulting deploy is asynchronous new ACondition("wait for app '" + appName + "'to appear", APP_IS_VISIBLE_TIMEOUT) { public boolean test() throws Exception { assertNotNull(model.getApplication(appName)); return true; } }; new ACondition("wait for app '" + appName + "'to be RUNNING", APP_DEPLOY_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.RUNNING, element.getRunState()); return true; } }; //Try to get request mappings new ACondition("wait for request mappings", FETCH_REQUEST_MAPPINGS_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); List<RequestMapping> mappings = element.getLiveRequestMappings(); assertNotNull(mappings); //Why is the test sometimes failing here? assertTrue(!mappings.isEmpty()); //Even though this is an 'empty' app should have some mappings, // for example an 'error' page. return true; } }; //Try to delete the app... reset(ui); when(ui.confirmOperation(eq("Deleting Elements"), anyString())).thenReturn(true); CloudAppDashElement app = model.getApplication(appName); app.getCloudModel().delete(ImmutableList.<BootDashElement>of(app), ui); new ACondition("wait for app to be deleted", APP_DELETE_TIMEOUT) { @Override public boolean test() throws Exception { assertNull(model.getApplication(appName)); return true; } }; }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testDeployAppIntoDebugMode() throws Exception { harness.createCfTarget(CfTestTargetParams.fromEnv()); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); final BootProjectDashElement project = harness .getElementFor(projects.createBootProject("to-deploy", withStarters("actuator", "web"))); final String appName = appHarness.randomAppName(); harness.answerDeploymentPrompt(ui, appName, appName); model.performDeployment(ImmutableSet.of(project.getProject()), ui, RunState.DEBUGGING); new ACondition("wait for app '" + appName + "'to be DEBUGGING", APP_DEPLOY_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.DEBUGGING, element.getRunState()); return true; }/*from w ww.j a va 2 s. c o m*/ }; }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testEnvVarsSetOnFirstDeploy() throws Exception { CloudFoundryBootDashModel target = harness.createCfTarget(CfTestTargetParams.fromEnv()); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); Map<String, String> env = new HashMap<>(); env.put("FOO", "something"); harness.answerDeploymentPrompt(ui, appName, appName, env); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); new ACondition("wait for app '" + appName + "'to be RUNNING", APP_DEPLOY_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.RUNNING, element.getRunState()); return true; }// w w w .j a v a 2 s .c o m }; Map<String, String> actualEnv = harness.fetchEnvironment(target, appName); assertEquals("something", actualEnv.get("FOO")); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testServicesBoundOnFirstDeploy() throws Exception { CloudFoundryBootDashModel target = harness.createCfTarget(CfTestTargetParams.fromEnv()); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); List<String> bindServices = ImmutableList.of(services.createTestService(), services.createTestService()); ACondition.waitFor("services exist " + bindServices, 30_000, () -> { Set<String> services = client.getServices().stream().map(CFServiceInstance::getName) .collect(Collectors.toSet()); System.out.println("services = " + services); assertTrue(services.containsAll(bindServices)); });/*w ww . j a va2 s. c o m*/ final String appName = appHarness.randomAppName(); harness.answerDeploymentPrompt(ui, appName, appName, bindServices); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); new ACondition("wait for app '" + appName + "'to be RUNNING", APP_DEPLOY_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.RUNNING, element.getRunState()); return true; } }; Set<String> actualServices = client.getBoundServicesSet(appName).block(); assertEquals(ImmutableSet.copyOf(bindServices), actualServices); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testDeployManifestWithAbsolutePathAttribute() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); IProject project = projects.createProject("to-deploy"); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForJobsToComplete();// w ww.j av a 2s. c o m File zipFile = getTestZip("testapp"); final String appName = appHarness.randomAppName(); IFile manifestFile = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n" + " path: " + zipFile.getAbsolutePath() + "\n" + " buildpack: staticfile_buildpack"); harness.answerDeploymentPrompt(ui, manifestFile); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); ACondition.waitFor("app to appear", APP_IS_VISIBLE_TIMEOUT, () -> { assertNotNull(model.getApplication(appName)); }); CloudAppDashElement app = model.getApplication(appName); ACondition.waitFor("app to be running", APP_DEPLOY_TIMEOUT, () -> { assertEquals(RunState.RUNNING, app.getRunState()); String url = pathJoin(app.getUrl(), "test.txt"); assertEquals(url, "some content here\n", IOUtils.toString(new URL(url))); }); verify(ui).promptApplicationDeploymentProperties(any()); verifyNoMoreInteractions(ui); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void deleteService() throws Exception { String serviceName = services.createTestService(); CFClientParams targetParams = CfTestTargetParams.fromEnv(); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); ACondition.waitFor("service to appear", APP_IS_VISIBLE_TIMEOUT, () -> { assertNotNull(model.getService(serviceName)); });//from ww w. j a v a 2 s. c o m when(ui.confirmOperation(contains("Deleting"), contains("Are you sure that you want to delete"))) .thenReturn(true); CloudServiceInstanceDashElement service = model.getService(serviceName); model.canDelete(service); model.delete(ImmutableSet.of(service), ui); ACondition.waitFor("service to disapear", SERVICE_DELETE_TIMEOUT, () -> { assertNull(model.getService(serviceName)); }); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testCreateCfTarget() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel target = harness.createCfTarget(targetParams, StoreCredentialsMode.STORE_PASSWORD); assertNotNull(target);/*from ww w . j a v a 2 s . c o m*/ assertNotNull(target.getRunTarget().getTargetProperties().getCredentials().getPassword()); assertEquals(1, harness.getCfRunTargetModels().size()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testCreateCfTargetAndStorePassword() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); {//from w w w . jav a 2 s .c o m clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel target = harness.createCfTarget(targetParams, StoreCredentialsMode.STORE_PASSWORD); assertNotNull(target); assertNotNull(target.getRunTarget().getTargetProperties().getCredentials().getPassword()); assertEquals(1, harness.getCfRunTargetModels().size()); SecuredCredentialsStore store = harness.getCredentialsStore(); assertTrue(store.isUnlocked()); } harness.reload(); { CloudFoundryBootDashModel target = harness.getCfTargetModel(); String expectedPass = targetParams.getCredentials().getPassword(); assertNotNull(target); String password = target.getRunTarget().getTargetProperties().getCredentials().getPassword(); assertEquals(expectedPass, password); assertEquals(StoreCredentialsMode.STORE_PASSWORD, target.getRunTarget().getTargetProperties().getStoreCredentials()); waitForJobsToComplete(); assertTrue(target.isConnected()); //should auto connect. verifyZeroInteractions(ui); //should not prompt for password (but used stored pass). { SecuredCredentialsStore store = harness.getCredentialsStore(); assertTrue(store.isUnlocked()); String key = harness.secureStoreKey(target); String storedCred = store.getCredentials(key); assertEquals(expectedPass, storedCred); } { IPropertyStore store = harness.getPrivateStore(); String key = harness.privateStoreKey(target); String storedCred = store.get(key); assertNull(storedCred); } } }