mercredi 8 janvier 2020

JUnit-test when form has enctype="multipart/form-data"

There's this form:

<form action="someServlet" method="POST" enctype='multipart/form-data'>

    <!-- Other parameters -->

    Curriculum: <input type="file" name="curriculum">

    <input type="submit" value="Confirm">
</form> 

so in my servlet I'm using request.getPart("curriculum") to obtain the file submitted. In my test class I've setted up the MockHttpServletRequest and the MockHttpServletResponse, how should I set the parameter in the request to send the file to the servlet?

Aucun commentaire:

Enregistrer un commentaire