| 1 |
|
package jalview.util; |
| 2 |
|
|
| 3 |
|
import java.io.File; |
| 4 |
|
|
| 5 |
|
import org.testng.Assert; |
| 6 |
|
import org.testng.annotations.DataProvider; |
| 7 |
|
import org.testng.annotations.Test; |
| 8 |
|
|
| |
|
| 95.1% |
Uncovered Elements: 3 (61) |
Complexity: 17 |
Complexity Density: 0.49 |
|
| 9 |
|
public class LaunchUtilsTest |
| 10 |
|
{ |
| |
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
1PASS
|
|
| 11 |
9 |
@Test(groups = "Functional", dataProvider = "versionComparisons")... |
| 12 |
|
public void testVersionComparisons(String v0, String v1, int parity) |
| 13 |
|
{ |
| 14 |
9 |
int comparison = LaunchUtils.compareVersions(v0, v1); |
| 15 |
9 |
if (parity == 0) |
| 16 |
|
{ |
| 17 |
3 |
Assert.assertEquals(comparison, parity, |
| 18 |
|
"These should be parsed as the same."); |
| 19 |
|
} |
| 20 |
6 |
else if (parity < 0) |
| 21 |
|
{ |
| 22 |
4 |
Assert.assertTrue(comparison < 0, "These should be v0 < v1"); |
| 23 |
|
} |
| 24 |
2 |
else if (parity > 0) |
| 25 |
|
{ |
| 26 |
2 |
Assert.assertTrue(comparison > 0, "These should be v0 > v1"); |
| 27 |
|
} |
| 28 |
|
} |
| 29 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 30 |
1 |
@DataProvider(name = "versionComparisons")... |
| 31 |
|
public Object[][] versionComparisons() |
| 32 |
|
{ |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
1 |
return new Object[][] { |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
{ "2", "2", 0 }, |
| 43 |
|
{ "1.2.3.4", "1.2.3.4", 0 }, |
| 44 |
|
{ "1.1.1.1", "1.1.1.1", 0 }, |
| 45 |
|
{ "1.2.3", "1.2", 1 }, |
| 46 |
|
{ "1.2.3", "1.2.3.4", -1 }, |
| 47 |
|
{ "1.2.hello.4", "1.2.world.4", -1 }, |
| 48 |
|
{ "2.0a", "2.0b", -1 }, |
| 49 |
|
{ "1", "2", -1 }, |
| 50 |
|
{ "2", "1", 1 }, |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
}; |
| 55 |
|
} |
| 56 |
|
|
| |
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
1PASS
|
|
| 57 |
14 |
@Test(groups = "Functional", dataProvider = "getdownVersionComparisons")... |
| 58 |
|
public void testGetdownVersionComparisons(String v0, String v1, |
| 59 |
|
int parity) |
| 60 |
|
{ |
| 61 |
14 |
int comparison = LaunchUtils.compareGetdownLauncherJarVersions(v0, v1); |
| 62 |
14 |
if (parity == 0) |
| 63 |
|
{ |
| 64 |
5 |
Assert.assertEquals(comparison, parity, |
| 65 |
|
"These should be parsed as the same."); |
| 66 |
|
} |
| 67 |
9 |
else if (parity < 0) |
| 68 |
|
{ |
| 69 |
5 |
Assert.assertTrue(comparison < 0, "These should be v0 < v1"); |
| 70 |
|
} |
| 71 |
4 |
else if (parity > 0) |
| 72 |
|
{ |
| 73 |
4 |
Assert.assertTrue(comparison > 0, "These should be v0 > v1"); |
| 74 |
|
} |
| 75 |
|
} |
| 76 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
1 |
@DataProvider(name = "getdownVersionComparisons")... |
| 78 |
|
public Object[][] getdownVersionComparisons() |
| 79 |
|
{ |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
1 |
return new Object[][] { |
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
{ "2", "2", 0 }, |
| 90 |
|
{ "1.2.3.4", "1.2.3.4", 0 }, |
| 91 |
|
{ "1.1.1.1", "1.1.1.1", 0 }, |
| 92 |
|
{ "1.2.3", "1.2", 1 }, |
| 93 |
|
{ "1.2.3", "1.2.3.4", -1 }, |
| 94 |
|
{ "1.2.hello.4", "1.2.world.4", -1 }, |
| 95 |
|
{ "2.0a", "2.0b", -1 }, |
| 96 |
|
{ "1", "2", -1 }, |
| 97 |
|
{ "2", "1", 1 }, |
| 98 |
|
{ "1.8.3-1.4.0_JVL", "1.8.3-1.4.0_JVL", 0 }, |
| 99 |
|
{ "1.2.3-4.5.6-7.8.9_NOJVL", "1.2.3-4.5.6-7.8.9_JVL", 0 }, |
| 100 |
|
{ "1.2.3-4.6.0-7.8.9", "1.2.3-4.5.6-9.0.0", 1 }, |
| 101 |
|
{ "1.2.3-4.5.6-7.8.9", "1.2.3-4.5.6-9.0.0", -1 }, |
| 102 |
|
{ "1.3.0-4.5.6-7.8.9", "1.2.3-4.5.6-9.0.0", 1 }, |
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
}; |
| 107 |
|
} |
| 108 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 109 |
4 |
@Test(groups = "Functional", dataProvider = "jarVersions")... |
| 110 |
|
public void testJarVersions(File f0, String version) |
| 111 |
|
{ |
| 112 |
4 |
String implementationVersion = LaunchUtils |
| 113 |
|
.getJarImplementationVersion(f0); |
| 114 |
4 |
Assert.assertEquals(implementationVersion, version, |
| 115 |
|
"These should be the same."); |
| 116 |
|
} |
| 117 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 118 |
1 |
@DataProvider(name = "jarVersions")... |
| 119 |
|
public Object[][] jarVersions() |
| 120 |
|
{ |
| 121 |
1 |
File f0 = new File( |
| 122 |
|
"test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.4.3.jar"); |
| 123 |
1 |
File f1 = new File( |
| 124 |
|
"test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.4.4.jar"); |
| 125 |
1 |
File f2 = new File( |
| 126 |
|
"test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.5.0.jar"); |
| 127 |
1 |
File f3 = new File( |
| 128 |
|
"test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.4-1.5.0.jar"); |
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
1 |
return new Object[][] { |
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
{ f0, "1.8.3-1.4.3_JVL" }, |
| 138 |
|
{ f1, "1.8.3-1.4.4_JVL" }, |
| 139 |
|
{ f2, "1.8.3-1.5.0_JVL" }, |
| 140 |
|
{ f3, "1.8.4-1.5.0_JVL" }, |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
}; |
| 145 |
|
} |
| 146 |
|
|
| |
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
1PASS
|
|
| 147 |
12 |
@Test(groups = "Functional", dataProvider = "jarVersionComparisons")... |
| 148 |
|
public void testJarVersionComparisons(File f0, File f1, int parity) |
| 149 |
|
{ |
| 150 |
12 |
int comparison = LaunchUtils.compareGetdownLauncherJarVersions(f0, f1); |
| 151 |
12 |
if (parity == 0) |
| 152 |
|
{ |
| 153 |
4 |
Assert.assertEquals(comparison, parity, |
| 154 |
|
"These should be parsed as the same."); |
| 155 |
|
} |
| 156 |
8 |
else if (parity < 0) |
| 157 |
|
{ |
| 158 |
4 |
Assert.assertTrue(comparison < 0, "These should be f0 < f1"); |
| 159 |
|
} |
| 160 |
4 |
else if (parity > 0) |
| 161 |
|
{ |
| 162 |
4 |
Assert.assertTrue(comparison > 0, "These should be f0 > f1"); |
| 163 |
|
} |
| 164 |
|
} |
| 165 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 166 |
1 |
@DataProvider(name = "jarVersionComparisons")... |
| 167 |
|
public Object[][] jarVersionComparisons() |
| 168 |
|
{ |
| 169 |
1 |
File f0 = new File( |
| 170 |
|
"test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.4.3.jar"); |
| 171 |
1 |
File f1 = new File( |
| 172 |
|
"test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.4.4.jar"); |
| 173 |
1 |
File f2 = new File( |
| 174 |
|
"test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.5.0.jar"); |
| 175 |
1 |
File f3 = new File( |
| 176 |
|
"test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.4-1.5.0.jar"); |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
1 |
return new Object[][] { |
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
{ f0, f0, 0 }, |
| 187 |
|
{ f1, f1, 0 }, |
| 188 |
|
{ f2, f2, 0 }, |
| 189 |
|
{ f3, f3, 0 }, |
| 190 |
|
{ f1, f0, 1 }, |
| 191 |
|
{ f2, f1, 1 }, |
| 192 |
|
{ f3, f2, 1 }, |
| 193 |
|
{ f3, f0, 1 }, |
| 194 |
|
{ f0, f1, -1 }, |
| 195 |
|
{ f1, f2, -1 }, |
| 196 |
|
{ f2, f3, -1 }, |
| 197 |
|
{ f0, f3, -1 }, |
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
}; |
| 202 |
|
} |
| 203 |
|
} |