An upload-and-probe trace distinguishes controller rejection, stored-file state and operational readiness.
Spring exercise: trace upload rejection and readiness changes
Predict the upload matrix
Send a valid short CSV with the original filename ../../outside.csv, an oversized part, an HTML body labelled text/csv, an invalid UTF-8 byte, an empty part and a missing part. Predict each status and whether the temporary directory contains a file. The accepted request stores bytes under a generated basename. The oversize request returns 413; fake-format and invalid-encoding requests return 422; empty and missing parts return 400. Rejected requests leave no file in the checked fixture.
Now set the test dependency indicator DOWN. Predict readiness, liveness and anonymous API status: 503, 200 and 401. The two halves use different test boundaries. Multipart runs under standalone MockMvc, while health runs over a local HTTP port.
Extend the proofs
Add a test where storage writing fails after a temporary path is created, then check cleanup. Add a deployed multipart size test against an actual servlet container, and a readiness test with a bounded dependency timeout. The source kit does not include those extensions, and this exercise has no hosted judge. State exactly which new outcome each extension would prove.
Checked source
mvn -q -Dtest=MultipartReceiptImportTest,ReadinessHealthGroupHttpTest testVerification boundary
MultipartReceiptImportTest and ReadinessHealthGroupHttpTest provide the local status and state outcomes in the downloadable Spring source kit. The excerpt is shortened; the kit contains the complete test.
Costs and limits
The exercise combines separate local fixtures; the upload route is not registered in ReceiptApplication and the health indicator is test-only. It does not model malware scanning, persistent import jobs, a Kubernetes probe or a real dependency outage.
Common Mistakes
- Do not infer storage state from a response code alone.
- Do not call a malformed upload a parsed CSV row failure.
- Do not equate liveness with dependency readiness.
Read next
Spring MVC multipart receipt import: validate before storing, Spring MockMvc multipart tests: what the fixture proves, Spring Boot readiness health group: withdraw traffic on a required dependency failure, Spring Boot liveness versus readiness: do not restart on every dependency outage.
