|
27 | 27 | import org.springframework.boot.actuate.info.GitInfoContributor;
|
28 | 28 | import org.springframework.boot.actuate.info.InfoContributor;
|
29 | 29 | import org.springframework.boot.actuate.info.InfoEndpoint;
|
| 30 | +import org.springframework.boot.actuate.info.JavaInfoContributor; |
30 | 31 | import org.springframework.boot.actuate.info.OsInfoContributor;
|
31 | 32 | import org.springframework.boot.actuate.info.ProcessInfoContributor;
|
32 | 33 | import org.springframework.boot.info.BuildProperties;
|
@@ -55,7 +56,8 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
|
55 | 56 | void info() throws Exception {
|
56 | 57 | this.mockMvc.perform(get("/actuator/info"))
|
57 | 58 | .andExpect(status().isOk())
|
58 |
| - .andDo(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo(), processInfo())); |
| 59 | + .andDo(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo(), processInfo(), |
| 60 | + javaInfo())); |
59 | 61 | }
|
60 | 62 |
|
61 | 63 | private ResponseFieldsSnippet gitInfo() {
|
@@ -100,6 +102,35 @@ private ResponseFieldsSnippet processInfo() {
|
100 | 102 | .type(JsonFieldType.NUMBER));
|
101 | 103 | }
|
102 | 104 |
|
| 105 | + private ResponseFieldsSnippet javaInfo() { |
| 106 | + return responseFields(beneathPath("java"), |
| 107 | + fieldWithPath("version").description("Java version, if available.") |
| 108 | + .type(JsonFieldType.STRING) |
| 109 | + .optional(), |
| 110 | + fieldWithPath("vendor").description("Vendor details."), |
| 111 | + fieldWithPath("vendor.name").description("Vendor name, if available.") |
| 112 | + .type(JsonFieldType.STRING) |
| 113 | + .optional(), |
| 114 | + fieldWithPath("vendor.version").description("Vendor version, if available.") |
| 115 | + .type(JsonFieldType.STRING) |
| 116 | + .optional(), |
| 117 | + fieldWithPath("runtime").description("Runtime details."), |
| 118 | + fieldWithPath("runtime.name").description("Runtime name, if available.") |
| 119 | + .type(JsonFieldType.STRING) |
| 120 | + .optional(), |
| 121 | + fieldWithPath("runtime.version").description("Runtime version, if available.") |
| 122 | + .type(JsonFieldType.STRING) |
| 123 | + .optional(), |
| 124 | + fieldWithPath("jvm").description("JVM details."), |
| 125 | + fieldWithPath("jvm.name").description("JVM name, if available.").type(JsonFieldType.STRING).optional(), |
| 126 | + fieldWithPath("jvm.vendor").description("JVM vendor, if available.") |
| 127 | + .type(JsonFieldType.STRING) |
| 128 | + .optional(), |
| 129 | + fieldWithPath("jvm.version").description("JVM version, if available.") |
| 130 | + .type(JsonFieldType.STRING) |
| 131 | + .optional()); |
| 132 | + } |
| 133 | + |
103 | 134 | @Configuration(proxyBeanMethods = false)
|
104 | 135 | static class TestConfiguration {
|
105 | 136 |
|
@@ -139,6 +170,11 @@ ProcessInfoContributor processInfoContributor() {
|
139 | 170 | return new ProcessInfoContributor();
|
140 | 171 | }
|
141 | 172 |
|
| 173 | + @Bean |
| 174 | + JavaInfoContributor javaInfoContributor() { |
| 175 | + return new JavaInfoContributor(); |
| 176 | + } |
| 177 | + |
142 | 178 | }
|
143 | 179 |
|
144 | 180 | }
|
0 commit comments