ThreadDumpEndpointDocumentationTests.java (spring-boot-2.7.3) | : | ThreadDumpEndpointDocumentationTests.java (spring-boot-2.7.4) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright 2012-2021 the original author or authors. | * Copyright 2012-2022 the original author or authors. | |||
* | * | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | * You may obtain a copy of the License at | |||
* | * | |||
* https://www.apache.org/licenses/LICENSE-2.0 | * https://www.apache.org/licenses/LICENSE-2.0 | |||
* | * | |||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
skipping to change at line 190 | skipping to change at line 190 | |||
+ "monitoring is disabled")))); | + "monitoring is disabled")))); | |||
latch.countDown(); | latch.countDown(); | |||
} | } | |||
@Test | @Test | |||
void textThreadDump() throws Exception { | void textThreadDump() throws Exception { | |||
this.mockMvc.perform(get("/actuator/threaddump").accept(MediaType .TEXT_PLAIN)).andExpect(status().isOk()) | this.mockMvc.perform(get("/actuator/threaddump").accept(MediaType .TEXT_PLAIN)).andExpect(status().isOk()) | |||
.andDo(MockMvcRestDocumentation.document("threadd ump/text", | .andDo(MockMvcRestDocumentation.document("threadd ump/text", | |||
preprocessResponse(new ContentMod ifyingOperationPreprocessor((bytes, mediaType) -> { | preprocessResponse(new ContentMod ifyingOperationPreprocessor((bytes, mediaType) -> { | |||
String content = new Stri ng(bytes, StandardCharsets.UTF_8); | String content = new Stri ng(bytes, StandardCharsets.UTF_8); | |||
return content.substring( | int mainThreadIndex = con | |||
0, content.indexOf("\"main\" - Thread")).getBytes(); | tent.indexOf("\"main\" - Thread"); | |||
String truncatedContent = | ||||
(mainThreadIndex >= 0) ? content.substring(0, mainThreadIndex) | ||||
: content | ||||
; | ||||
return truncatedContent.g | ||||
etBytes(); | ||||
})))); | })))); | |||
} | } | |||
@Configuration(proxyBeanMethods = false) | @Configuration(proxyBeanMethods = false) | |||
@Import(BaseDocumentationConfiguration.class) | @Import(BaseDocumentationConfiguration.class) | |||
static class TestConfiguration { | static class TestConfiguration { | |||
@Bean | @Bean | |||
ThreadDumpEndpoint endpoint() { | ThreadDumpEndpoint endpoint() { | |||
return new ThreadDumpEndpoint(); | return new ThreadDumpEndpoint(); | |||
End of changes. 2 change blocks. | ||||
3 lines changed or deleted | 9 lines changed or added |