Documentation polishing. Re-arranged testing section
This commit is contained in:
@@ -303,82 +303,8 @@ Functions and consumers that are declared with input and output in `Message<?>`
|
||||
|
||||
When POSTing text the response format might be different with Spring Boot 2.0 and older versions, depending on the content negotiation (provide content type and accpt headers for the best results).
|
||||
|
||||
And then you can test it as any other web application. Let's look at the example
|
||||
See <<Testing Functional Applications>> to see the details and example on how to test such application.
|
||||
|
||||
Suppose this is your application:
|
||||
|
||||
[source, java]
|
||||
----
|
||||
@SpringBootApplication
|
||||
public class SampleFunctionApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SampleFunctionApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<String, String> uppercase() {
|
||||
return v -> v.toUpperCase();
|
||||
}
|
||||
}
|
||||
----
|
||||
and test:
|
||||
|
||||
[source, java]
|
||||
----
|
||||
@SpringBootTest(classes = SampleFunctionApplication.class,
|
||||
webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class WebFunctionTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate rest;
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
ResponseEntity<String> result = this.rest.exchange(
|
||||
RequestEntity.post(new URI("/uppercase")).body("hello"), String.class);
|
||||
System.out.println(result.getBody());
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
And to help with correct dependencies here is the excerpt from POM
|
||||
|
||||
[source, xml]
|
||||
----
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.2.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
. . . .
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-function-web</artifactId>
|
||||
<version>3.0.1.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
== Standalone Streaming Applications
|
||||
|
||||
|
||||
Reference in New Issue
Block a user