1 51 package org.apache.avalon.framework.test; 52 53 import junit.framework.TestCase; 54 import org.apache.avalon.framework.Version; 55 56 61 public class VersionTestCase 62 extends TestCase 63 { 64 public VersionTestCase( final String name ) 65 { 66 super( name ); 67 } 68 69 public void testValidVersionString() 70 { 71 final Version v1 = Version.getVersion( "1" ); 72 assertTrue( new Version( 1, 0, 0 ).equals( v1 ) ); 73 74 final Version v2 = Version.getVersion( "0.3" ); 75 assertTrue( new Version( 0, 3, 0 ).equals( v2 ) ); 76 77 final Version v3 = Version.getVersion( "78.10.03" ); 78 assertTrue( new Version( 78, 10, 3 ).equals( v3 ) ); 79 } 80 81 public void testInvalidVersionString() 82 { 83 try 84 { 85 Version.getVersion( "" ); 86 fail( "Empty string is illegal version string" ); 87 } 88 catch ( final IllegalArgumentException iae ) 89 { 90 } 92 93 try 94 { 95 Version.getVersion( "1.F" ); 96 Version.getVersion( "1.0-dev" ); 97 fail( "Version string do contains only '.' and number" ); 98 } 99 catch ( final NumberFormatException nfe ) 100 { 101 } 103 } 104 105 public void testComplies() 106 { 107 final Version v1 = new Version( 1, 3 , 6 ); 108 final Version v2 = new Version( 1, 3 , 7 ); 109 final Version v3 = new Version( 1, 4 , 0 ); 110 final Version v4 = new Version( 2, 0 , 1 ); 111 112 assertTrue( v1.complies( v1 ) ); 113 assertTrue( ! v1.complies( v2 ) ); 114 assertTrue( v2.complies( v1 ) ); 115 assertTrue( ! v1.complies( v3 ) ); 116 assertTrue( v3.complies( v1 ) ); 117 assertTrue( ! v1.complies( v4 ) ); 118 assertTrue( ! v4.complies( v1 ) ); 119 } 120 } 121 | Popular Tags |