Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
编写 Swagger 集成测试 (#54)
Browse files Browse the repository at this point in the history
* swagger-ItTest

* swagger-ItTest

* swagger-ItTest

* swagger-ItTest
  • Loading branch information
A-Little-Excited authored May 10, 2024
1 parent b1c0a96 commit 17a3fff
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paiondata.athena.spring.boot.autoconfigure.actuator

import com.paiondata.athena.spring.boot.autoconfigure.AbstractITSpec
package com.paiondata.athena.spring.boot.autoconfigure

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2024 Paion Data
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paiondata.athena.spring.boot.autoconfigure

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import org.springframework.test.web.servlet.result.MockMvcResultMatchers

@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
class OpenApiITSpec extends AbstractITSpec {

@Autowired
MockMvc mockMvc

def "Swagger is enabled"() {
when:
def response = mockMvc.perform(MockMvcRequestBuilders.get('/swagger-ui/index.html'))

then:
response.andExpect(MockMvcResultMatchers.status().isOk())
}
}

0 comments on commit 17a3fff

Please sign in to comment.