use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class XmlConfigTests method setup.
@BeforeEach
public void setup() {
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
}
use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class AsyncTests method callable.
@Test
public void callable() throws Exception {
MvcResult mvcResult = this.mockMvc.perform(get("/1").param("callable", "true")).andExpect(request().asyncStarted()).andExpect(request().asyncResult(equalTo(new Person("Joe")))).andExpect(request().asyncResult(new Person("Joe"))).andReturn();
this.mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class JavaConfigTests method setup.
@BeforeEach
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
verifyRootWacSupport();
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
}
use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class SseTests method sse.
@Test
public void sse() {
FluxExchangeResult<Person> exchangeResult = this.testClient.get().uri("/persons").exchange().expectStatus().isOk().expectHeader().contentType("text/event-stream").returnResult(Person.class);
StepVerifier.create(exchangeResult.getResponseBody()).expectNext(new Person("N0"), new Person("N1"), new Person("N2")).expectNextCount(4).consumeNextWith(person -> assertThat(person.getName()).endsWith("7")).thenCancel().verify();
}
use of org.springframework.test.web.Person in project spring-framework by spring-projects.
the class SampleTests method performGetManyTimes.
@Test
public void performGetManyTimes() {
String responseBody = "{\"name\" : \"Ludwig van Beethoven\", \"someDouble\" : \"1.6035\"}";
this.mockServer.expect(manyTimes(), requestTo("/composers/42")).andExpect(method(HttpMethod.GET)).andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON));
@SuppressWarnings("unused") Person ludwig = this.restTemplate.getForObject("/composers/{id}", Person.class, 42);
// We are only validating the request. The response is mocked out.
// hotel.getId() == 42
// hotel.getName().equals("Holiday Inn")
this.restTemplate.getForObject("/composers/{id}", Person.class, 42);
this.restTemplate.getForObject("/composers/{id}", Person.class, 42);
this.restTemplate.getForObject("/composers/{id}", Person.class, 42);
this.mockServer.verify();
}
Aggregations