@@ -0,0 +1,3286 @@
+package com.lance.springfox;%0A%0Aimport java.io.BufferedWriter;%0Aimport java.nio.charset.StandardCharsets;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Ignore;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.SpringApplicationConfiguration;%0Aimport org.springframework.http.MediaType;%0Aimport org.springframework.mock.web.MockHttpServletResponse;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0Aimport org.springframework.test.context.web.WebAppConfiguration;%0Aimport org.springframework.test.web.servlet.MockMvc;%0Aimport org.springframework.test.web.servlet.MvcResult;%0Aimport org.springframework.test.web.servlet.request.MockMvcRequestBuilders;%0Aimport org.springframework.test.web.servlet.result.MockMvcResultMatchers;%0Aimport org.springframework.test.web.servlet.setup.MockMvcBuilders;%0Aimport org.springframework.web.context.WebApplicationContext;%0A%0Aimport com.lance.springfox.common.SwaggerConfig;%0A%0Aimport io.github.robwin.markup.builder.MarkupLanguage;%0Aimport springfox.documentation.staticdocs.Swagger2MarkupResultHandler;%0A%0A@WebAppConfiguration%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@SpringApplicationConfiguration(classes=%7BSimpleApplication.class, SwaggerConfig.class%7D)%0Apublic class Swagger2MarkupTest %7B%0A%09@Autowired%0A    private WebApplicationContext context;%0A    private MockMvc mockMvc;%0A    %0A    @Before%0A    public void setupMockMvc() %7B%0A        mockMvc = MockMvcBuilders.webAppContextSetup(context).build();%0A    %7D%0A%0A    @Test%0A    @Ignore%0A    public void convertSwaggerToAsciiDoc() throws Exception %7B%0A        this.mockMvc.perform(MockMvcRequestBuilders.get(%22/v2/api-docs?group=Admin API%22)%0A                .accept(MediaType.APPLICATION_JSON))%0A                .andDo(Swagger2MarkupResultHandler.outputDirectory(%22src/docs/asciidoc/generated%22).build())%0A                .andExpect(MockMvcResultMatchers.status().isOk());%0A    %7D%0A%0A    @Test%0A    @Ignore%0A    public void convertSwaggerToMarkdown() throws Exception %7B%0A        this.mockMvc.perform(MockMvcRequestBuilders.get(%22/v2/api-docs?group=Admin API%22)%0A                .accept(MediaType.APPLICATION_JSON))%0A                .andDo(Swagger2MarkupResultHandler.outputDirectory(%22src/docs/markdown/generated%22)%0A                    .withMarkupLanguage(MarkupLanguage.MARKDOWN).build())%0A                .andExpect(MockMvcResultMatchers.status().isOk());%0A    %7D%0A    %0A    @Test%0A    @Ignore%0A    public void createSpringfoxSwaggerJson() throws Exception %7B%0A        String outputDir = %22E:%5C%5Cgitwork%5C%5Cspring-boot-all%5C%5Cspring-boot-springfox%5C%5Csrc%5C%5Cdocs%5C%5C%22;%0A        MvcResult mvcResult = this.mockMvc.perform(MockMvcRequestBuilders.get(%22/v2/api-docs?group=Admin API%22)%0A                .accept(MediaType.APPLICATION_JSON))%0A                .andExpect(MockMvcResultMatchers.status().isOk())%0A                .andReturn();%0A%0A        MockHttpServletResponse response = mvcResult.getResponse();%0A        String swaggerJson = response.getContentAsString();%0A        Files.createDirectories(Paths.get(outputDir));%0A        try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputDir, %22swagger.json%22), StandardCharsets.UTF_8))%7B%0A            writer.write(swaggerJson);%0A        %7D%0A    %7D%0A%7D%0A

add junit test swagger2Markuptest