Clover icon

Coverage Report

  1. Project Clover database Tue Mar 10 2026 14:58:44 GMT
  2. Package jalview.util

File LaunchUtilsTest.java

 

Code metrics

18
35
8
1
203
150
17
0.49
4.38
8
2.12

Classes

Class Line # Actions
LaunchUtilsTest 9 35 17
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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   
 
9    public class LaunchUtilsTest
10    {
 
11  0 toggle @Test(groups = "Functional", dataProvider = "versionComparisons")
12    public void testVersionComparisons(String v0, String v1, int parity)
13    {
14  0 int comparison = LaunchUtils.compareVersions(v0, v1);
15  0 if (parity == 0)
16    {
17  0 Assert.assertEquals(comparison, parity,
18    "These should be parsed as the same.");
19    }
20  0 else if (parity < 0)
21    {
22  0 Assert.assertTrue(comparison < 0, "These should be v0 < v1");
23    }
24  0 else if (parity > 0)
25    {
26  0 Assert.assertTrue(comparison > 0, "These should be v0 > v1");
27    }
28    }
29   
 
30  0 toggle @DataProvider(name = "versionComparisons")
31    public Object[][] versionComparisons()
32    {
33    /*
34    String v0, // a version number
35    String v1, // a version number
36    int comparison, // -1 if v0 < v1, 0 if v0 == v1, +1 if v0 > v1
37    */
38  0 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   
 
57  0 toggle @Test(groups = "Functional", dataProvider = "getdownVersionComparisons")
58    public void testGetdownVersionComparisons(String v0, String v1,
59    int parity)
60    {
61  0 int comparison = LaunchUtils.compareGetdownLauncherJarVersions(v0, v1);
62  0 if (parity == 0)
63    {
64  0 Assert.assertEquals(comparison, parity,
65    "These should be parsed as the same.");
66    }
67  0 else if (parity < 0)
68    {
69  0 Assert.assertTrue(comparison < 0, "These should be v0 < v1");
70    }
71  0 else if (parity > 0)
72    {
73  0 Assert.assertTrue(comparison > 0, "These should be v0 > v1");
74    }
75    }
76   
 
77  0 toggle @DataProvider(name = "getdownVersionComparisons")
78    public Object[][] getdownVersionComparisons()
79    {
80    /*
81    String v0, // a getdown style version number
82    String v1, // a getdown style version number
83    int comparison, // -1 if v0 < v1, 0 if v0 == v1, +1 if v0 > v1
84    */
85  0 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   
 
109  0 toggle @Test(groups = "Functional", dataProvider = "jarVersions")
110    public void testJarVersions(File f0, String version)
111    {
112  0 String implementationVersion = LaunchUtils
113    .getJarImplementationVersion(f0);
114  0 Assert.assertEquals(implementationVersion, version,
115    "These should be the same.");
116    }
117   
 
118  0 toggle @DataProvider(name = "jarVersions")
119    public Object[][] jarVersions()
120    {
121  0 File f0 = new File(
122    "test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.4.3.jar");
123  0 File f1 = new File(
124    "test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.4.4.jar");
125  0 File f2 = new File(
126    "test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.5.0.jar");
127  0 File f3 = new File(
128    "test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.4-1.5.0.jar");
129    /*
130    File f0, // a jar file
131    String version, // the Implementation-Version found in the jar's META-INF/MANIFEST.MF
132    */
133  0 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   
 
147  0 toggle @Test(groups = "Functional", dataProvider = "jarVersionComparisons")
148    public void testJarVersionComparisons(File f0, File f1, int parity)
149    {
150  0 int comparison = LaunchUtils.compareGetdownLauncherJarVersions(f0, f1);
151  0 if (parity == 0)
152    {
153  0 Assert.assertEquals(comparison, parity,
154    "These should be parsed as the same.");
155    }
156  0 else if (parity < 0)
157    {
158  0 Assert.assertTrue(comparison < 0, "These should be f0 < f1");
159    }
160  0 else if (parity > 0)
161    {
162  0 Assert.assertTrue(comparison > 0, "These should be f0 > f1");
163    }
164    }
165   
 
166  0 toggle @DataProvider(name = "jarVersionComparisons")
167    public Object[][] jarVersionComparisons()
168    {
169  0 File f0 = new File(
170    "test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.4.3.jar");
171  0 File f1 = new File(
172    "test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.4.4.jar");
173  0 File f2 = new File(
174    "test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.3-1.5.0.jar");
175  0 File f3 = new File(
176    "test/jalview/util/fake-getdown-launchers/fake-getdown-launcher-1.8.4-1.5.0.jar");
177    /*
178    File f0, // a jar file (with getdown style Implementation-Version in the META-INF/MANIFEST.MF)
179    File f1, // a jar file (with getdown style Implementation-Version in the META-INF/MANIFEST.MF)
180    int comparison, // -1 if f0 < f1, 0 if f0 == f1, +1 if f0 > f1
181    */
182  0 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    }