Add WebFlux with Undertow tests
This commit is contained in:
1
framework/webflux-undertow/README.adoc
Normal file
1
framework/webflux-undertow/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
Tests if WebFlux with Undertow is working.
|
||||
26
framework/webflux-undertow/build.gradle
Normal file
26
framework/webflux-undertow/build.gradle
Normal file
@@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id "java"
|
||||
id "org.springframework.boot"
|
||||
id "org.springframework.cr.smoke-test"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
|
||||
implementation("org.springframework.boot:spring-boot-starter-webflux")
|
||||
implementation("org.springframework.boot:spring-boot-starter-undertow")
|
||||
modules {
|
||||
module("org.springframework.boot:spring-boot-starter-reactor-netty") {
|
||||
replacedBy("org.springframework.boot:spring-boot-starter-undertow", "Use Undertow instead of Netty")
|
||||
}
|
||||
}
|
||||
implementation("org.crac:crac:$cracVersion")
|
||||
implementation(project(":cr-listener"))
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
appTestImplementation(project(":cr-smoke-test-support"))
|
||||
}
|
||||
|
||||
crSmokeTest {
|
||||
webApplication = true
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.example.webflux;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cr.smoketest.support.junit.ApplicationTest;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ApplicationTest
|
||||
class WebfluxApplicationTests {
|
||||
|
||||
@Test
|
||||
void stringResponseBody(WebTestClient client) {
|
||||
client.get()
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.isOk()
|
||||
.expectBody()
|
||||
.consumeWith((result) -> assertThat(new String(result.getResponseBodyContent()))
|
||||
.isEqualTo("Hello from Spring WebFlux and Undertow"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void resourceInStatic(WebTestClient client) {
|
||||
client.get()
|
||||
.uri("foo.html")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.isOk()
|
||||
.expectBody()
|
||||
.consumeWith((result) -> assertThat(new String(result.getResponseBodyContent())).isEqualTo("Foo"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.webflux;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class WebfluxApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WebfluxApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example.webflux;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class WebfluxController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String hello() {
|
||||
return "Hello from Spring WebFlux and Undertow";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Foo
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.example.webflux.test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
public class RandomPortTests {
|
||||
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Test
|
||||
void check() {
|
||||
assertThat(this.port).isNotZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void webClientWorks(@Autowired WebTestClient webClient) {
|
||||
webClient.get()
|
||||
.uri("/")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.isOk()
|
||||
.expectBody(String.class)
|
||||
.isEqualTo("Hello from Spring WebFlux and Undertow");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user