FileViewer { @GET @Path("{filename}") @Produces(MediaType.TEXT_PLAIN) public Response get(@PathParam("filename") final String file) { String fileContents = read(file); if (fileContents == null) return error(); else return Response.status(200).entity(fileContents).build(); }  @GET @Path("{filename}") @Produces(MediaType.TEXT_PLAIN) Response get(@PathParam("filename") final String file); @GET @Path("list") @Produces(MediaType.TEXT_PLAIN) Response list(); @GET @Path("{filename}/json") @Produces(MediaType.APPLICATION_JSON) Response json(@PathParam("filename") final String file);  }
@Test public void shouldNotGetFileContents() { Response response = fileViewer.get("non-existing-file" + System.currentTimeMillis() + ".txt"); Assert.assertEquals(404, response.getStatus()); Assert.assertEquals("File not found", response.getEntity()); }
@Test public void shouldGetFileContents() { Response response = fileViewer.get(getAvailableFile()); Assert.assertEquals(200, response.getStatus()); Assert.assertNotSame("", response.getEntity()); }