Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7M7FEdeEm3APj16Bu
10 lines
808 B
Plaintext
10 lines
808 B
Plaintext
# 10-test-clients (Spring Boot 4.1.3, JDK 25)
|
|
TestRestTemplate.getForEntity("/students/1", Student.class) -> 200 OK Student[id=1, name=Asha]
|
|
RestTestClient.get().uri("/students/1").exchange().expectStatus().isOk().expectBody(Student.class) -> Student[id=1, name=Asha]
|
|
TestRestTemplate on a 404 does not throw: status 404 NOT_FOUND
|
|
RestTestClient on a 404 does not throw: expectStatus().isNotFound() passed
|
|
TestRestTemplate.postForEntity(...) -> 201 CREATED Location /students/3
|
|
RestTestClient.post()...body(...).exchange().expectStatus().isCreated().expectHeader().exists("Location") passed
|
|
TestRestTemplate.withBasicAuth("user", "pw") -> server saw Authorization: Basic dXNlcjpwdw==
|
|
RestTestClient.mutate().defaultHeaders(h -> h.setBasicAuth("user", "pw")) -> server saw Authorization: Basic dXNlcjpwdw==
|