1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import jalview.gui.JvOptionPane; |
24 |
|
|
25 |
|
import java.io.File; |
26 |
|
import java.io.IOException; |
27 |
|
|
28 |
|
import org.testng.AssertJUnit; |
29 |
|
import org.testng.annotations.AfterClass; |
30 |
|
import org.testng.annotations.BeforeClass; |
31 |
|
import org.testng.annotations.Test; |
32 |
|
|
33 |
|
|
34 |
|
@author |
35 |
|
|
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 10 |
Complexity Density: 0.43 |
|
37 |
|
public class FileIOTester |
38 |
|
{ |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
40 |
1 |
@BeforeClass(alwaysRun = true)... |
41 |
|
public void setUpJvOptionPane() |
42 |
|
{ |
43 |
1 |
JvOptionPane.setInteractiveMode(false); |
44 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
@throws |
49 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
50 |
1 |
@BeforeClass(alwaysRun = true)... |
51 |
|
public static void setUpBeforeClass() throws Exception |
52 |
|
{ |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
@throws |
57 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
58 |
1 |
@AfterClass(alwaysRun = true)... |
59 |
|
public static void tearDownAfterClass() throws Exception |
60 |
|
{ |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
final static File ALIGN_FILE = new File( |
66 |
|
"test/jalview/io/test_gz_fasta.gz"); |
67 |
|
|
68 |
|
final static File NOTGZALIGN_FILE = new File( |
69 |
|
"test/jalview/io/test_gz_fasta_notgz.gz"); |
70 |
|
|
71 |
|
final static File STARS_FA_FILE1 = new File( |
72 |
|
"test/jalview/io/test_fasta_stars.fa"); |
73 |
|
|
74 |
|
final static File STARS_FA_FILE2 = new File( |
75 |
|
"test/jalview/io/test_fasta_stars2.fa"); |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
77 |
6 |
private void assertValidFormat(FileFormatI fmt, String src, FileParse fp)... |
78 |
|
throws FileFormatException |
79 |
|
{ |
80 |
6 |
AssertJUnit.assertTrue("Couldn't resolve " + src + " as a valid file", |
81 |
|
fp.isValid()); |
82 |
6 |
FileFormatI type = new IdentifyFile().identify(fp); |
83 |
6 |
AssertJUnit.assertSame("Data from '" + src + "' Expected to be '" + fmt |
84 |
|
+ "' identified as '" + type + "'", type, fmt); |
85 |
|
} |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
87 |
1 |
@Test(groups = { "Functional" })... |
88 |
|
public void testStarsInFasta1() throws IOException |
89 |
|
{ |
90 |
1 |
String uri; |
91 |
1 |
FileParse fp = new FileParse(uri = STARS_FA_FILE1.getAbsoluteFile() |
92 |
|
.toString(), DataSourceType.FILE); |
93 |
1 |
assertValidFormat(FileFormat.Fasta, uri, fp); |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
96 |
1 |
@Test(groups = { "Functional" })... |
97 |
|
public void testStarsInFasta2() throws IOException |
98 |
|
{ |
99 |
1 |
String uri; |
100 |
1 |
FileParse fp = new FileParse(uri = STARS_FA_FILE2.getAbsoluteFile() |
101 |
|
.toString(), DataSourceType.FILE); |
102 |
1 |
assertValidFormat(FileFormat.Fasta, uri, fp); |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
105 |
1 |
@Test(groups = { "Functional" })... |
106 |
|
public void testGzipIo() throws IOException |
107 |
|
{ |
108 |
1 |
String uri; |
109 |
1 |
FileParse fp = new FileParse(uri = ALIGN_FILE.getAbsoluteFile().toURI() |
110 |
|
.toString(), DataSourceType.URL); |
111 |
1 |
assertValidFormat(FileFormat.Fasta, uri, fp); |
112 |
|
} |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
114 |
1 |
@Test(groups = { "Functional" })... |
115 |
|
public void testGziplocalFileIO() throws IOException |
116 |
|
{ |
117 |
1 |
String filepath; |
118 |
1 |
FileParse fp = new FileParse(filepath = ALIGN_FILE.getAbsoluteFile() |
119 |
|
.toString(), DataSourceType.FILE); |
120 |
1 |
assertValidFormat(FileFormat.Fasta, filepath, fp); |
121 |
|
} |
122 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
123 |
1 |
@Test(groups = { "Functional" })... |
124 |
|
public void testNonGzipURLIO() throws IOException |
125 |
|
{ |
126 |
1 |
String uri; |
127 |
1 |
FileParse fp = new FileParse(uri = NOTGZALIGN_FILE.getAbsoluteFile() |
128 |
|
.toURI().toString(), DataSourceType.URL); |
129 |
1 |
assertValidFormat(FileFormat.Fasta, uri, fp); |
130 |
|
} |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
132 |
1 |
@Test(groups = { "Functional" })... |
133 |
|
public void testNonGziplocalFileIO() throws IOException |
134 |
|
{ |
135 |
1 |
String filepath; |
136 |
1 |
FileParse fp = new FileParse(filepath = NOTGZALIGN_FILE |
137 |
|
.getAbsoluteFile().toString(), DataSourceType.FILE); |
138 |
1 |
assertValidFormat(FileFormat.Fasta, filepath, fp); |
139 |
|
} |
140 |
|
} |