Fixup test following dependency change

Since spring-boot-actuator-docs should not depend on a starter the log
file is now simulated.
pull/5900/merge
Phillip Webb 9 years ago
parent cf6212b955
commit 1bb2c4fc00

@ -64,6 +64,10 @@
<artifactId>liquibase-core</artifactId> <artifactId>liquibase-core</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId> <artifactId>spring-jdbc</artifactId>

@ -17,6 +17,7 @@
package org.springframework.boot.actuate.hypermedia; package org.springframework.boot.actuate.hypermedia;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; 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.MockMvc;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.ResultHandler; import org.springframework.test.web.servlet.ResultHandler;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; 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 String RESTDOCS_OUTPUT_DIR = "target/generated-snippets";
static final File LOG_FILE = new File("target/logs/spring.log");
@Autowired @Autowired
private MvcEndpoints mvcEndpoints; private MvcEndpoints mvcEndpoints;
@ -77,7 +81,7 @@ public class EndpointDocumentation {
@BeforeClass @BeforeClass
public static void clearLog() { public static void clearLog() {
new File("target/logs/spring.log").delete(); LOG_FILE.delete();
} }
@Test @Test
@ -88,6 +92,8 @@ public class EndpointDocumentation {
@Test @Test
public void partialLogfile() throws Exception { public void partialLogfile() throws Exception {
FileCopyUtils.copy(getClass().getResourceAsStream("log.txt"),
new FileOutputStream(LOG_FILE));
this.mockMvc this.mockMvc
.perform(get("/logfile").accept(MediaType.TEXT_PLAIN) .perform(get("/logfile").accept(MediaType.TEXT_PLAIN)
.header(HttpHeaders.RANGE, "bytes=0-1024")) .header(HttpHeaders.RANGE, "bytes=0-1024"))

@ -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<java.lang.String> 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<java.util.Map<java.lang.String, java.lang.Object>> 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"]
Loading…
Cancel
Save