forked from apache/maven
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up code using the ComparableVersion class
prevents warnings in IDE about raw types.
- Loading branch information
1 parent
343ba68
commit 62e840f
Showing
1 changed file
with
9 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,10 @@ | |
* | ||
* @author <a href="mailto:[email protected]">Hervé Boutemy</a> | ||
*/ | ||
@SuppressWarnings( "unchecked" ) | ||
public class ComparableVersionTest | ||
extends TestCase | ||
{ | ||
private Comparable newComparable( String version ) | ||
private ComparableVersion newComparable( String version ) | ||
{ | ||
ComparableVersion ret = new ComparableVersion( version ); | ||
String canonical = ret.getCanonical(); | ||
|
@@ -56,18 +55,18 @@ private Comparable newComparable( String version ) | |
|
||
private void checkVersionsOrder( String[] versions ) | ||
{ | ||
Comparable[] c = new Comparable[versions.length]; | ||
ComparableVersion[] c = new ComparableVersion[versions.length]; | ||
for ( int i = 0; i < versions.length; i++ ) | ||
{ | ||
c[i] = newComparable( versions[i] ); | ||
} | ||
|
||
for ( int i = 1; i < versions.length; i++ ) | ||
{ | ||
Comparable low = c[i - 1]; | ||
ComparableVersion low = c[i - 1]; | ||
for ( int j = i; j < versions.length; j++ ) | ||
{ | ||
Comparable high = c[j]; | ||
ComparableVersion high = c[j]; | ||
assertTrue( "expected " + low + " < " + high, low.compareTo( high ) < 0 ); | ||
assertTrue( "expected " + high + " > " + low, high.compareTo( low ) > 0 ); | ||
} | ||
|
@@ -76,8 +75,8 @@ private void checkVersionsOrder( String[] versions ) | |
|
||
private void checkVersionsEqual( String v1, String v2 ) | ||
{ | ||
Comparable c1 = newComparable( v1 ); | ||
Comparable c2 = newComparable( v2 ); | ||
ComparableVersion c1 = newComparable( v1 ); | ||
ComparableVersion c2 = newComparable( v2 ); | ||
assertTrue( "expected " + v1 + " == " + v2, c1.compareTo( c2 ) == 0 ); | ||
assertTrue( "expected " + v2 + " == " + v1, c2.compareTo( c1 ) == 0 ); | ||
assertTrue( "expected same hashcode for " + v1 + " and " + v2, c1.hashCode() == c2.hashCode() ); | ||
|
@@ -87,8 +86,8 @@ private void checkVersionsEqual( String v1, String v2 ) | |
|
||
private void checkVersionsOrder( String v1, String v2 ) | ||
{ | ||
Comparable c1 = newComparable( v1 ); | ||
Comparable c2 = newComparable( v2 ); | ||
ComparableVersion c1 = newComparable( v1 ); | ||
ComparableVersion c2 = newComparable( v2 ); | ||
assertTrue( "expected " + v1 + " < " + v2, c1.compareTo( c2 ) < 0 ); | ||
assertTrue( "expected " + v2 + " > " + v1, c2.compareTo( c1 ) > 0 ); | ||
} | ||
|
@@ -224,7 +223,7 @@ public void testReuse() | |
ComparableVersion c1 = new ComparableVersion( "1" ); | ||
c1.parseVersion( "2" ); | ||
|
||
Comparable c2 = newComparable( "2" ); | ||
ComparableVersion c2 = newComparable( "2" ); | ||
|
||
assertEquals( "reused instance should be equivalent to new instance", c1, c2 ); | ||
} | ||
|