1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.version.internal; |
21 |
|
|
22 |
|
import java.io.ByteArrayInputStream; |
23 |
|
import java.io.ByteArrayOutputStream; |
24 |
|
import java.io.IOException; |
25 |
|
import java.io.ObjectInputStream; |
26 |
|
import java.io.ObjectOutputStream; |
27 |
|
|
28 |
|
import org.junit.Assert; |
29 |
|
import org.junit.Test; |
30 |
|
import org.xwiki.extension.version.Version; |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 5 |
Complexity Density: 0.23 |
|
32 |
|
public class DefaultVersionTest |
33 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
34 |
2 |
private void validateSerialize(Version version) throws IOException, ClassNotFoundException... |
35 |
|
{ |
36 |
2 |
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
37 |
2 |
ObjectOutputStream out = new ObjectOutputStream(outputStream); |
38 |
2 |
out.writeObject(version); |
39 |
2 |
out.close(); |
40 |
2 |
outputStream.close(); |
41 |
|
|
42 |
2 |
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); |
43 |
2 |
ObjectInputStream in = new ObjectInputStream(inputStream); |
44 |
2 |
Assert.assertEquals(version, in.readObject()); |
45 |
2 |
in.close(); |
46 |
2 |
inputStream.close(); |
47 |
|
} |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
49 |
1 |
@Test... |
50 |
|
public void testCompareTo() |
51 |
|
{ |
52 |
1 |
Assert.assertTrue(new DefaultVersion("1.1").compareTo(new DefaultVersion("1.1")) == 0); |
53 |
1 |
Assert.assertTrue(new DefaultVersion("1.2").compareTo(new DefaultVersion("1.1")) > 0); |
54 |
1 |
Assert.assertTrue(new DefaultVersion("1.1").compareTo(new DefaultVersion("1.2")) < 0); |
55 |
|
|
56 |
1 |
Assert.assertTrue(new DefaultVersion("1.1").compareTo(new DefaultVersion("1.1w")) < 0); |
57 |
|
|
58 |
1 |
Assert.assertTrue(new DefaultVersion("1.1").compareTo(new DefaultVersion("1.1-milestone-1")) > 0); |
59 |
1 |
Assert.assertTrue(new DefaultVersion("1.1.1").compareTo(new DefaultVersion("1.1-milestone-1")) > 0); |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
62 |
1 |
@Test... |
63 |
|
public void testType() |
64 |
|
{ |
65 |
1 |
Assert.assertEquals(Version.Type.SNAPSHOT, new DefaultVersion("1.1-SNAPSHOT").getType()); |
66 |
1 |
Assert.assertEquals(Version.Type.BETA, new DefaultVersion("1.1-milestone-1").getType()); |
67 |
1 |
Assert.assertEquals(Version.Type.STABLE, new DefaultVersion("1.1").getType()); |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
70 |
1 |
@Test... |
71 |
|
public void testSerialize() throws IOException, ClassNotFoundException |
72 |
|
{ |
73 |
1 |
validateSerialize(new DefaultVersion("1.1")); |
74 |
1 |
validateSerialize(new DefaultVersion("1.1-milestone-1")); |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
77 |
1 |
@Test... |
78 |
|
public void testBigInteger() |
79 |
|
{ |
80 |
1 |
new DefaultVersion("1.2147483648").getType(); |
81 |
|
} |
82 |
|
} |