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 |
|
import jalview.json.binding.biojs.BioJSReleasePojo; |
25 |
|
import jalview.json.binding.biojs.BioJSRepositoryPojo; |
26 |
|
|
27 |
|
import java.io.File; |
28 |
|
import java.io.IOException; |
29 |
|
import java.net.MalformedURLException; |
30 |
|
import java.net.URISyntaxException; |
31 |
|
import java.net.URL; |
32 |
|
import java.net.URLConnection; |
33 |
|
import java.util.TreeMap; |
34 |
|
|
35 |
|
import org.testng.Assert; |
36 |
|
import org.testng.AssertJUnit; |
37 |
|
import org.testng.annotations.BeforeClass; |
38 |
|
import org.testng.annotations.Test; |
39 |
|
|
|
|
| 50% |
Uncovered Elements: 27 (54) |
Complexity: 12 |
Complexity Density: 0.25 |
|
40 |
|
public class BioJsHTMLOutputTest |
41 |
|
{ |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
43 |
1 |
@BeforeClass(alwaysRun = true)... |
44 |
|
public void setUpJvOptionPane() |
45 |
|
{ |
46 |
1 |
JvOptionPane.setInteractiveMode(false); |
47 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
48 |
|
} |
49 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.33 |
1PASS
|
|
50 |
1 |
@Test(groups = { "Functional" })... |
51 |
|
public void getJalviewAlignmentAsJsonString() |
52 |
|
{ |
53 |
1 |
String bjsTemplate = null; |
54 |
1 |
try |
55 |
|
{ |
56 |
1 |
BioJsHTMLOutput.updateBioJS(); |
57 |
1 |
try |
58 |
|
{ |
59 |
|
|
60 |
|
|
61 |
1 |
Thread.sleep(1000 * 3); |
62 |
|
} catch (InterruptedException e) |
63 |
|
{ |
64 |
0 |
e.printStackTrace(); |
65 |
|
} |
66 |
1 |
bjsTemplate = HTMLOutput.readFileAsString(BioJsHTMLOutput |
67 |
|
.getCurrentBJSTemplateFile()); |
68 |
|
|
69 |
|
} catch (IOException e) |
70 |
|
{ |
71 |
0 |
e.printStackTrace(); |
72 |
|
} |
73 |
1 |
Assert.assertNotNull(bjsTemplate); |
74 |
|
} |
75 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
76 |
1 |
@Test(... |
77 |
|
groups = { "Functional" }, |
78 |
|
expectedExceptions = NullPointerException.class) |
79 |
|
public void expectedNullPointerException() |
80 |
|
{ |
81 |
1 |
try |
82 |
|
{ |
83 |
1 |
BioJsHTMLOutput.refreshVersionInfo(null); |
84 |
|
} catch (URISyntaxException e) |
85 |
|
{ |
86 |
0 |
AssertJUnit.fail("Expception occured while testing!"); |
87 |
0 |
e.printStackTrace(); |
88 |
|
} |
89 |
|
} |
90 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 2 |
Complexity Density: 0.14 |
1PASS
|
|
91 |
1 |
@Test(groups = { "Functional" })... |
92 |
|
public void getBioJsMSAVersions() |
93 |
|
{ |
94 |
1 |
TreeMap<String, File> versions = null; |
95 |
1 |
try |
96 |
|
{ |
97 |
1 |
BioJsHTMLOutput |
98 |
|
.refreshVersionInfo(BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY); |
99 |
1 |
versions = BioJsHTMLOutput.getBioJsMSAVersions(); |
100 |
|
} catch (URISyntaxException e) |
101 |
|
{ |
102 |
0 |
AssertJUnit.fail("Expception occured while testing!"); |
103 |
0 |
e.printStackTrace(); |
104 |
|
} |
105 |
1 |
AssertJUnit.assertNotNull("No versions found", versions); |
106 |
1 |
AssertJUnit.assertTrue("One or more Templates required", |
107 |
|
versions.size() > 0); |
108 |
1 |
System.out |
109 |
|
.println("Number of discovered versions : " + versions.size()); |
110 |
1 |
for (String v : versions.keySet()) |
111 |
|
{ |
112 |
3 |
System.out.println("version : " + v); |
113 |
3 |
System.out.println("File : " + versions.get(v)); |
114 |
|
} |
115 |
|
|
116 |
1 |
System.out.println("\nCurrent latest version : " |
117 |
|
+ BioJsHTMLOutput.getCurrentBJSTemplateFile()); |
118 |
1 |
AssertJUnit.assertNotNull("Latest BioJsMSA version NOT found!", |
119 |
|
BioJsHTMLOutput.getCurrentBJSTemplateFile()); |
120 |
|
|
121 |
|
} |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
123 |
0 |
@Test(groups = { "Network" })... |
124 |
|
public void testBioJsUpdate() |
125 |
|
{ |
126 |
0 |
String url = BioJsHTMLOutput.BJS_TEMPLATE_GIT_REPO; |
127 |
0 |
AssertJUnit |
128 |
|
.assertTrue("URL not reacable : " + url, urlIsReachable(url)); |
129 |
0 |
String response = BioJsHTMLOutput.getURLContentAsString(url); |
130 |
0 |
AssertJUnit.assertNotNull("Null response read from url!", response); |
131 |
0 |
BioJSRepositoryPojo repository = new BioJSRepositoryPojo(response); |
132 |
0 |
System.out.println(">>> description : " + repository.getDescription()); |
133 |
0 |
System.out.println(">>> latest version : " |
134 |
|
+ repository.getLatestReleaseVersion()); |
135 |
0 |
System.out.println(">>> repo count : " |
136 |
|
+ repository.getReleases().size()); |
137 |
0 |
for (BioJSReleasePojo release : repository.getReleases()) |
138 |
|
{ |
139 |
0 |
System.out.println("repo type : " + release.getType()); |
140 |
0 |
System.out.println("url : " + release.getUrl()); |
141 |
0 |
System.out.println("release version : " + release.getVersion()); |
142 |
|
} |
143 |
|
} |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.43 |
|
145 |
0 |
private static boolean urlIsReachable(String urlString)... |
146 |
|
{ |
147 |
0 |
try |
148 |
|
{ |
149 |
0 |
final URL url = new URL(urlString); |
150 |
0 |
final URLConnection conn = url.openConnection(); |
151 |
0 |
conn.connect(); |
152 |
0 |
return true; |
153 |
|
} catch (MalformedURLException e) |
154 |
|
{ |
155 |
0 |
throw new RuntimeException(e); |
156 |
|
} catch (IOException e) |
157 |
|
{ |
158 |
0 |
return false; |
159 |
|
} |
160 |
|
} |
161 |
|
} |