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 org.junit.Assert; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.extension.version.InvalidVersionRangeException; |
25 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (45) |
Complexity: 10 |
Complexity Density: 0.29 |
|
26 |
|
public class DefaultVersionRangeTest |
27 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
28 |
1 |
@Test... |
29 |
|
public void testIsCompatible() throws InvalidVersionRangeException |
30 |
|
{ |
31 |
|
|
32 |
1 |
Assert.assertTrue(new DefaultVersionRange("[1.0]").isCompatible(new DefaultVersionRange("[1.0]"))); |
33 |
1 |
Assert.assertTrue(new DefaultVersionRange("[1.0,2.0]").isCompatible(new DefaultVersionRange("[1.0]"))); |
34 |
1 |
Assert.assertTrue(new DefaultVersionRange("[1.0,2.0]").isCompatible(new DefaultVersionRange("[1.0,3.0]"))); |
35 |
1 |
Assert.assertTrue(new DefaultVersionRange("[1.0,2.0]").isCompatible(new DefaultVersionRange("[2.0,3.0]"))); |
36 |
1 |
Assert.assertTrue(new DefaultVersionRange("(,2.0]").isCompatible(new DefaultVersionRange("[2.0,)"))); |
37 |
1 |
Assert.assertTrue(new DefaultVersionRange("(,2.0]").isCompatible(new DefaultVersionRange("[1.0,)"))); |
38 |
1 |
Assert.assertTrue(new DefaultVersionRange("(,2.0)").isCompatible(new DefaultVersionRange("(1.0,)"))); |
39 |
|
|
40 |
|
|
41 |
1 |
Assert.assertFalse(new DefaultVersionRange("[1.0,2.0)").isCompatible(new DefaultVersionRange("(2.0,3.0]"))); |
42 |
1 |
Assert.assertFalse(new DefaultVersionRange("(,2.0)").isCompatible(new DefaultVersionRange("(2.0,)"))); |
43 |
1 |
Assert.assertFalse(new DefaultVersionRange("[1.0]").isCompatible(new DefaultVersionRange("[2.0]"))); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
46 |
1 |
@Test... |
47 |
|
public void testGetValue() |
48 |
|
{ |
49 |
1 |
Assert.assertEquals("[1.0,2.0]", new DefaultVersionRange(new DefaultVersion("1.0"), true, new DefaultVersion( |
50 |
|
"2.0"), true).getValue()); |
51 |
1 |
Assert.assertEquals("(1.0,2.0]", new DefaultVersionRange(new DefaultVersion("1.0"), false, new DefaultVersion( |
52 |
|
"2.0"), true).getValue()); |
53 |
1 |
Assert.assertEquals("[1.0,2.0)", new DefaultVersionRange(new DefaultVersion("1.0"), true, new DefaultVersion( |
54 |
|
"2.0"), false).getValue()); |
55 |
1 |
Assert.assertEquals("(1.0,2.0)", new DefaultVersionRange(new DefaultVersion("1.0"), false, new DefaultVersion( |
56 |
|
"2.0"), false).getValue()); |
57 |
|
|
58 |
1 |
Assert |
59 |
|
.assertEquals("(1.0,)", new DefaultVersionRange(new DefaultVersion("1.0"), false, null, false).getValue()); |
60 |
1 |
Assert.assertEquals("[1.0,)", new DefaultVersionRange(new DefaultVersion("1.0"), true, null, false).getValue()); |
61 |
1 |
Assert.assertEquals("(1.0,]", new DefaultVersionRange(new DefaultVersion("1.0"), false, null, true).getValue()); |
62 |
1 |
Assert.assertEquals("[1.0,]", new DefaultVersionRange(new DefaultVersion("1.0"), true, null, true).getValue()); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testToString() |
67 |
|
{ |
68 |
1 |
Assert.assertEquals("[1.0,2.0]", new DefaultVersionRange(new DefaultVersion("1.0"), true, new DefaultVersion( |
69 |
|
"2.0"), true).toString()); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
72 |
1 |
@Test... |
73 |
|
public void testHashCode() throws InvalidVersionRangeException |
74 |
|
{ |
75 |
1 |
Assert.assertEquals(new DefaultVersionRange("[1.0,2.0]").hashCode(), |
76 |
|
new DefaultVersionRange("[1.0,2.0]").hashCode()); |
77 |
1 |
Assert.assertEquals(new DefaultVersionRange("[1.0]").hashCode(), |
78 |
|
new DefaultVersionRange("[1.0,1.0]").hashCode()); |
79 |
|
|
80 |
1 |
Assert.assertNotEquals(new DefaultVersionRange("[1.0,2.0)").hashCode(), |
81 |
|
new DefaultVersionRange("[1.0.2.0]").hashCode()); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
84 |
1 |
@Test... |
85 |
|
public void testEquals() throws InvalidVersionRangeException |
86 |
|
{ |
87 |
1 |
Assert.assertEquals(new DefaultVersionRange("[1.0,2.0]"), new DefaultVersionRange("[1.0,2.0]")); |
88 |
1 |
Assert.assertEquals(new DefaultVersionRange("[1.0]"), new DefaultVersionRange("[1.0,1.0]")); |
89 |
|
|
90 |
1 |
Assert.assertNotEquals(new DefaultVersionRange("[1.0,2.0)"), new DefaultVersionRange("[1.0.2.0]")); |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
93 |
1 |
@Test... |
94 |
|
public void testContainsVersion() throws InvalidVersionRangeException |
95 |
|
{ |
96 |
1 |
Assert.assertTrue(new DefaultVersionRange("[1.0,2.0]").containsVersion(new DefaultVersion("1.0"))); |
97 |
1 |
Assert.assertTrue(new DefaultVersionRange("[1.0,2.0]").containsVersion(new DefaultVersion("2.0"))); |
98 |
|
|
99 |
1 |
Assert.assertFalse(new DefaultVersionRange("[2.0]").containsVersion(new DefaultVersion("1.0"))); |
100 |
1 |
Assert.assertFalse(new DefaultVersionRange("[2.0]").containsVersion(new DefaultVersion("3.0"))); |
101 |
1 |
Assert.assertFalse(new DefaultVersionRange("(1.0,2.0)").containsVersion(new DefaultVersion("1.0"))); |
102 |
1 |
Assert.assertFalse(new DefaultVersionRange("(1.0,2.0)").containsVersion(new DefaultVersion("2.0"))); |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
105 |
1 |
@Test(expected = InvalidVersionRangeException.class)... |
106 |
|
public void testInvalidVersionRangeWithSingleVersionWithLowerBoundInclusive() throws InvalidVersionRangeException |
107 |
|
{ |
108 |
1 |
new DefaultVersionRange("]1.0]"); |
109 |
|
} |
110 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
111 |
1 |
@Test(expected = InvalidVersionRangeException.class)... |
112 |
|
public void testInvalidVersionRangeWithSingleVersionWithUpperBoundInclusive() throws InvalidVersionRangeException |
113 |
|
{ |
114 |
1 |
new DefaultVersionRange("[1.0["); |
115 |
|
} |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
117 |
1 |
@Test(expected = InvalidVersionRangeException.class)... |
118 |
|
public void testInvalidVersionRangeWithRangeMoreThanTwoBound() throws InvalidVersionRangeException |
119 |
|
{ |
120 |
1 |
new DefaultVersionRange("[1.0,2.0,3.0]"); |
121 |
|
} |
122 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
123 |
1 |
@Test(expected = InvalidVersionRangeException.class)... |
124 |
|
public void testInvalidVersionRangeWithLowerBoundGreaterThanUpperBound() throws InvalidVersionRangeException |
125 |
|
{ |
126 |
1 |
new DefaultVersionRange("[2.0,1.0]"); |
127 |
|
} |
128 |
|
} |