Rework the samples to avoid depending on Spring Boot
Closes gh-711
This commit is contained in:
@@ -18,25 +18,23 @@ 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:${project.ext['spring-restdocs.version']}"
|
||||
asciidoctorExtensions "org.springframework.restdocs:spring-restdocs-asciidoctor:$restdocsVersion"
|
||||
|
||||
implementation 'io.projectreactor.ipc:reactor-netty:0.7.1.RELEASE'
|
||||
implementation 'org.springframework:spring-context:5.0.1.RELEASE'
|
||||
implementation 'org.springframework:spring-webflux:5.0.1.RELEASE'
|
||||
implementation 'org.springframework:spring-context:6.0.0-SNAPSHOT'
|
||||
implementation 'org.springframework:spring-webflux:6.0.0-SNAPSHOT'
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.springframework:spring-test:5.0.1.RELEASE'
|
||||
testImplementation "org.springframework.restdocs:spring-restdocs-webtestclient:${project.ext['spring-restdocs.version']}"
|
||||
testImplementation 'org.springframework:spring-test:6.0.0-SNAPSHOT'
|
||||
testImplementation "org.springframework.restdocs:spring-restdocs-webtestclient:$restdocsVersion"
|
||||
}
|
||||
|
||||
test {
|
||||
@@ -55,6 +53,3 @@ jar {
|
||||
into 'static/docs'
|
||||
}
|
||||
}
|
||||
|
||||
eclipseJdt.onlyIf { false }
|
||||
cleanEclipseJdt.onlyIf { false }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 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,33 +16,22 @@
|
||||
|
||||
package com.example.webtestclient;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
import org.springframework.web.reactive.function.server.RequestPredicates;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.RouterFunctions;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
|
||||
import reactor.ipc.netty.http.server.HttpServer;
|
||||
|
||||
@EnableWebFlux
|
||||
@Configuration
|
||||
public class SampleWebTestClientApplication {
|
||||
|
||||
@Bean
|
||||
public RouterFunction<ServerResponse> routerFunction() {
|
||||
return RouterFunctions.route(RequestPredicates.GET("/"), (request) -> ServerResponse.status(HttpStatus.OK).syncBody("Hello, World"));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
RouterFunction<?> routerFunction = new AnnotationConfigApplicationContext(SampleWebTestClientApplication.class).getBean(RouterFunction.class);
|
||||
ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(RouterFunctions.toHttpHandler(routerFunction));
|
||||
HttpServer httpServer = HttpServer.create(8080);
|
||||
httpServer.startAndAwait(adapter);
|
||||
return RouterFunctions.route(RequestPredicates.GET("/"), (request) -> ServerResponse.status(HttpStatus.OK).bodyValue("Hello, World"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user