Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 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.950819795.1%
 

Contributing tests

This file is covered by 29 tests. .

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  9 toggle @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   
 
30  1 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  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   
 
57  14 toggle @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   
 
77  1 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  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   
 
109  4 toggle @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   
 
118  1 toggle @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    File f0, // a jar file
131    String version, // the Implementation-Version found in the jar's META-INF/MANIFEST.MF
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   
 
147  12 toggle @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   
 
166  1 toggle @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    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  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    }