From 1bb2c4fc00ebc6a4513a6068979894db02a23675 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 10 May 2016 10:57:16 -0700 Subject: [PATCH] Fixup test following dependency change Since spring-boot-actuator-docs should not depend on a starter the log file is now simulated. --- spring-boot-actuator-docs/pom.xml | 4 ++++ .../hypermedia/EndpointDocumentation.java | 8 ++++++- .../boot/actuate/hypermedia/log.txt | 24 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 spring-boot-actuator-docs/src/restdoc/resources/org/springframework/boot/actuate/hypermedia/log.txt diff --git a/spring-boot-actuator-docs/pom.xml b/spring-boot-actuator-docs/pom.xml index 6ef2498e110..aa91619e8f8 100644 --- a/spring-boot-actuator-docs/pom.xml +++ b/spring-boot-actuator-docs/pom.xml @@ -64,6 +64,10 @@ liquibase-core provided + + org.springframework + spring-core + org.springframework spring-jdbc diff --git a/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java b/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java index a3fb1650c77..84213de8569 100644 --- a/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java +++ b/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java @@ -17,6 +17,7 @@ package org.springframework.boot.actuate.hypermedia; import java.io.File; +import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; @@ -48,6 +49,7 @@ import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.ResultHandler; +import org.springframework.util.FileCopyUtils; import org.springframework.util.StringUtils; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; @@ -66,6 +68,8 @@ public class EndpointDocumentation { static final String RESTDOCS_OUTPUT_DIR = "target/generated-snippets"; + static final File LOG_FILE = new File("target/logs/spring.log"); + @Autowired private MvcEndpoints mvcEndpoints; @@ -77,7 +81,7 @@ public class EndpointDocumentation { @BeforeClass public static void clearLog() { - new File("target/logs/spring.log").delete(); + LOG_FILE.delete(); } @Test @@ -88,6 +92,8 @@ public class EndpointDocumentation { @Test public void partialLogfile() throws Exception { + FileCopyUtils.copy(getClass().getResourceAsStream("log.txt"), + new FileOutputStream(LOG_FILE)); this.mockMvc .perform(get("/logfile").accept(MediaType.TEXT_PLAIN) .header(HttpHeaders.RANGE, "bytes=0-1024")) diff --git a/spring-boot-actuator-docs/src/restdoc/resources/org/springframework/boot/actuate/hypermedia/log.txt b/spring-boot-actuator-docs/src/restdoc/resources/org/springframework/boot/actuate/hypermedia/log.txt new file mode 100644 index 00000000000..5d282499951 --- /dev/null +++ b/spring-boot-actuator-docs/src/restdoc/resources/org/springframework/boot/actuate/hypermedia/log.txt @@ -0,0 +1,24 @@ +2016-05-10 10:55:45.405 INFO 40532 --- [ main] sanity.SanityCheckApplication : Starting SanityCheckApplication on pwmbp with PID 40532 (/Users/pwebb/projects/spring-boot/samples/spring-boot-sanity-check/target/classes started by pwebb in /Users/pwebb/projects/spring-boot/samples/spring-boot-sanity-check) +2016-05-10 10:55:45.408 INFO 40532 --- [ main] sanity.SanityCheckApplication : No active profile set, falling back to default profiles: default +2016-05-10 10:55:45.473 INFO 40532 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@59e5ddf: startup date [Tue May 10 10:55:45 PDT 2016]; root of context hierarchy +2016-05-10 10:55:47.076 INFO 40532 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) +2016-05-10 10:55:47.088 INFO 40532 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat +2016-05-10 10:55:47.090 INFO 40532 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.33 +2016-05-10 10:55:47.173 INFO 40532 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +2016-05-10 10:55:47.173 INFO 40532 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1705 ms +2016-05-10 10:55:47.486 INFO 40532 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] +2016-05-10 10:55:47.489 INFO 40532 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] +2016-05-10 10:55:47.490 INFO 40532 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] +2016-05-10 10:55:47.490 INFO 40532 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] +2016-05-10 10:55:47.490 INFO 40532 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] +2016-05-10 10:55:47.763 INFO 40532 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@59e5ddf: startup date [Tue May 10 10:55:45 PDT 2016]; root of context hierarchy +2016-05-10 10:55:47.826 INFO 40532 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public org.springframework.http.ResponseEntity sanity.MyController.hello() +2016-05-10 10:55:47.829 INFO 40532 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) +2016-05-10 10:55:47.830 INFO 40532 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) +2016-05-10 10:55:47.864 INFO 40532 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] +2016-05-10 10:55:47.864 INFO 40532 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] +2016-05-10 10:55:47.908 INFO 40532 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] +2016-05-10 10:55:48.208 WARN 40532 --- [ main] arterDepricationWarningAutoConfiguration : spring-boot-starter-redis is deprecated as of Spring Boot 1.4, please migrate to spring-boot-starter-data-redis +2016-05-10 10:55:48.268 INFO 40532 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup +2016-05-10 10:55:48.320 ERROR 40532 --- [ main] o.a.coyote.http11.Http11NioProtocol : Failed to start end point associated with ProtocolHandler ["http-nio-8080"] +