BAEL-859 (updated) How to display/list all Spring-managed beans? (#2064)

* Separating displayAllBeans logic from main method

* Removing as 'Person' bean is no longer used

* Removing as 'Person' bean is no longer used

* Removing as 'Person' bean is no longer used

* Added FooService and FooController

* Changed test cases as per new configuration

* Template to handle front-end view

* Fixed spacing issue

* Fixed spaces

* Fixed spacing issue
This commit is contained in:
ramansahasi
2017-06-13 20:43:16 +05:30
committed by maibin
parent 74aa2c9ec9
commit 69b4a05eb8
8 changed files with 60 additions and 58 deletions

View File

@@ -44,9 +44,8 @@ public class DisplayBeanIntegrationTest {
@Test
public void givenRestTemplate_whenAccessServerUrl_thenHttpStatusOK() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.testRestTemplate.getForEntity(
"http://localhost:" + this.port + "/getPerson", Map.class);
ResponseEntity<String> entity = this.testRestTemplate.getForEntity(
"http://localhost:" + this.port + "/displayallbeans", String.class);
then(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@@ -69,8 +68,8 @@ public class DisplayBeanIntegrationTest {
List<Map<String, Object>> allBeans = (List) ((Map) entity.getBody().get(0)).get("beans");
List<String> beanNamesList = allBeans.stream().map(x -> (String) x.get("bean")).collect(Collectors.toList());
assertThat( beanNamesList, hasItem("personController"));
assertThat( beanNamesList, hasItem("person"));
assertThat( beanNamesList, hasItem("fooController"));
assertThat( beanNamesList, hasItem("fooService"));
}
@Test
@@ -78,7 +77,7 @@ public class DisplayBeanIntegrationTest {
String[] beanNames = context.getBeanDefinitionNames();
List<String> beanNamesList = Arrays.asList(beanNames);
assertTrue(beanNamesList.contains("personController"));
assertTrue(beanNamesList.contains("person"));
assertTrue(beanNamesList.contains("fooController"));
assertTrue(beanNamesList.contains("fooService"));
}
}