mardi 20 octobre 2015

How to apply jUnit test on a void method

i have this class

@Value("${norsys.loadfile.directory}")
private String chemin;

@RequestMapping(value = "/{fileName:.+}", method = RequestMethod.GET)
@ResponseBody()
public void loadVideoFile(@PathVariable("fileName") String fileName,HttpServletResponse response) {
    try {
        response.setContentType("video/mp4");
        Files.copy(Paths.get(chemin, fileName), response.getOutputStream());
        response.flushBuffer();
    } catch (java.io.FileNotFoundException e) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
    } catch (Exception e) {
        response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
    }
}

I dont know how to apply a JUnit test to keep coverage high, I hope that you can give me an idea, thank you

Aucun commentaire:

Enregistrer un commentaire