GenericVersionRange implements VersionRange { @Override public String toString() { StringBuilder buffer = new StringBuilder( 64 ); buffer.append( lowerBoundInclusive ? '[' : '(' ); if ( lowerBound != null ) { buffer.append( lowerBound ); } buffer.append( ',' ); if ( upperBound != null ) { buffer.append( upperBound ); } buffer.append( upperBoundInclusive ? ']' : ')' ); return buffer.toString(); } GenericVersionRange( String range );  GenericVersionRange( Version lowerBound, boolean lowerBoundInclusive, Version upperBound,
                                boolean upperBoundInclusive ); Version getLowerBound(); boolean isLowerBoundInclusive(); Version getUpperBound(); boolean isUpperBoundInclusive(); boolean containsVersion( Version version ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override String toString();  }
@Test public void testLowerBoundInclusiveUpperBoundInclusive() { VersionRange range = parseValid( "[1,2]" ); assertContains( range, "1" ); assertContains( range, "1.1-SNAPSHOT" ); assertContains( range, "2" ); assertEquals( range, parseValid( range.toString() ) ); }
@Test public void testLowerBoundInclusiveUpperBoundExclusive() { VersionRange range = parseValid( "[1.2.3.4.5,1.2.3.4.6)" ); assertContains( range, "1.2.3.4.5" ); assertNotContains( range, "1.2.3.4.6" ); assertEquals( range, parseValid( range.toString() ) ); }
@Test public void testLowerBoundExclusiveUpperBoundInclusive() { VersionRange range = parseValid( "(1a,1b]" ); assertNotContains( range, "1a" ); assertContains( range, "1b" ); assertEquals( range, parseValid( range.toString() ) ); }
@Test public void testLowerBoundExclusiveUpperBoundExclusive() { VersionRange range = parseValid( "(1,3)" ); assertNotContains( range, "1" ); assertContains( range, "2-SNAPSHOT" ); assertNotContains( range, "3" ); assertEquals( range, parseValid( range.toString() ) ); }
@Test public void testSingleVersion() { VersionRange range = parseValid( "[1]" ); assertContains( range, "1" ); assertEquals( range, parseValid( range.toString() ) ); range = parseValid( "[1,1]" ); assertContains( range, "1" ); assertEquals( range, parseValid( range.toString() ) ); }