changing classes of maven module

This commit is contained in:
Fabio Pereira
2018-04-02 21:57:53 -03:00
parent 0a1293f553
commit f871b4e1fe
7 changed files with 175 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package com.baeldung.reactive.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.reactive.server.EntityExchangeResult;
import org.springframework.test.web.reactive.server.WebTestClient;
import static org.junit.Assert.assertEquals;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class UserControllerTest {
@Autowired
private WebTestClient webTestClient;
@Test
public void getUserName() {
EntityExchangeResult<String> result = webTestClient.get().uri("/users/baeldung")
.exchange()
.expectStatus().isOk()
.expectBody(String.class)
.returnResult();
assertEquals(result.getResponseBody(), "baeldung");
assertEquals(result.getResponseHeaders().getFirst("web-filter"), "web-filter-test");
}
@Test
public void getUserNameTest() {
EntityExchangeResult<String> result = webTestClient.get().uri("/users/test")
.exchange()
.expectStatus().isOk()
.expectBody(String.class)
.returnResult();
assertEquals(result.getResponseBody(), "test");
assertEquals(result.getResponseHeaders().getFirst("web-filter"), "web-filter-test");
}
}