1 package org.apache.maven.artifact.versioning;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.TestCase;
23
24 import java.util.List;
25
26 import org.apache.maven.artifact.Artifact;
27
28
29
30
31
32
33
34 public class VersionRangeTest
35 extends TestCase
36 {
37 private static final String CHECK_NUM_RESTRICTIONS = "check number of restrictions";
38
39 private static final String CHECK_UPPER_BOUND = "check upper bound";
40
41 private static final String CHECK_UPPER_BOUND_INCLUSIVE = "check upper bound is inclusive";
42
43 private static final String CHECK_LOWER_BOUND = "check lower bound";
44
45 private static final String CHECK_LOWER_BOUND_INCLUSIVE = "check lower bound is inclusive";
46
47 private static final String CHECK_VERSION_RECOMMENDATION = "check version recommended";
48
49 private static final String CHECK_SELECTED_VERSION_KNOWN = "check selected version known";
50
51 private static final String CHECK_SELECTED_VERSION = "check selected version";
52
53 public void testRange()
54 throws InvalidVersionSpecificationException, OverConstrainedVersionException
55 {
56 Artifact artifact = null;
57
58 VersionRange range = VersionRange.createFromVersionSpec( "(,1.0]" );
59 List restrictions = range.getRestrictions();
60 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
61 Restriction restriction = (Restriction) restrictions.get( 0 );
62 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
63 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
64 assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
65 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
66 assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
67 assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
68 assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
69
70 range = VersionRange.createFromVersionSpec( "1.0" );
71 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.0", range.getRecommendedVersion().toString() );
72 restrictions = range.getRestrictions();
73 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
74 restriction = (Restriction) restrictions.get( 0 );
75 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
76 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
77 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
78 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
79 assertTrue( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
80 assertEquals( CHECK_SELECTED_VERSION, "1.0", range.getSelectedVersion( artifact ).toString() );
81
82 range = VersionRange.createFromVersionSpec( "[1.0]" );
83 restrictions = range.getRestrictions();
84 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
85 restriction = (Restriction) restrictions.get( 0 );
86 assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() );
87 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
88 assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
89 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
90 assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
91 assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
92 assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
93
94 range = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
95 restrictions = range.getRestrictions();
96 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
97 restriction = (Restriction) restrictions.get( 0 );
98 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
99 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
100 assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
101 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
102 assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
103 assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
104 assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
105
106 range = VersionRange.createFromVersionSpec( "[1.0,2.0)" );
107 restrictions = range.getRestrictions();
108 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
109 restriction = (Restriction) restrictions.get( 0 );
110 assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() );
111 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
112 assertEquals( CHECK_UPPER_BOUND, "2.0", restriction.getUpperBound().toString() );
113 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
114 assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
115 assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
116 assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
117
118 range = VersionRange.createFromVersionSpec( "[1.5,)" );
119 restrictions = range.getRestrictions();
120 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
121 restriction = (Restriction) restrictions.get( 0 );
122 assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() );
123 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
124 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
125 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
126 assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
127 assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
128 assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
129
130 range = VersionRange.createFromVersionSpec( "(,1.0],[1.2,)" );
131 restrictions = range.getRestrictions();
132 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
133 restriction = (Restriction) restrictions.get( 0 );
134 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
135 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
136 assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
137 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
138 assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
139 restriction = (Restriction) restrictions.get( 1 );
140 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
141 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
142 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
143 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
144 assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
145 assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
146 assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
147 }
148
149 public void testInvalidRanges()
150 {
151 checkInvalidRange( "(1.0)" );
152 checkInvalidRange( "[1.0)" );
153 checkInvalidRange( "(1.0]" );
154 checkInvalidRange( "(1.0,1.0]" );
155 checkInvalidRange( "[1.0,1.0)" );
156 checkInvalidRange( "(1.0,1.0)" );
157 checkInvalidRange( "[1.1,1.0]" );
158 checkInvalidRange( "[1.0,1.2),1.3" );
159
160 checkInvalidRange( "[1.0,1.2),(1.1,1.3]" );
161
162 checkInvalidRange( "[1.1,1.3),(1.0,1.2]" );
163
164 checkInvalidRange( "(1.1,1.2],[1.0,1.1)" );
165 }
166
167 public void testIntersections()
168 throws InvalidVersionSpecificationException
169 {
170 VersionRange range1 = VersionRange.createFromVersionSpec( "1.0" );
171 VersionRange range2 = VersionRange.createFromVersionSpec( "1.1" );
172 VersionRange mergedRange = range1.restrict( range2 );
173
174
175 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.0", mergedRange.getRecommendedVersion().toString() );
176 List restrictions = mergedRange.getRestrictions();
177 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
178 Restriction restriction = (Restriction) restrictions.get( 0 );
179 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
180 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
181 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
182 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
183
184 mergedRange = range2.restrict( range1 );
185 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
186 restrictions = mergedRange.getRestrictions();
187 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
188 restriction = (Restriction) restrictions.get( 0 );
189 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
190 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
191 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
192 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
193
194
195 range1 = VersionRange.createFromVersionSpec( "[1.0,)" );
196 range2 = VersionRange.createFromVersionSpec( "1.1" );
197 mergedRange = range1.restrict( range2 );
198 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
199 restrictions = mergedRange.getRestrictions();
200 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
201 restriction = (Restriction) restrictions.get( 0 );
202 assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() );
203 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
204 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
205 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
206
207 range1 = VersionRange.createFromVersionSpec( "[1.1,)" );
208 range2 = VersionRange.createFromVersionSpec( "1.1" );
209 mergedRange = range1.restrict( range2 );
210 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
211 restrictions = mergedRange.getRestrictions();
212 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
213 restriction = (Restriction) restrictions.get( 0 );
214 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
215 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
216 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
217 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
218
219 range1 = VersionRange.createFromVersionSpec( "[1.1]" );
220 range2 = VersionRange.createFromVersionSpec( "1.1" );
221 mergedRange = range1.restrict( range2 );
222 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
223 restrictions = mergedRange.getRestrictions();
224 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
225 restriction = (Restriction) restrictions.get( 0 );
226 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
227 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
228 assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getLowerBound().toString() );
229 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
230
231 range1 = VersionRange.createFromVersionSpec( "(1.1,)" );
232 range2 = VersionRange.createFromVersionSpec( "1.1" );
233 mergedRange = range1.restrict( range2 );
234 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
235 restrictions = mergedRange.getRestrictions();
236 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
237 restriction = (Restriction) restrictions.get( 0 );
238 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
239 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
240 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
241 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
242
243 range1 = VersionRange.createFromVersionSpec( "[1.2,)" );
244 range2 = VersionRange.createFromVersionSpec( "1.1" );
245 mergedRange = range1.restrict( range2 );
246 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
247 restrictions = mergedRange.getRestrictions();
248 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
249 restriction = (Restriction) restrictions.get( 0 );
250 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
251 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
252 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
253 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
254
255 range1 = VersionRange.createFromVersionSpec( "(,1.2]" );
256 range2 = VersionRange.createFromVersionSpec( "1.1" );
257 mergedRange = range1.restrict( range2 );
258 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
259 restrictions = mergedRange.getRestrictions();
260 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
261 restriction = (Restriction) restrictions.get( 0 );
262 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
263 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
264 assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
265 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
266
267 range1 = VersionRange.createFromVersionSpec( "(,1.1]" );
268 range2 = VersionRange.createFromVersionSpec( "1.1" );
269 mergedRange = range1.restrict( range2 );
270 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
271 restrictions = mergedRange.getRestrictions();
272 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
273 restriction = (Restriction) restrictions.get( 0 );
274 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
275 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
276 assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
277 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
278
279 range1 = VersionRange.createFromVersionSpec( "(,1.1)" );
280 range2 = VersionRange.createFromVersionSpec( "1.1" );
281 mergedRange = range1.restrict( range2 );
282 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
283 restrictions = mergedRange.getRestrictions();
284 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
285 restriction = (Restriction) restrictions.get( 0 );
286 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
287 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
288 assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
289 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
290
291 range1 = VersionRange.createFromVersionSpec( "(,1.0]" );
292 range2 = VersionRange.createFromVersionSpec( "1.1" );
293 mergedRange = range1.restrict( range2 );
294 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
295 restrictions = mergedRange.getRestrictions();
296 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
297 restriction = (Restriction) restrictions.get( 0 );
298 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
299 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
300 assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
301 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
302
303 range1 = VersionRange.createFromVersionSpec( "(,1.0], [1.1,)" );
304 range2 = VersionRange.createFromVersionSpec( "1.2" );
305 mergedRange = range1.restrict( range2 );
306 assertEquals( CHECK_VERSION_RECOMMENDATION, "1.2", mergedRange.getRecommendedVersion().toString() );
307 restrictions = mergedRange.getRestrictions();
308 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
309 restriction = (Restriction) restrictions.get( 0 );
310 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
311 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
312 assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
313 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
314 restriction = (Restriction) restrictions.get( 1 );
315 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
316 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
317 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
318 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
319
320 range1 = VersionRange.createFromVersionSpec( "(,1.0], [1.1,)" );
321 range2 = VersionRange.createFromVersionSpec( "1.0.5" );
322 mergedRange = range1.restrict( range2 );
323 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
324 restrictions = mergedRange.getRestrictions();
325 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
326 restriction = (Restriction) restrictions.get( 0 );
327 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
328 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
329 assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
330 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
331 restriction = (Restriction) restrictions.get( 1 );
332 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
333 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
334 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
335 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
336
337 range1 = VersionRange.createFromVersionSpec( "(,1.1), (1.1,)" );
338 range2 = VersionRange.createFromVersionSpec( "1.1" );
339 mergedRange = range1.restrict( range2 );
340 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
341 restrictions = mergedRange.getRestrictions();
342 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
343 restriction = (Restriction) restrictions.get( 0 );
344 assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
345 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
346 assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
347 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
348 restriction = (Restriction) restrictions.get( 1 );
349 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
350 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
351 assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
352 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
353
354 range1 = VersionRange.createFromVersionSpec( "[1.1,1.3]" );
355 range2 = VersionRange.createFromVersionSpec( "(1.1,)" );
356 mergedRange = range1.restrict( range2 );
357 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
358 restrictions = mergedRange.getRestrictions();
359 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
360 restriction = (Restriction) restrictions.get( 0 );
361 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
362 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
363 assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
364 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
365
366 range1 = VersionRange.createFromVersionSpec( "(,1.3)" );
367 range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
368 mergedRange = range1.restrict( range2 );
369 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
370 restrictions = mergedRange.getRestrictions();
371 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
372 restriction = (Restriction) restrictions.get( 0 );
373 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
374 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
375 assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
376 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
377
378 range1 = VersionRange.createFromVersionSpec( "[1.1,1.3]" );
379 range2 = VersionRange.createFromVersionSpec( "[1.2,)" );
380 mergedRange = range1.restrict( range2 );
381 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
382 restrictions = mergedRange.getRestrictions();
383 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
384 restriction = (Restriction) restrictions.get( 0 );
385 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
386 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
387 assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
388 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
389
390 range1 = VersionRange.createFromVersionSpec( "(,1.3]" );
391 range2 = VersionRange.createFromVersionSpec( "[1.2,1.4]" );
392 mergedRange = range1.restrict( range2 );
393 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
394 restrictions = mergedRange.getRestrictions();
395 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
396 restriction = (Restriction) restrictions.get( 0 );
397 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
398 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
399 assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
400 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
401
402 range1 = VersionRange.createFromVersionSpec( "(1.2,1.3]" );
403 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
404 mergedRange = range1.restrict( range2 );
405 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
406 restrictions = mergedRange.getRestrictions();
407 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
408 restriction = (Restriction) restrictions.get( 0 );
409 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
410 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
411 assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
412 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
413
414 range1 = VersionRange.createFromVersionSpec( "(1.2,1.3)" );
415 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
416 mergedRange = range1.restrict( range2 );
417 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
418 restrictions = mergedRange.getRestrictions();
419 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
420 restriction = (Restriction) restrictions.get( 0 );
421 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
422 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
423 assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
424 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
425
426 range1 = VersionRange.createFromVersionSpec( "[1.2,1.3)" );
427 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
428 mergedRange = range1.restrict( range2 );
429 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
430 restrictions = mergedRange.getRestrictions();
431 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
432 restriction = (Restriction) restrictions.get( 0 );
433 assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
434 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
435 assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
436 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
437
438 range1 = VersionRange.createFromVersionSpec( "[1.0,1.1]" );
439 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
440 mergedRange = range1.restrict( range2 );
441 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
442 restrictions = mergedRange.getRestrictions();
443 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
444 restriction = (Restriction) restrictions.get( 0 );
445 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
446 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
447 assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
448 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
449
450 range1 = VersionRange.createFromVersionSpec( "[1.0,1.1)" );
451 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
452 mergedRange = range1.restrict( range2 );
453 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
454 restrictions = mergedRange.getRestrictions();
455 assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
456
457 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
458 range2 = VersionRange.createFromVersionSpec( "[1.1]" );
459 mergedRange = range1.restrict( range2 );
460 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
461 restrictions = mergedRange.getRestrictions();
462 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
463 restriction = (Restriction) restrictions.get( 0 );
464 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
465 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
466 assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
467 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
468
469 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
470 range2 = VersionRange.createFromVersionSpec( "[1.4]" );
471 mergedRange = range1.restrict( range2 );
472 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
473 restrictions = mergedRange.getRestrictions();
474 assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
475 restriction = (Restriction) restrictions.get( 0 );
476 assertEquals( CHECK_LOWER_BOUND, "1.4", restriction.getLowerBound().toString() );
477 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
478 assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
479 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
480
481 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
482 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
483 mergedRange = range1.restrict( range2 );
484 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
485 restrictions = mergedRange.getRestrictions();
486 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
487 restriction = (Restriction) restrictions.get( 0 );
488 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
489 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
490 assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
491 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
492 restriction = (Restriction) restrictions.get( 1 );
493 assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
494 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
495 assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
496 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
497
498 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" );
499 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
500 mergedRange = range1.restrict( range2 );
501 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
502 restrictions = mergedRange.getRestrictions();
503 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
504 restriction = (Restriction) restrictions.get( 0 );
505 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
506 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
507 assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
508 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
509 restriction = (Restriction) restrictions.get( 1 );
510 assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
511 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
512 assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
513 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
514
515 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
516 range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
517 mergedRange = range1.restrict( range2 );
518 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
519 restrictions = mergedRange.getRestrictions();
520 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
521 restriction = (Restriction) restrictions.get( 0 );
522 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
523 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
524 assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
525 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
526 restriction = (Restriction) restrictions.get( 1 );
527 assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
528 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
529 assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
530 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
531
532 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" );
533 range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
534 mergedRange = range1.restrict( range2 );
535 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
536 restrictions = mergedRange.getRestrictions();
537 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
538 restriction = (Restriction) restrictions.get( 0 );
539 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
540 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
541 assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
542 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
543 restriction = (Restriction) restrictions.get( 1 );
544 assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
545 assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
546 assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
547 assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
548
549 range1 = VersionRange.createFromVersionSpec( "(,1.1),(1.4,)" );
550 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
551 mergedRange = range1.restrict( range2 );
552 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
553 restrictions = mergedRange.getRestrictions();
554 assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
555
556 range1 = VersionRange.createFromVersionSpec( "(,1.1],[1.4,)" );
557 range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
558 mergedRange = range1.restrict( range2 );
559 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
560 restrictions = mergedRange.getRestrictions();
561 assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
562
563 range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" );
564 range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
565 mergedRange = range1.restrict( range2 );
566 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
567 restrictions = mergedRange.getRestrictions();
568 assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
569
570 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
571 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.6,]" );
572 mergedRange = range1.restrict( range2 );
573 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
574 restrictions = mergedRange.getRestrictions();
575 assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
576 restriction = (Restriction) restrictions.get( 0 );
577 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
578 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
579 assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
580 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
581 restriction = (Restriction) restrictions.get( 1 );
582 assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
583 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
584 assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
585 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
586
587 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
588 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,]" );
589 mergedRange = range1.restrict( range2 );
590 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
591 restrictions = mergedRange.getRestrictions();
592 assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() );
593 restriction = (Restriction) restrictions.get( 0 );
594 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
595 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
596 assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
597 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
598 restriction = (Restriction) restrictions.get( 1 );
599 assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
600 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
601 assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
602 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
603 restriction = (Restriction) restrictions.get( 2 );
604 assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() );
605 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
606 assertEquals( CHECK_UPPER_BOUND, "1.5", restriction.getUpperBound().toString() );
607 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
608
609 range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.7]" );
610 range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,1.6]" );
611 mergedRange = range1.restrict( range2 );
612 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
613 restrictions = mergedRange.getRestrictions();
614 assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() );
615 restriction = (Restriction) restrictions.get( 0 );
616 assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
617 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
618 assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
619 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
620 restriction = (Restriction) restrictions.get( 1 );
621 assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
622 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
623 assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
624 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
625 restriction = (Restriction) restrictions.get( 2 );
626 assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() );
627 assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
628 assertEquals( CHECK_UPPER_BOUND, "1.6", restriction.getUpperBound().toString() );
629 assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
630
631
632 range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" );
633 range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
634 range1 = range1.restrict( range2 );
635 mergedRange = range1.restrict( range2 );
636 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
637 restrictions = mergedRange.getRestrictions();
638 assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
639
640 range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" );
641 range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
642 range2 = range1.restrict( range2 );
643 mergedRange = range1.restrict( range2 );
644 assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
645 restrictions = mergedRange.getRestrictions();
646 assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
647 }
648
649 private void checkInvalidRange( String version )
650 {
651 try
652 {
653 VersionRange.createFromVersionSpec( version );
654 fail( "Version " + version + " should have failed to construct" );
655 }
656 catch ( InvalidVersionSpecificationException expected )
657 {
658
659 }
660 }
661 }