Browse Source

Polish

pull/6108/merge
Phillip Webb 10 years ago
parent
commit
5ab072be9c
  1. 4
      spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java
  2. 19
      spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

4
spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java

@ -41,6 +41,8 @@ import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.li @@ -41,6 +41,8 @@ import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.li
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
/**
* Tests for {@link AutoConfigureRestDocs}.
*
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ -61,7 +63,7 @@ public class RestDocsAutoConfigurationAdvancedConfigurationIntegrationTests { @@ -61,7 +63,7 @@ public class RestDocsAutoConfigurationAdvancedConfigurationIntegrationTests {
@Test
public void snippetGeneration() throws Exception {
this.document.snippets(links(
this.document.document(links(
linkWithRel("self").description("Canonical location of this resource")));
this.mvc.perform(get("/"));
File defaultSnippetsDir = new File(

19
spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

@ -682,20 +682,17 @@ public class SpringApplicationTests { @@ -682,20 +682,17 @@ public class SpringApplicationTests {
application.setApplicationContextClass(SpyApplicationContext.class);
final LinkedHashSet<ApplicationEvent> events = new LinkedHashSet<ApplicationEvent>();
application.addListeners(new ApplicationListener<ApplicationEvent>() {
@Override
public void onApplicationEvent(ApplicationEvent event) {
events.add(event);
}
});
this.context = application.run();
assertThat(events).hasAtLeastOneElementOfType(ApplicationPreparedEvent.class);
assertThat(events).hasAtLeastOneElementOfType(ContextRefreshedEvent.class);
ApplicationListener<ApplicationEvent> listener = this.context.getBean(
"testApplicationListener", ApplicationListener.class);
verify(listener).onApplicationEvent(argThat(isA(ContextRefreshedEvent.class)));
verify(listener).onApplicationEvent(argThat(isA(ApplicationReadyEvent.class)));
verifyNoMoreInteractions(listener);
verifyTestListenerEvents();
}
@Test
@ -705,17 +702,23 @@ public class SpringApplicationTests { @@ -705,17 +702,23 @@ public class SpringApplicationTests {
application.setApplicationContextClass(SpyApplicationContext.class);
final LinkedHashSet<ApplicationEvent> events = new LinkedHashSet<ApplicationEvent>();
application.addListeners(new ApplicationListener<ApplicationEvent>() {
@Override
public void onApplicationEvent(ApplicationEvent event) {
events.add(event);
}
});
this.context = application.run();
assertThat(events).hasAtLeastOneElementOfType(ApplicationPreparedEvent.class);
assertThat(events).hasAtLeastOneElementOfType(ContextRefreshedEvent.class);
verifyTestListenerEvents();
}
ApplicationListener<ApplicationEvent> listener = this.context.getBean(
"testApplicationListener", ApplicationListener.class);
@SuppressWarnings("unchecked")
private void verifyTestListenerEvents() {
ApplicationListener<ApplicationEvent> listener = this.context
.getBean("testApplicationListener", ApplicationListener.class);
verify(listener).onApplicationEvent(argThat(isA(ContextRefreshedEvent.class)));
verify(listener).onApplicationEvent(argThat(isA(ApplicationReadyEvent.class)));
verifyNoMoreInteractions(listener);

Loading…
Cancel
Save