@@ -0,0 +1,1956 @@
+package org.apache.taverna.download.impl;%0A%0Aimport java.io.File;%0Aimport java.net.URL;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.util.Collections;%0Aimport static java.nio.charset.StandardCharsets.US_ASCII;%0A%0Aimport org.apache.taverna.download.DownloadException;%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;%0A%0Apublic class TestDownloadManagerImpl %7B%0A%09%0A%09/**%0A%09 * This test should remain commented out %0A%09 * as it relies on a third-party %0A%09 * web service.%0A%09 * %0A%09 * Verifies %0A%09 * %0A%09 */%0A%09@Test(expected=DownloadException.class)%0A%09public void handle300MultipleChoice() throws Exception %7B%0A%09%09DownloadManagerImpl dl = new DownloadManagerImpl();%0A%09%09Path pomFile = Files.createTempFile(%22test%22, %22.pom%22);%0A%09%09// NOTE: The below URL is a Taverna 2 POM - not related to %0A%09%09// taverna-plugin-impl%0A%09%09URL wrongURL = new URL(%22http://192.185.115.65/~diana/DIANA_plugin_updated/test-plugins/gr/dianatools/diana.services-activity/1.0-SNAPSHOT/diana.services-activity-1.0-SNAPSHOT.pom%22);%0A%09%09dl.download(wrongURL, pomFile.toFile(), %22MD5%22);%09%0A%09%7D%0A%09%0A%09/**%0A%09 * Test downloading a file:/// to a File, checking md5 hashsum.%0A%09 * %0A%09 * This might seem silly, but avoids spinning up a Jetty instance%0A%09 * just for this unit test.%0A%09 * %0A%09 */%0A%09@Test%0A%09public void downloadLocalFile() throws Exception %7B%0A%09%09Path example = Files.createTempFile(%22example%22, %22.txt%22);%0A%09%09Files.write(example, %22Hello world%22.getBytes(US_ASCII)); // No newline%0A%09%09Path exampleMd5 = example.resolve(example.getFileName() + %22.md5%22);%0A//%09%09stain@biggie:~$ echo -n %22Hello world%22%7Cmd5sum%0A//%09%093e25960a79dbc69b674cd4ec67a72c62  -%0A%09%09Files.write(exampleMd5, %223e25960a79dbc69b674cd4ec67a72c62%22.getBytes(US_ASCII));%0A%09%09%0A%09%09DownloadManagerImpl dl = new DownloadManagerImpl();%0A%09%09%0A%09%09Path toFile = Files.createTempFile(%22downloaded%22, %22.txt%22);%0A%09%09%0A%09%09dl.download(example.toUri().toURL(), toFile.toFile(), %22MD5%22);%0A%09%09String hello = Files.readAllLines(toFile, US_ASCII).get(0);%0A%09%09%0A%09%09assertEquals(%22Hello world%22, hello);%0A%09%09%0A%09%7D%0A%09%0A%7D%0A

Test DownloadMnagerImpl