### Question:
DownloadTask { public TmpFile execute() throws ErrorCodeException, InvalidContentException, FileSizeOutOfRangeException, UnreachableUrlException { ProbesHandler.DOWNLOAD.addProcessing(this.probesGroup); URL currentUrl = this.url; HttpURLConnection connection = null; TmpFile theFile = null; int i; for (i = 0; i < this.maxTrials; i++) { try { connection = (HttpURLConnection) currentUrl.openConnection(); connection.setConnectTimeout(Constantes.CONNECTION_TIMEOUT); connection.setReadTimeout(Constantes.CONNECTION_TIMEOUT); if (connection.getResponseCode() / 100 != 2) { throw new ErrorCodeException(connection.getResponseCode()); } else if ("video".contains(connection.getContentType())) { throw new InvalidContentException(connection.getContentType()); } else if (!currentUrl.equals(connection.getURL())) { currentUrl = connection.getURL(); } else { final int fileSize = connection.getContentLength(); if ((fileSize > this.maxFileSize) || (fileSize <= 0)) { throw new FileSizeOutOfRangeException(fileSize); } theFile = FilesManager.TMP_MANAGER.new TmpFile(); IOUtils.copy(connection.getInputStream(), new FileOutputStream(theFile.get())); break; } } catch (final IOException e) { } finally { if (connection != null) { connection.disconnect(); } } } if ((theFile == null) && (i == this.maxTrials)) { throw new UnreachableUrlException(); } ProbesHandler.DOWNLOAD.addProcessed(this.probesGroup); return theFile; } DownloadTask(boolean probesGroup, URL url, int maxTrials, int maxFileSize);  DownloadTask(boolean probesGroup, String url, int maxTrials, int maxFileSize);  DownloadTask(boolean probesGroup, URL url);  DownloadTask(boolean probesGroup, String url); TmpFile execute();  }### Answer:
@Test public void testDownload1() throws ErrorCodeException, InvalidContentException, FileSizeOutOfRangeException, UnreachableUrlException, MalformedURLException { final DownloadTask task = new DownloadTask(true, "http: final TmpFile resultFile = task.execute(); Assert.assertNotNull(resultFile); Assert.assertEquals(51503, resultFile.get().length()); resultFile.delete(); }
@Test(expected = FileSizeOutOfRangeException.class) public void testTooBigDownload() throws ErrorCodeException, InvalidContentException, FileSizeOutOfRangeException, UnreachableUrlException, MalformedURLException { final DownloadTask theTask = new DownloadTask(true, "http: theTask.execute(); }
@Test(expected = ErrorCodeException.class) public void test404CodeDownload() throws MalformedURLException, ErrorCodeException, InvalidContentException, FileSizeOutOfRangeException, UnreachableUrlException { final DownloadTask theTask = new DownloadTask(true, "http: theTask.execute(); }