Rename MockMvcTestClient to MockMvcWebTestClient
Closes gh-19647
This commit is contained in:
@@ -34,7 +34,7 @@ import org.springframework.test.context.ContextHierarchy;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
@@ -46,7 +46,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.context.AsyncControllerJavaConfigTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -67,7 +67,7 @@ public class AsyncControllerJavaConfigTests {
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.testClient = MockMvcTestClient.bindToApplicationContext(this.wac).build();
|
||||
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.test.web.servlet.samples.context.PersonController;
|
||||
import org.springframework.test.web.servlet.samples.context.PersonDao;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
@@ -46,7 +46,7 @@ import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.context.JavaConfigTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -73,7 +73,7 @@ public class JavaConfigTests {
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.testClient = MockMvcTestClient.bindToApplicationContext(this.wac).build();
|
||||
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
|
||||
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
|
||||
|
||||
@@ -36,7 +36,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.handler;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.context.WebAppResourceTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -57,7 +57,7 @@ public class WebAppResourceTests {
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.testClient = MockMvcTestClient.bindToApplicationContext(this.wac).build();
|
||||
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
|
||||
}
|
||||
|
||||
// TilesConfigurer: resources under "/WEB-INF/**/tiles.xml"
|
||||
@@ -90,7 +90,7 @@ public class WebAppResourceTests {
|
||||
.expectStatus().isOk()
|
||||
.expectBody().isEmpty();
|
||||
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(handler().handlerType(DefaultServletHttpRequestHandler.class))
|
||||
.andExpect(forwardedUrl("default"));
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.test.web.servlet.samples.context.PersonDao;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.context.XmlConfigTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -59,7 +59,7 @@ public class XmlConfigTests {
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.testClient = MockMvcTestClient.bindToApplicationContext(this.wac).build();
|
||||
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
|
||||
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureTask;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
@@ -39,7 +39,7 @@ import org.springframework.web.context.request.async.DeferredResult;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.AsyncTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -47,7 +47,7 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBo
|
||||
public class AsyncTests {
|
||||
|
||||
private final WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new AsyncController()).build();
|
||||
MockMvcWebTestClient.bindToController(new AsyncController()).build();
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.ExceptionHandlerTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -45,7 +45,7 @@ class ExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void localExceptionHandlerMethod() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController()).build();
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController()).build();
|
||||
|
||||
client.get().uri("/person/Clyde")
|
||||
.exchange()
|
||||
@@ -55,7 +55,7 @@ class ExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void globalExceptionHandlerMethod() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.controllerAdvice(new GlobalExceptionHandler())
|
||||
.build();
|
||||
|
||||
@@ -102,7 +102,7 @@ class ExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void noException() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new RestPersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new RestPersonController())
|
||||
.controllerAdvice(new RestPersonControllerExceptionHandler())
|
||||
.build();
|
||||
|
||||
@@ -115,7 +115,7 @@ class ExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void localExceptionHandlerMethod() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new RestPersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new RestPersonController())
|
||||
.controllerAdvice(new RestPersonControllerExceptionHandler())
|
||||
.build();
|
||||
|
||||
@@ -128,7 +128,7 @@ class ExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void globalExceptionHandlerMethod() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new RestPersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new RestPersonController())
|
||||
.controllerAdvice(new RestGlobalExceptionHandler())
|
||||
.build();
|
||||
|
||||
@@ -141,7 +141,7 @@ class ExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void globalRestPersonControllerExceptionHandlerTakesPrecedenceOverGlobalExceptionHandler() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new RestPersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new RestPersonController())
|
||||
.controllerAdvice(RestGlobalExceptionHandler.class, RestPersonControllerExceptionHandler.class)
|
||||
.build();
|
||||
|
||||
@@ -154,7 +154,7 @@ class ExceptionHandlerTests {
|
||||
|
||||
@Test
|
||||
void noHandlerFound() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new RestPersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new RestPersonController())
|
||||
.controllerAdvice(RestGlobalExceptionHandler.class, RestPersonControllerExceptionHandler.class)
|
||||
.dispatcherServletCustomizer(servlet -> servlet.setThrowExceptionIfNoHandlerFound(true))
|
||||
.build();
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -54,7 +54,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.FilterTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -63,7 +63,7 @@ public class FilterTests {
|
||||
|
||||
@Test
|
||||
public void whenFiltersCompleteMvcProcessesRequest() throws Exception {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.filters(new ContinueFilter())
|
||||
.build();
|
||||
|
||||
@@ -74,7 +74,7 @@ public class FilterTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().size(1))
|
||||
.andExpect(model().attributeExists("id"))
|
||||
.andExpect(flash().attributeCount(1))
|
||||
@@ -83,7 +83,7 @@ public class FilterTests {
|
||||
|
||||
@Test
|
||||
public void filtersProcessRequest() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.filters(new ContinueFilter(), new RedirectFilter())
|
||||
.build();
|
||||
|
||||
@@ -95,7 +95,7 @@ public class FilterTests {
|
||||
|
||||
@Test
|
||||
public void filterMappedBySuffix() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.filter(new RedirectFilter(), "*.html")
|
||||
.build();
|
||||
|
||||
@@ -107,7 +107,7 @@ public class FilterTests {
|
||||
|
||||
@Test
|
||||
public void filterWithExactMapping() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.filter(new RedirectFilter(), "/p", "/persons")
|
||||
.build();
|
||||
|
||||
@@ -119,7 +119,7 @@ public class FilterTests {
|
||||
|
||||
@Test
|
||||
public void filterSkipped() throws Exception {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.filter(new RedirectFilter(), "/p", "/person")
|
||||
.build();
|
||||
|
||||
@@ -131,7 +131,7 @@ public class FilterTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().size(1))
|
||||
.andExpect(model().attributeExists("id"))
|
||||
.andExpect(flash().attributeCount(1))
|
||||
@@ -140,7 +140,7 @@ public class FilterTests {
|
||||
|
||||
@Test
|
||||
public void filterWrapsRequestResponse() throws Exception {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.filter(new WrappingRequestResponseFilter())
|
||||
.build();
|
||||
|
||||
@@ -148,13 +148,13 @@ public class FilterTests {
|
||||
client.post().uri("/user").exchange().expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attribute("principal", WrappingRequestResponseFilter.PRINCIPAL_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterWrapsRequestResponseAndPerformsAsyncDispatch() {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.filters(new WrappingRequestResponseFilter(), new ShallowEtagHeaderFilter())
|
||||
.build();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
||||
import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcConfigurerAdapter;
|
||||
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.FrameworkExtensionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -43,7 +43,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class FrameworkExtensionTests {
|
||||
|
||||
private final WebTestClient client =
|
||||
MockMvcTestClient.bindToController(new SampleController())
|
||||
MockMvcWebTestClient.bindToController(new SampleController())
|
||||
.apply(defaultSetup())
|
||||
.build();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.http.client.MultipartBodyBuilder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -50,14 +50,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.MultipartControllerTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MultipartControllerTests {
|
||||
|
||||
private final WebTestClient testClient = MockMvcTestClient.bindToController(new MultipartController()).build();
|
||||
private final WebTestClient testClient = MockMvcWebTestClient.bindToController(new MultipartController()).build();
|
||||
|
||||
|
||||
@Test
|
||||
@@ -77,7 +77,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attribute("fileContent", fileContent))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attribute("fileContent", fileContent))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attribute("fileContent", fileContent))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attributeDoesNotExist("fileContent"))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attribute("fileContent", fileContent))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attributeDoesNotExist("fileContent"))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attribute("fileContent", fileContent))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attributeDoesNotExist("fileContent"))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attribute("fileContent", fileContent))
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
@@ -268,7 +268,7 @@ public class MultipartControllerTests {
|
||||
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
|
||||
bodyBuilder.part("json", json, MediaType.APPLICATION_JSON);
|
||||
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new MultipartController())
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new MultipartController())
|
||||
.filter(new RequestWrappingFilter())
|
||||
.build();
|
||||
|
||||
@@ -279,7 +279,7 @@ public class MultipartControllerTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().attribute("jsonContent", json));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,14 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.ReactiveReturnTypeTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -41,7 +41,7 @@ public class ReactiveReturnTypeTests {
|
||||
public void sseWithFlux() {
|
||||
|
||||
WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new ReactiveController()).build();
|
||||
MockMvcWebTestClient.bindToController(new ReactiveController()).build();
|
||||
|
||||
Flux<String> bodyFlux = testClient.get().uri("/spr16869")
|
||||
.exchange()
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.Errors;
|
||||
@@ -39,7 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.RedirectTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -47,7 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class RedirectTests {
|
||||
|
||||
private final WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new PersonController()).build();
|
||||
MockMvcWebTestClient.bindToController(new PersonController()).build();
|
||||
|
||||
|
||||
@Test
|
||||
@@ -60,7 +60,7 @@ public class RedirectTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(exchangeResult)
|
||||
MockMvcWebTestClient.resultActionsFor(exchangeResult)
|
||||
.andExpect(model().size(1))
|
||||
.andExpect(model().attributeExists("name"))
|
||||
.andExpect(flash().attributeCount(1))
|
||||
@@ -77,7 +77,7 @@ public class RedirectTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(model().size(1))
|
||||
.andExpect(model().attributeExists("name"))
|
||||
.andExpect(flash().attributeCount(1))
|
||||
@@ -89,7 +89,7 @@ public class RedirectTests {
|
||||
EntityExchangeResult<Void> result =
|
||||
testClient.post().uri("/persons").exchange().expectStatus().isOk().expectBody().isEmpty();
|
||||
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(forwardedUrl("persons/add"))
|
||||
.andExpect(model().size(1))
|
||||
.andExpect(model().attributeExists("person"))
|
||||
@@ -101,7 +101,7 @@ public class RedirectTests {
|
||||
EntityExchangeResult<Void> result =
|
||||
testClient.post().uri("/people").exchange().expectStatus().isOk().expectBody().isEmpty();
|
||||
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(forwardedUrl("persons/add"))
|
||||
.andExpect(model().size(1))
|
||||
.andExpect(model().attributeExists("person"))
|
||||
@@ -111,7 +111,7 @@ public class RedirectTests {
|
||||
@Test
|
||||
public void getPerson() throws Exception {
|
||||
EntityExchangeResult<Void> result =
|
||||
MockMvcTestClient.bindToController(new PersonController())
|
||||
MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.defaultRequest(get("/").flashAttr("message", "success!"))
|
||||
.build()
|
||||
.get().uri("/persons/Joe")
|
||||
@@ -120,7 +120,7 @@ public class RedirectTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andDo(MockMvcResultHandlers.print())
|
||||
.andExpect(forwardedUrl("persons/index"))
|
||||
.andExpect(model().size(2))
|
||||
|
||||
@@ -21,13 +21,13 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.RequestParameterTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -37,7 +37,7 @@ public class RequestParameterTests {
|
||||
@Test
|
||||
public void queryParameter() {
|
||||
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController()).build();
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController()).build();
|
||||
|
||||
client.get().uri("/search?name=George")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.validation.constraints.NotNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -37,7 +37,7 @@ public class ResponseBodyTests {
|
||||
|
||||
@Test
|
||||
void json() {
|
||||
MockMvcTestClient.bindToController(new PersonController()).build()
|
||||
MockMvcWebTestClient.bindToController(new PersonController()).build()
|
||||
.get()
|
||||
.uri("/person/Lee")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.accept.ContentNegotiationManager;
|
||||
import org.springframework.web.accept.FixedContentNegotiationStrategy;
|
||||
@@ -47,7 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.RequestParameterTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -57,7 +57,7 @@ class ViewResolutionTests {
|
||||
@Test
|
||||
void jspOnly() throws Exception {
|
||||
WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new PersonController())
|
||||
MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.viewResolvers(new InternalResourceViewResolver("/WEB-INF/", ".jsp"))
|
||||
.build();
|
||||
|
||||
@@ -67,7 +67,7 @@ class ViewResolutionTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(model().size(1))
|
||||
.andExpect(model().attributeExists("person"))
|
||||
@@ -77,7 +77,7 @@ class ViewResolutionTests {
|
||||
@Test
|
||||
void jsonOnly() {
|
||||
WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new PersonController())
|
||||
MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.singleView(new MappingJackson2JsonView())
|
||||
.build();
|
||||
|
||||
@@ -94,7 +94,7 @@ class ViewResolutionTests {
|
||||
marshaller.setClassesToBeBound(Person.class);
|
||||
|
||||
WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new PersonController())
|
||||
MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.singleView(new MarshallingView(marshaller))
|
||||
.build();
|
||||
|
||||
@@ -123,7 +123,7 @@ class ViewResolutionTests {
|
||||
cnViewResolver.afterPropertiesSet();
|
||||
|
||||
WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new PersonController())
|
||||
MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.viewResolvers(cnViewResolver, new InternalResourceViewResolver())
|
||||
.build();
|
||||
|
||||
@@ -133,7 +133,7 @@ class ViewResolutionTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(model().size(1))
|
||||
.andExpect(model().attributeExists("person"))
|
||||
.andExpect(forwardedUrl("person/show"));
|
||||
@@ -155,7 +155,7 @@ class ViewResolutionTests {
|
||||
|
||||
@Test
|
||||
void defaultViewResolver() throws Exception {
|
||||
WebTestClient client = MockMvcTestClient.bindToController(new PersonController()).build();
|
||||
WebTestClient client = MockMvcWebTestClient.bindToController(new PersonController()).build();
|
||||
|
||||
EntityExchangeResult<Void> result = client.get().uri("/person/Corea")
|
||||
.exchange()
|
||||
@@ -163,7 +163,7 @@ class ViewResolutionTests {
|
||||
.expectBody().isEmpty();
|
||||
|
||||
// Further assertions on the server response
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(model().attribute("person", hasProperty("name", equalTo("Corea"))))
|
||||
.andExpect(forwardedUrl("person/show")); // InternalResourceViewResolver
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resulthandlers.PrintingResultHandlerSmokeTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class PrintingResultHandlerSmokeTests {
|
||||
|
||||
private final WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new SimpleController()).build();
|
||||
MockMvcWebTestClient.bindToController(new SimpleController()).build();
|
||||
|
||||
|
||||
// Not intended to be executed with the build.
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.ContentAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
public class ContentAssertionTests {
|
||||
|
||||
private final WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new SimpleController()).build();
|
||||
MockMvcWebTestClient.bindToController(new SimpleController()).build();
|
||||
|
||||
@Test
|
||||
public void testContentType() {
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
||||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||
@@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.CookieAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -51,7 +51,7 @@ public class CookieAssertionTests {
|
||||
localeResolver.setCookieDomain("domain");
|
||||
localeResolver.setCookieHttpOnly(true);
|
||||
|
||||
client = MockMvcTestClient.bindToController(new SimpleController())
|
||||
client = MockMvcWebTestClient.bindToController(new SimpleController())
|
||||
.interceptors(new LocaleChangeInterceptor())
|
||||
.localeResolver(localeResolver)
|
||||
.alwaysExpect(status().isOk())
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@@ -37,7 +37,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.FlashAttributeAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -45,7 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class FlashAttributeAssertionTests {
|
||||
|
||||
private final WebTestClient client =
|
||||
MockMvcTestClient.bindToController(new PersonController())
|
||||
MockMvcWebTestClient.bindToController(new PersonController())
|
||||
.alwaysExpect(status().isFound())
|
||||
.alwaysExpect(flash().attributeCount(3))
|
||||
.build();
|
||||
@@ -84,7 +84,7 @@ public class FlashAttributeAssertionTests {
|
||||
|
||||
private ResultActions performRequest() {
|
||||
EntityExchangeResult<Void> result = client.post().uri("/persons").exchange().expectBody().isEmpty();
|
||||
return MockMvcTestClient.resultActionsFor(result);
|
||||
return MockMvcWebTestClient.resultActionsFor(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder;
|
||||
@@ -38,7 +38,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.on;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.HandlerAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -46,7 +46,7 @@ import static org.springframework.web.servlet.mvc.method.annotation.MvcUriCompon
|
||||
public class HandlerAssertionTests {
|
||||
|
||||
private final WebTestClient client =
|
||||
MockMvcTestClient.bindToController(new SimpleController())
|
||||
MockMvcWebTestClient.bindToController(new SimpleController())
|
||||
.alwaysExpect(status().isOk())
|
||||
.build();
|
||||
|
||||
@@ -90,7 +90,7 @@ public class HandlerAssertionTests {
|
||||
|
||||
private ResultActions performRequest() {
|
||||
EntityExchangeResult<Void> result = client.get().uri("/").exchange().expectBody().isEmpty();
|
||||
return MockMvcTestClient.resultActionsFor(result);
|
||||
return MockMvcWebTestClient.resultActionsFor(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
@@ -48,7 +48,7 @@ import static org.springframework.http.HttpHeaders.LAST_MODIFIED;
|
||||
import static org.springframework.http.HttpHeaders.VARY;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.HeaderAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -78,7 +78,7 @@ public class HeaderAssertionTests {
|
||||
|
||||
PersonController controller = new PersonController();
|
||||
controller.setStubTimestamp(this.currentTime);
|
||||
this.testClient = MockMvcTestClient.bindToController(controller).build();
|
||||
this.testClient = MockMvcWebTestClient.bindToController(controller).build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -40,7 +40,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.JsonPathAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -48,7 +48,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class JsonPathAssertionTests {
|
||||
|
||||
private final WebTestClient client =
|
||||
MockMvcTestClient.bindToController(new MusicController())
|
||||
MockMvcWebTestClient.bindToController(new MusicController())
|
||||
.alwaysExpect(status().isOk())
|
||||
.alwaysExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.configureClient()
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
@@ -45,7 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.ModelAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -53,7 +53,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class ModelAssertionTests {
|
||||
|
||||
private final WebTestClient client =
|
||||
MockMvcTestClient.bindToController(new SampleController("a string value", 3, new Person("a name")))
|
||||
MockMvcWebTestClient.bindToController(new SampleController("a string value", 3, new Person("a name")))
|
||||
.controllerAdvice(new ModelAttributeAdvice())
|
||||
.alwaysExpect(status().isOk())
|
||||
.build();
|
||||
@@ -96,7 +96,7 @@ public class ModelAssertionTests {
|
||||
|
||||
private ResultActions performRequest(HttpMethod method, String uri) {
|
||||
EntityExchangeResult<Void> result = client.method(method).uri(uri).exchange().expectBody().isEmpty();
|
||||
return MockMvcTestClient.resultActionsFor(result);
|
||||
return MockMvcWebTestClient.resultActionsFor(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
@@ -34,7 +34,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* MockMvcWebTestClient equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.RequestAttributeAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -42,12 +42,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class RequestAttributeAssertionTests {
|
||||
|
||||
private final WebTestClient mainServletClient =
|
||||
MockMvcTestClient.bindToController(new SimpleController())
|
||||
MockMvcWebTestClient.bindToController(new SimpleController())
|
||||
.defaultRequest(get("/").servletPath("/main"))
|
||||
.build();
|
||||
|
||||
private final WebTestClient client =
|
||||
MockMvcTestClient.bindToController(new SimpleController()).build();
|
||||
MockMvcWebTestClient.bindToController(new SimpleController()).build();
|
||||
|
||||
|
||||
@Test
|
||||
@@ -76,7 +76,7 @@ public class RequestAttributeAssertionTests {
|
||||
.expectStatus().isOk()
|
||||
.expectBody().isEmpty();
|
||||
|
||||
return MockMvcTestClient.resultActionsFor(result);
|
||||
return MockMvcWebTestClient.resultActionsFor(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -39,7 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.SessionAttributeAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -47,7 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class SessionAttributeAssertionTests {
|
||||
|
||||
private final WebTestClient client =
|
||||
MockMvcTestClient.bindToController(new SimpleController())
|
||||
MockMvcWebTestClient.bindToController(new SimpleController())
|
||||
.alwaysExpect(status().isOk())
|
||||
.build();
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SessionAttributeAssertionTests {
|
||||
|
||||
private ResultActions performRequest() {
|
||||
EntityExchangeResult<Void> result = client.post().uri("/").exchange().expectBody().isEmpty();
|
||||
return MockMvcTestClient.resultActionsFor(result);
|
||||
return MockMvcWebTestClient.resultActionsFor(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
@@ -37,7 +37,7 @@ import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
import static org.springframework.http.HttpStatus.NOT_IMPLEMENTED;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.StatusAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -45,7 +45,7 @@ import static org.springframework.http.HttpStatus.NOT_IMPLEMENTED;
|
||||
public class StatusAssertionTests {
|
||||
|
||||
private final WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new StatusController()).build();
|
||||
MockMvcWebTestClient.bindToController(new StatusController()).build();
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,14 +21,14 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrlPattern;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrlPattern;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.UrlAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -36,7 +36,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class UrlAssertionTests {
|
||||
|
||||
private final WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new SimpleController()).build();
|
||||
MockMvcWebTestClient.bindToController(new SimpleController()).build();
|
||||
|
||||
|
||||
@Test
|
||||
@@ -52,7 +52,7 @@ public class UrlAssertionTests {
|
||||
EntityExchangeResult<Void> result =
|
||||
testClient.get().uri("/persons").exchange().expectBody().isEmpty();
|
||||
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(redirectedUrlPattern("/persons/*"));
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class UrlAssertionTests {
|
||||
EntityExchangeResult<Void> result =
|
||||
testClient.get().uri("/").exchange().expectBody().isEmpty();
|
||||
|
||||
MockMvcTestClient.resultActionsFor(result)
|
||||
MockMvcWebTestClient.resultActionsFor(result)
|
||||
.andExpect(forwardedUrlPattern("/ho?e"));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
@@ -30,7 +30,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.UrlAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -38,21 +38,21 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
public class ViewNameAssertionTests {
|
||||
|
||||
private final WebTestClient client =
|
||||
MockMvcTestClient.bindToController(new SimpleController())
|
||||
MockMvcWebTestClient.bindToController(new SimpleController())
|
||||
.alwaysExpect(status().isOk())
|
||||
.build();
|
||||
|
||||
|
||||
@Test
|
||||
public void testEqualTo() throws Exception {
|
||||
MockMvcTestClient.resultActionsFor(performRequest())
|
||||
MockMvcWebTestClient.resultActionsFor(performRequest())
|
||||
.andExpect(view().name("mySpecialView"))
|
||||
.andExpect(view().name(equalTo("mySpecialView")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHamcrestMatcher() throws Exception {
|
||||
MockMvcTestClient.resultActionsFor(performRequest())
|
||||
MockMvcWebTestClient.resultActionsFor(performRequest())
|
||||
.andExpect(view().name(containsString("Special")));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@@ -40,7 +40,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.XmlContentAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -58,7 +58,7 @@ public class XmlContentAssertionTests {
|
||||
|
||||
|
||||
private final WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new MusicController())
|
||||
MockMvcWebTestClient.bindToController(new MusicController())
|
||||
.alwaysExpect(status().isOk())
|
||||
.alwaysExpect(content().contentType(MediaType.parseMediaType("application/xml;charset=UTF-8")))
|
||||
.configureClient()
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcTestClient;
|
||||
import org.springframework.test.web.servlet.client.MockMvcWebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@@ -48,7 +48,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.HEAD;
|
||||
|
||||
/**
|
||||
* MockMvcTestClient equivalent of the MockMvc
|
||||
* {@link MockMvcWebTestClient} equivalent of the MockMvc
|
||||
* {@link org.springframework.test.web.servlet.samples.standalone.resultmatchers.XpathAssertionTests}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -59,7 +59,7 @@ public class XpathAssertionTests {
|
||||
Collections.singletonMap("ns", "https://example.org/music/people");
|
||||
|
||||
private final WebTestClient testClient =
|
||||
MockMvcTestClient.bindToController(new MusicController())
|
||||
MockMvcWebTestClient.bindToController(new MusicController())
|
||||
.alwaysExpect(status().isOk())
|
||||
.alwaysExpect(content().contentType(MediaType.parseMediaType("application/xml;charset=UTF-8")))
|
||||
.configureClient()
|
||||
@@ -157,7 +157,7 @@ public class XpathAssertionTests {
|
||||
|
||||
@Test
|
||||
public void testFeedWithLinefeedChars() {
|
||||
MockMvcTestClient.bindToController(new BlogFeedController()).build()
|
||||
MockMvcWebTestClient.bindToController(new BlogFeedController()).build()
|
||||
.get().uri("/blog.atom")
|
||||
.accept(MediaType.APPLICATION_ATOM_XML)
|
||||
.exchange()
|
||||
|
||||
Reference in New Issue
Block a user