| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ws.utils; |
| 22 |
|
|
| 23 |
|
import java.io.File; |
| 24 |
|
import java.io.IOException; |
| 25 |
|
|
| 26 |
|
import org.testng.Assert; |
| 27 |
|
import org.testng.annotations.Test; |
| 28 |
|
|
| |
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 5 |
Complexity Density: 0.28 |
|
| 29 |
|
public class UrlDownloadClientTest |
| 30 |
|
{ |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.29 |
4-
|
|
| 35 |
0 |
@Test(groups = { "Network" }, enabled = true)... |
| 36 |
|
public void UrlDownloadTest() |
| 37 |
|
{ |
| 38 |
0 |
UrlDownloadClient client = new UrlDownloadClient(); |
| 39 |
0 |
String urlstring = "http://identifiers.org/rest/collections/"; |
| 40 |
0 |
String outfile = "testfile.tmp"; |
| 41 |
|
|
| 42 |
0 |
try |
| 43 |
|
{ |
| 44 |
0 |
client.download(urlstring, outfile); |
| 45 |
|
} catch (IOException e) |
| 46 |
|
{ |
| 47 |
0 |
Assert.fail("Exception was thrown from UrlDownloadClient download: " |
| 48 |
|
+ e.getMessage()); |
| 49 |
0 |
File f = new File(outfile); |
| 50 |
0 |
if (f.exists()) |
| 51 |
|
{ |
| 52 |
0 |
f.delete(); |
| 53 |
|
} |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
|
| 57 |
0 |
File f = new File(outfile); |
| 58 |
0 |
Assert.assertTrue(f.exists()); |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
0 |
Assert.assertTrue(f.length() > 250000); |
| 63 |
|
|
| 64 |
0 |
if (f.exists()) |
| 65 |
|
{ |
| 66 |
0 |
f.delete(); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
4-
|
|
| 74 |
0 |
@Test(... |
| 75 |
|
groups = |
| 76 |
|
{ "Network" }, |
| 77 |
|
enabled = true, |
| 78 |
|
expectedExceptions = |
| 79 |
|
{ IOException.class }) |
| 80 |
|
public void DownloadGarbageUrlTest() throws IOException |
| 81 |
|
{ |
| 82 |
0 |
UrlDownloadClient client = new UrlDownloadClient(); |
| 83 |
0 |
String urlstring = "identifiers.org/rest/collections/"; |
| 84 |
0 |
String outfile = "testfile.tmp"; |
| 85 |
|
|
| 86 |
0 |
client.download(urlstring, outfile); |
| 87 |
|
} |
| 88 |
|
} |