1+ /*
2+ *
3+ * * Copyright 2019-2020 the original author or authors.
4+ * *
5+ * * Licensed under the Apache License, Version 2.0 (the "License");
6+ * * you may not use this file except in compliance with the License.
7+ * * You may obtain a copy of the License at
8+ * *
9+ * * https://www.apache.org/licenses/LICENSE-2.0
10+ * *
11+ * * Unless required by applicable law or agreed to in writing, software
12+ * * distributed under the License is distributed on an "AS IS" BASIS,
13+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * * See the License for the specific language governing permissions and
15+ * * limitations under the License.
16+ *
17+ */
18+
19+ package test .org .springdoc .ui .app1 ;
20+
21+ import org .junit .jupiter .api .Test ;
22+ import test .org .springdoc .ui .AbstractSpringDocActuatorTest ;
23+
24+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
25+ import org .springframework .boot .test .context .SpringBootTest ;
26+
27+ import static org .hamcrest .CoreMatchers .equalTo ;
28+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
29+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .jsonPath ;
30+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
31+
32+
33+ @ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .RANDOM_PORT ,
34+ properties = {"spring.jackson.property-naming-strategy=UPPER_CAMEL_CASE" , "springdoc.show-actuator=true" ,
35+ "management.endpoints.web.base-path=/management" ,
36+ "server.servlet.context-path=/demo/api" , "management.server.port=9001" , "management.server.base-path=/demo/api" })
37+ public class SpringDocSwaggerConfigTest extends AbstractSpringDocActuatorTest {
38+
39+ @ Test
40+ public void testIndexSwaggerConfig () throws Exception {
41+ mockMvc .perform (get ("/demo/api/v3/api-docs/swagger-config" ).contextPath ("/demo/api" ))
42+ .andExpect (status ().isOk ())
43+ .andExpect (jsonPath ("validatorUrl" , equalTo ("" )))
44+ .andExpect (jsonPath ("oauth2RedirectUrl" , equalTo ("http://localhost/demo/api/swagger-ui/oauth2-redirect.html" )))
45+ .andExpect (jsonPath ("url" ).doesNotExist ())
46+ .andExpect (jsonPath ("urls[0].url" , equalTo ("/demo/api/v3/api-docs/springdocDefault" )))
47+ .andExpect (jsonPath ("urls[0].name" , equalTo ("springdocDefault" )))
48+ .andExpect (jsonPath ("urls[1].url" , equalTo ("/demo/api/v3/api-docs/x-actuator" )))
49+ .andExpect (jsonPath ("urls[1].name" , equalTo ("x-actuator" )));
50+ }
51+
52+
53+ @ SpringBootApplication
54+ static class SpringDocTestApp {}
55+
56+ }
0 commit comments