Add 'cloud-function-webflux' smoke test
This commit is contained in:
@@ -5,6 +5,7 @@ smoke_tests:
|
||||
- async
|
||||
- batch
|
||||
- cloud-function-web
|
||||
- cloud-function-webflux
|
||||
- command-line-runner
|
||||
- conditional
|
||||
- configuration-properties
|
||||
|
||||
1
cloud-function-webflux/README.adoc
Normal file
1
cloud-function-webflux/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
Tests if Spring Cloud Function WebFlux works
|
||||
27
cloud-function-webflux/build.gradle
Normal file
27
cloud-function-webflux/build.gradle
Normal file
@@ -0,0 +1,27 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot'
|
||||
id 'org.springframework.boot.aot'
|
||||
id 'org.springframework.aot.smoke-test'
|
||||
id 'org.graalvm.buildtools.native'
|
||||
}
|
||||
|
||||
ext {
|
||||
set('springCloudVersion', "2022.0.0-SNAPSHOT")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
|
||||
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"))
|
||||
implementation("org.springframework.boot:spring-boot-starter")
|
||||
implementation("org.springframework.cloud:spring-cloud-starter-function-webflux")
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
aotTestImplementation(project(":aot-smoke-test-support"))
|
||||
aotTestImplementation("org.awaitility:awaitility:4.2.0")
|
||||
}
|
||||
|
||||
aotSmokeTest {
|
||||
webApplication = true
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.example.cloud.function.webflux;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.smoketest.support.junit.AotSmokeTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@AotSmokeTest
|
||||
class CloudFunctionWebFluxApplicationAotTests {
|
||||
|
||||
@Test
|
||||
void uppercaseShouldBeInvokable(WebTestClient webTestClient) {
|
||||
webTestClient.post().uri("/uppercase").header("Content-Type", MediaType.TEXT_PLAIN_VALUE).bodyValue("hello")
|
||||
.exchange().expectStatus().isOk().expectBody()
|
||||
.consumeWith((result) -> assertThat(new String(result.getResponseBodyContent())).isEqualTo("HELLO"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void lowercaseShouldBeInvokable(WebTestClient webTestClient) {
|
||||
webTestClient.post().uri("/lowercase").header("Content-Type", MediaType.TEXT_PLAIN_VALUE).bodyValue("HELLO")
|
||||
.exchange().expectStatus().isOk().expectBody()
|
||||
.consumeWith((result) -> assertThat(new String(result.getResponseBodyContent())).isEqualTo("hello"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.cloud.function.webflux;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class CloudFunctionWebFluxApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CloudFunctionWebFluxApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.example.cloud.function.webflux;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
class Lowercase implements Function<Mono<String>, Mono<String>> {
|
||||
|
||||
@Override
|
||||
public Mono<String> apply(Mono<String> input) {
|
||||
return input.map((i) -> i.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.example.cloud.function.webflux;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
class Uppercase implements Function<Mono<String>, Mono<String>> {
|
||||
|
||||
@Override
|
||||
public Mono<String> apply(Mono<String> input) {
|
||||
return input.map((i) -> i.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example.cloud.function.webflux;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class CloudFunctionWebFluxApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,6 +59,7 @@ include "aspect"
|
||||
include "async"
|
||||
include "batch"
|
||||
include "cloud-function-web"
|
||||
include "cloud-function-webflux"
|
||||
include "command-line-runner"
|
||||
include "conditional"
|
||||
include "configuration-properties"
|
||||
|
||||
Reference in New Issue
Block a user