Rework the samples to avoid depending on Spring Boot

Closes gh-711
This commit is contained in:
Andy Wilkinson
2021-09-28 18:11:14 +01:00
parent 4223f70102
commit be0528bdcb
31 changed files with 505 additions and 268 deletions

View File

@@ -2,11 +2,8 @@ plugins {
id "eclipse"
id "java"
id "org.asciidoctor.jvm.convert" version "3.3.2"
id "org.springframework.boot" version "2.4.7"
}
apply plugin: 'io.spring.dependency-management'
repositories {
mavenLocal()
maven { url 'https://repo.spring.io/milestone' }
@@ -20,21 +17,21 @@ sourceCompatibility = 17
targetCompatibility = 17
ext {
restdocsVersion = '3.0.0-SNAPSHOT'
snippetsDir = file('build/generated-snippets')
}
ext['spring-restdocs.version'] = '3.0.0-SNAPSHOT'
configurations {
asciidoctorExtensions
}
dependencies {
asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.testng:testng:6.9.10'
asciidoctorExtensions "org.springframework.restdocs:spring-restdocs-asciidoctor:$restdocsVersion"
implementation "org.springframework:spring-webmvc:6.0.0-SNAPSHOT"
testImplementation "org.springframework.restdocs:spring-restdocs-mockmvc:$restdocsVersion"
testImplementation "org.testng:testng:6.9.10"
}
test {
@@ -48,12 +45,9 @@ asciidoctor {
dependsOn test
}
bootJar {
jar {
dependsOn asciidoctor
from ("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}
eclipseJdt.onlyIf { false }
cleanEclipseJdt.onlyIf { false }

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,18 +16,13 @@
package com.example.testng;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@Configuration
public class SampleTestNgApplication {
public static void main(String[] args) {
new SpringApplication(SampleTestNgApplication.class).run(args);
}
@RestController
private static class SampleController {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,9 +24,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.lang.reflect.Method;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.restdocs.ManualRestDocumentation;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
@@ -34,7 +35,8 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@SpringBootTest
@WebAppConfiguration
@ContextConfiguration(classes = SampleTestNgApplication.class)
public class SampleTestNgApplicationTests extends AbstractTestNGSpringContextTests {
private final ManualRestDocumentation restDocumentation = new ManualRestDocumentation();