Package org.apache.avalon.framework

Examples of org.apache.avalon.framework.Version


        super( name );
    }

    public void testValidVersionString()
    {
        final Version v1 = Version.getVersion( "1" );
        assertTrue( new Version( 1, 0, 0 ).equals( v1 ) );

        final Version v2 = Version.getVersion( "0.3" );
        assertTrue( new Version( 0, 3, 0 ).equals( v2 ) );

        final Version v3 = Version.getVersion( "78.10.03" );
        assertTrue( new Version( 78, 10, 3 ).equals( v3 ) );


        try
        {
            final Version v4 = Version.getVersion( null );

            fail( "Expected an exception!" );
        }
        catch( NullPointerException th )
        {}
View Full Code Here


        }
    }

    public void testComplies()
    {
        final Version v0 = new Version( -1, 0 , 0 );
        final Version v1 = new Version( 1, 3 , 6 );
        final Version v2 = new Version( 1, 3 , 7 );
        final Version v3 = new Version( 1, 4 , 0 );
        final Version v4 = new Version( 2, 0 , 1 );

        assertTrue(   v1.complies( v0 ) );
        assertTrue(   v4.complies( v0 ) );
        assertTrue( ! v0.complies( v1 ) );
        assertTrue( ! v0.complies( v4 ) );
       
        assertTrue(   v1.complies( v1 ) );
        assertTrue( ! v1.complies( v2 ) );
        assertTrue(   v2.complies( v1 ) );
        assertTrue( ! v1.complies( v3 ) );
        assertTrue(   v3.complies( v1 ) );
        assertTrue( ! v1.complies( v4 ) );
        assertTrue( ! v4.complies( v1 ) );

        assertTrue( ! v4.complies( null ) );
    }
View Full Code Here

        assertTrue( ! v4.complies( null ) );
    }
   
    public void testHashCode()
    {
        final Version v1 = new Version( 5, 1, 0 );
        final Version v2 = new Version( 1, 0, 3 );
        final Version v3 = new Version( 1, 0, 3 );
       
        assertEquals( calculateHash(v1), v1.hashCode() );
        assertEquals( calculateHash(v2), v2.hashCode() );
       
        assertTrue( v1.hashCode() != v2.hashCode() );
        assertTrue( ! v1.equals(v2) );
       
        assertEquals( v2.hashCode(), v3.hashCode() );
        assertEquals( v2, v3 );
    }
View Full Code Here

        assertEquals( v2, v3 );
    }
   
    public void testComparable()
    {
        final Version v1 = new Version( 1, 0, 0 );
        final Version v2 = new Version( 2, 0, 0 );
        final Version v3 = new Version( 2, 1, 0 );
        final Version v4 = new Version( 2, 1, 1 );
        final Version v5 = new Version( 1, 0, 0 );
       
        assertEquals( 0, v1.compareTo(v5) );
        assertEquals( 0, v5.compareTo(v1) );
       
        assertEquals( -1, v1.compareTo(v2) );
        assertEquals( 1, v2.compareTo(v1) );
       
        assertEquals( -1, v2.compareTo(v3) );
View Full Code Here

        {}
    }

    public void testEquals()
    {
        assertFalse( new Version( 1, 0, 0 ).equals( this ) );
        assertFalse( new Version( 1, 0, 0 ).equals( null ) );
    }
View Full Code Here

        assertFalse( new Version( 1, 0, 0 ).equals( null ) );
    }

    public void testToString()
    {
        assertEquals( "1.0.0", new Version( 1, 0, 0 ).toString() );
        assertEquals( "230.21.-123456", new Version( 230, 21, -123456 ).toString() );
    }
View Full Code Here

    private DependencyDescriptor getDependency( DocletTag tag )
    {
        final String value = getNamedParameter( tag, TYPE_PARAM );
        final String type = resolveType( value );
        final String versionString = getNamedParameter( tag, VERSION_PARAM, null );
        final Version version = resolveVersion( versionString, value );
        final String key = getNamedParameter( tag, KEY_PARAM, type );
        final String optional = getNamedParameter( tag, OPTIONAL_PARAM, "false" );
        final boolean isOptional = "true".equals( optional.toLowerCase() );
        final ReferenceDescriptor ref = new ReferenceDescriptor( type, version );
        return new DependencyDescriptor( key, ref, isOptional, null );
View Full Code Here

    {
        final String name =
          info.getChild( "name" ).getValue( null );
        final String schema =
          info.getChild( "schema-type" ).getValue( null );
        final Version version =
          buildVersion( info.getChild( "version" ).getValue( "1.0" ) );
        final Properties attributes =
            buildAttributes( info.getChild( "attributes" ) );
        final String lifestyle = InfoDescriptor.SINGLETON;
        return new InfoDescriptor(
View Full Code Here

    {
        try
        {
            final String type = service.getAttribute( "name" );
            final String versionString = service.getAttribute( "version", "1.0" );
            final Version version = buildVersion( versionString );
            return new ReferenceDescriptor( type, version );
        }
        catch( Throwable e )
        {
            final String error =
View Full Code Here

        final DocletTag tag = getJavaClass().getTagByName( getNS() + Tags.DELIMITER + KEY );
        if( null == tag )
        {
            return null;
        }
        final Version version = Version.getVersion( getNamedParameter( tag, VERSION_PARAM, "" ) );
        final String type = getJavaClass().getFullyQualifiedName();
        final Properties properties = new AttributeTag( getJavaClass() ).getProperties();
        final ReferenceDescriptor ref = new ReferenceDescriptor( type, version );
        return new Service( ref, properties );
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.Version

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.