| 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( |
| 67 |
|
BioJsHTMLOutput.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 = |
| 78 |
|
{ "Functional" }, |
| 79 |
|
expectedExceptions = NullPointerException.class) |
| 80 |
|
public void expectedNullPointerException() |
| 81 |
|
{ |
| 82 |
1 |
try |
| 83 |
|
{ |
| 84 |
1 |
BioJsHTMLOutput.refreshVersionInfo(null); |
| 85 |
|
} catch (URISyntaxException e) |
| 86 |
|
{ |
| 87 |
0 |
AssertJUnit.fail("Expception occured while testing!"); |
| 88 |
0 |
e.printStackTrace(); |
| 89 |
|
} |
| 90 |
|
} |
| 91 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 2 |
Complexity Density: 0.14 |
1PASS
|
|
| 92 |
1 |
@Test(groups = { "Functional" })... |
| 93 |
|
public void getBioJsMSAVersions() |
| 94 |
|
{ |
| 95 |
1 |
TreeMap<String, File> versions = null; |
| 96 |
1 |
try |
| 97 |
|
{ |
| 98 |
1 |
BioJsHTMLOutput.refreshVersionInfo( |
| 99 |
|
BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY); |
| 100 |
1 |
versions = BioJsHTMLOutput.getBioJsMSAVersions(); |
| 101 |
|
} catch (URISyntaxException e) |
| 102 |
|
{ |
| 103 |
0 |
AssertJUnit.fail("Expception occured while testing!"); |
| 104 |
0 |
e.printStackTrace(); |
| 105 |
|
} |
| 106 |
1 |
AssertJUnit.assertNotNull("No versions found", versions); |
| 107 |
1 |
AssertJUnit.assertTrue("One or more Templates required", |
| 108 |
|
versions.size() > 0); |
| 109 |
1 |
System.out |
| 110 |
|
.println("Number of discovered versions : " + versions.size()); |
| 111 |
1 |
for (String v : versions.keySet()) |
| 112 |
|
{ |
| 113 |
3 |
System.out.println("version : " + v); |
| 114 |
3 |
System.out.println("File : " + versions.get(v)); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
1 |
System.out.println("\nCurrent latest version : " |
| 118 |
|
+ BioJsHTMLOutput.getCurrentBJSTemplateFile()); |
| 119 |
1 |
AssertJUnit.assertNotNull("Latest BioJsMSA version NOT found!", |
| 120 |
|
BioJsHTMLOutput.getCurrentBJSTemplateFile()); |
| 121 |
|
|
| 122 |
|
} |
| 123 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
| 124 |
0 |
@Test(groups = { "Network" })... |
| 125 |
|
public void testBioJsUpdate() |
| 126 |
|
{ |
| 127 |
0 |
String url = BioJsHTMLOutput.BJS_TEMPLATE_GIT_REPO; |
| 128 |
0 |
AssertJUnit.assertTrue("URL not reacable : " + url, |
| 129 |
|
urlIsReachable(url)); |
| 130 |
0 |
String response = BioJsHTMLOutput.getURLContentAsString(url); |
| 131 |
0 |
AssertJUnit.assertNotNull("Null response read from url!", response); |
| 132 |
0 |
BioJSRepositoryPojo repository = new BioJSRepositoryPojo(response); |
| 133 |
0 |
System.out.println(">>> description : " + repository.getDescription()); |
| 134 |
0 |
System.out.println( |
| 135 |
|
">>> latest version : " + repository.getLatestReleaseVersion()); |
| 136 |
0 |
System.out |
| 137 |
|
.println(">>> repo count : " + repository.getReleases().size()); |
| 138 |
0 |
for (BioJSReleasePojo release : repository.getReleases()) |
| 139 |
|
{ |
| 140 |
0 |
System.out.println("repo type : " + release.getType()); |
| 141 |
0 |
System.out.println("url : " + release.getUrl()); |
| 142 |
0 |
System.out.println("release version : " + release.getVersion()); |
| 143 |
|
} |
| 144 |
|
} |
| 145 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 146 |
0 |
private static boolean urlIsReachable(String urlString)... |
| 147 |
|
{ |
| 148 |
0 |
try |
| 149 |
|
{ |
| 150 |
0 |
final URL url = new URL(urlString); |
| 151 |
0 |
final URLConnection conn = url.openConnection(); |
| 152 |
0 |
conn.connect(); |
| 153 |
0 |
return true; |
| 154 |
|
} catch (MalformedURLException e) |
| 155 |
|
{ |
| 156 |
0 |
throw new RuntimeException(e); |
| 157 |
|
} catch (IOException e) |
| 158 |
|
{ |
| 159 |
0 |
return false; |
| 160 |
|
} |
| 161 |
|
} |
| 162 |
|
} |