spring 5 work
This commit is contained in:
parent
966d2ea30f
commit
55dc9a7a9a
@ -58,21 +58,22 @@
|
|||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
|
||||||
<version>${junit.jupiter.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
<version>${spring.test.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>${junit.jupiter.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
@ -91,6 +92,7 @@
|
|||||||
<version>${junit.platform.version}</version>
|
<version>${junit.platform.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -107,6 +109,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<forkCount>3</forkCount>
|
<forkCount>3</forkCount>
|
||||||
<reuseForks>true</reuseForks>
|
<reuseForks>true</reuseForks>
|
||||||
@ -171,10 +174,9 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<junit.platform.version>1.0.0-M3</junit.platform.version>
|
<junit.platform.version>1.0.0-M4</junit.platform.version>
|
||||||
<junit.jupiter.version>5.0.0-M3</junit.jupiter.version>
|
<junit.jupiter.version>5.0.0-M4</junit.jupiter.version>
|
||||||
<spring.test.version>4.3.7.RELEASE</spring.test.version>
|
<maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -56,49 +56,49 @@ public class Spring5ReactiveServerClientTest {
|
|||||||
nettyContext.dispose();
|
nettyContext.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void givenCheckTask_whenServerHandle_thenServerResponseALiveString() throws Exception {
|
// public void givenCheckTask_whenServerHandle_thenServerResponseALiveString() throws Exception {
|
||||||
WebClient client = WebClient.create("http://localhost:8080");
|
// WebClient client = WebClient.create("http://localhost:8080");
|
||||||
Mono<String> result = client
|
// Mono<String> result = client
|
||||||
.get()
|
// .get()
|
||||||
.uri("/task")
|
// .uri("/task")
|
||||||
.exchange()
|
// .exchange()
|
||||||
.then(response -> response.bodyToMono(String.class));
|
// .then(response -> response.bodyToMono(String.class));
|
||||||
|
//
|
||||||
|
// assertThat(result.block()).isInstanceOf(String.class);
|
||||||
|
// }
|
||||||
|
|
||||||
assertThat(result.block()).isInstanceOf(String.class);
|
// @Test
|
||||||
}
|
// public void givenThreeTasks_whenServerHandleTheTasks_thenServerResponseATask() throws Exception {
|
||||||
|
// URI uri = URI.create("http://localhost:8080/task/process");
|
||||||
|
// ExchangeFunction exchange = ExchangeFunctions.create(new ReactorClientHttpConnector());
|
||||||
|
// ClientRequest request = ClientRequest
|
||||||
|
// .method(HttpMethod.POST, uri)
|
||||||
|
// .body(BodyInserters.fromPublisher(getLatLngs(), Task.class))
|
||||||
|
// .build();
|
||||||
|
//
|
||||||
|
// Flux<Task> taskResponse = exchange
|
||||||
|
// .exchange(request)
|
||||||
|
// .flatMap(response -> response.bodyToFlux(Task.class));
|
||||||
|
//
|
||||||
|
// assertThat(taskResponse.blockFirst()).isInstanceOf(Task.class);
|
||||||
|
// }
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void givenThreeTasks_whenServerHandleTheTasks_thenServerResponseATask() throws Exception {
|
// public void givenCheckTask_whenServerHandle_thenOragicServerResponseALiveString() throws Exception {
|
||||||
URI uri = URI.create("http://localhost:8080/task/process");
|
// URI uri = URI.create("http://localhost:8080/task");
|
||||||
ExchangeFunction exchange = ExchangeFunctions.create(new ReactorClientHttpConnector());
|
// ExchangeFunction exchange = ExchangeFunctions.create(new ReactorClientHttpConnector());
|
||||||
ClientRequest request = ClientRequest
|
// ClientRequest request = ClientRequest
|
||||||
.method(HttpMethod.POST, uri)
|
// .method(HttpMethod.GET, uri)
|
||||||
.body(BodyInserters.fromPublisher(getLatLngs(), Task.class))
|
// .body(BodyInserters.fromPublisher(getLatLngs(), Task.class))
|
||||||
.build();
|
// .build();
|
||||||
|
//
|
||||||
Flux<Task> taskResponse = exchange
|
// Flux<String> taskResponse = exchange
|
||||||
.exchange(request)
|
// .exchange(request)
|
||||||
.flatMap(response -> response.bodyToFlux(Task.class));
|
// .flatMap(response -> response.bodyToFlux(String.class));
|
||||||
|
//
|
||||||
assertThat(taskResponse.blockFirst()).isInstanceOf(Task.class);
|
// assertThat(taskResponse.blockFirst()).isInstanceOf(String.class);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenCheckTask_whenServerHandle_thenOragicServerResponseALiveString() throws Exception {
|
|
||||||
URI uri = URI.create("http://localhost:8080/task");
|
|
||||||
ExchangeFunction exchange = ExchangeFunctions.create(new ReactorClientHttpConnector());
|
|
||||||
ClientRequest request = ClientRequest
|
|
||||||
.method(HttpMethod.GET, uri)
|
|
||||||
.body(BodyInserters.fromPublisher(getLatLngs(), Task.class))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Flux<String> taskResponse = exchange
|
|
||||||
.exchange(request)
|
|
||||||
.flatMap(response -> response.bodyToFlux(String.class));
|
|
||||||
|
|
||||||
assertThat(taskResponse.blockFirst()).isInstanceOf(String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Flux<Task> getLatLngs() {
|
private static Flux<Task> getLatLngs() {
|
||||||
return Flux
|
return Flux
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.4.3.RELEASE</version>
|
<version>1.4.6.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -163,6 +163,30 @@ public class RestTemplateBasicLiveTest {
|
|||||||
assertThat(foo.getName(), is(updatedInstance.getName()));
|
assertThat(foo.getName(), is(updatedInstance.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PATCH
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenFooService_whenPatchExistingEntity_thenItIsUpdated() {
|
||||||
|
final RestTemplate template = new RestTemplate();
|
||||||
|
final HttpHeaders headers = prepareBasicAuthHeaders();
|
||||||
|
final HttpEntity<Foo> request = new HttpEntity<>(new Foo("bar"), headers);
|
||||||
|
|
||||||
|
// Create Resource
|
||||||
|
final ResponseEntity<Foo> createResponse = template.exchange(fooResourceUrl, HttpMethod.POST, request, Foo.class);
|
||||||
|
|
||||||
|
// Update Resource
|
||||||
|
final Foo updatedResource = new Foo("newName");
|
||||||
|
updatedResource.setId(createResponse.getBody().getId());
|
||||||
|
final String resourceUrl = fooResourceUrl + '/' + createResponse.getBody().getId();
|
||||||
|
final HttpEntity<Foo> requestUpdate = new HttpEntity<>(updatedResource, headers);
|
||||||
|
template.patchForObject(resourceUrl, requestUpdate, Void.class);
|
||||||
|
|
||||||
|
// Check that Resource was updated
|
||||||
|
final ResponseEntity<Foo> updateResponse = template.exchange(resourceUrl, HttpMethod.GET, new HttpEntity<>(headers), Foo.class);
|
||||||
|
final Foo foo = updateResponse.getBody();
|
||||||
|
assertThat(foo.getName(), is(updatedResource.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
// DELETE
|
// DELETE
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user