Let's start with a file upload servlet implementation. I will omit some unnecessary details and concentrate on two issues: get application context and retrieve/save file to disk.
Servlet is ready. Let's develop test case to verify it. There are basically three steps:
- create mock request (and response)
- create servlet instance and pass Spring application context to it
- wrap file into request and call servlet's post()
Test case is ready. Depending on your uploads management strategy (disk, database, Amazon S3, ...), test case should be extended to ensure that file has been stored by upload servlet at proper location.