List of usage examples for org.springframework.ide.eclipse.boot.util RetryUtil retryWhen
public static void retryWhen(String name, int tries, Predicate<Throwable> when, Thunk task) throws Exception
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryClientTest.java
@Test public void getServices() throws Exception { RetryUtil.retryWhen("getServices", 5, FLAKY_SERVICE_BROKER, () -> { String[] serviceNames = new String[3]; Set<String> userProvided = new HashSet<>(); for (int i = 0; i < serviceNames.length; i++) { if (i % 2 == 0) { serviceNames[i] = services.createTestService(); } else { serviceNames[i] = services.createTestUserProvidedService(); userProvided.add(serviceNames[i]); }/*from ww w . j av a 2s . c om*/ } List<CFServiceInstance> actualServices = client.getServices(); ImmutableSet<String> actualServiceNames = ImmutableSet .copyOf(actualServices.stream().map(CFServiceInstance::getName).collect(Collectors.toList())); for (CFServiceInstance s : actualServices) { //Note: because these test on CI host run in parallel with others using same space... // we should assume there might be 'extra stuff' on the space than what we just created here. //So only check that 'our stuff' exists and looks right and ignore the rest. String name = s.getName(); if (ImmutableSet.copyOf(serviceNames).contains(name)) { System.out.println("Verifying service: " + name); if (userProvided.contains(name)) { assertEquals("user-provided", s.getService()); System.out.println(" user provided => OK"); } else { assertEquals(services.getTestServiceAndPlan()[0], s.getService()); System.out.println(" getService() => OK"); String expectPlan = services.getTestServiceAndPlan()[1]; assertEquals(expectPlan, s.getPlan()); System.out.println(" getPlan() => OK"); assertIsURL(s.getDashboardUrl()); System.out.println(" getDashboardUrl() => OK"); assertIsURL(s.getDocumentationUrl()); System.out.println(" getDocumentationUrl() => OK"); assertText(s.getDescription()); System.out.println(" getDescription() => OK"); } } } for (String s : serviceNames) { assertTrue(s + " not found in " + actualServiceNames, actualServiceNames.contains(s)); } }); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryClientTest.java
@Test public void testServiceCreateAndDelete() throws Exception { RetryUtil.retryWhen("testServiceCreateAndDelete", 5, FLAKY_SERVICE_BROKER, () -> { String[] serviceNames = new String[2]; for (int i = 0; i < serviceNames.length; i++) { serviceNames[i] = services.randomServiceName(); }// w ww.ja v a 2 s . co m ; for (int i = 0; i < serviceNames.length; i++) { String serviceName = serviceNames[i]; if (i % 2 == 0) { System.out.println("Create service: " + serviceName); String[] serviceInfo = services.getTestServiceAndPlan(); client.createService(serviceName, serviceInfo[0], serviceInfo[1]) .block(CloudFoundryServicesHarness.CREATE_SERVICE_TIMEOUT); } else { System.out.println("Create user-provided service: " + serviceName); client.createUserProvidedService(serviceName, ImmutableMap.of()).block(); } } List<CFServiceInstance> services = client.getServices(); assertServices(services, serviceNames); for (String serviceName : serviceNames) { client.deleteServiceAsync(serviceName).block(); System.out.println("Deleted service: " + serviceName); } assertNoServices(client.getServices(), serviceNames); }); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryClientTest.java
@Test public void testGetBoundServices() throws Exception { RetryUtil.retryWhen("testGetBoundServices", 5, FLAKY_SERVICE_BROKER, () -> { String service1 = services.createTestService(); String service2 = services.createTestService(); String service3 = services.createTestService(); String appName = appHarness.randomAppName(); CFPushArguments params = new CFPushArguments(); params.setAppName(appName);/*www . ja v a 2 s .c o m*/ params.setApplicationData(getTestZip("testapp")); params.setBuildpack("staticfile_buildpack"); params.setServices(ImmutableList.of(service1, service2)); push(params); List<CFApplication> allApps = client.getApplicationsWithBasicInfo(); CFApplication app = null; for (CFApplication a : allApps) { if (a.getName().equals(appName)) { app = a; } } assertEquals(ImmutableSet.of(service1, service2), ImmutableSet.copyOf(app.getServices())); app = client.getApplication(appName); assertEquals(ImmutableSet.of(service1, service2), ImmutableSet.copyOf(app.getServices())); }); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryServicesHarness.java
public String createTestService() throws Exception { String name = randomServiceName(); RetryUtil.retryWhen("createTestService[" + name + "]", 5, FLAKY_SERVICE_BROKER, () -> { String[] serviceParams = getTestServiceAndPlan(); client.createService(name, serviceParams[0], serviceParams[1]).block(CREATE_SERVICE_TIMEOUT); });//from www . ja va2s. co m return name; }