Package org.codehaus.dna.impl

Examples of org.codehaus.dna.impl.DefaultConfiguration


    }

    public void testGetMalformedValueAsFloat()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        configuration.setValue( "malformed" );
        assertTrue( "getValue('1')", 1.0 == configuration.getValueAsFloat( 1 ) );
        try
        {
            configuration.getValueAsFloat();
        }
        catch( ConfigurationException e )
        {
            return;
        }
View Full Code Here


    }

    public void testGetAttributeAsText()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        final String value = "value";
        configuration.setAttribute( key, value );
        assertEquals( "getAttribute('key')",
                      value,
                      configuration.getAttribute( key ) );
        assertEquals( "getAttribute('key','defaultValue')",
                      value,
                      configuration.getAttribute( key, "defaultValue" ) );
    }
View Full Code Here

    }

    public void testGetMissingAttributeAsText()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        configuration.setAttribute( "AnotherKey", "someValue" );
        assertEquals( "getAttribute('key','defaultValue')",
                      "defaultValue",
                      configuration.getAttribute( key, "defaultValue" ) );

        try
        {
            configuration.getAttribute( key );
        }
        catch( ConfigurationException e )
        {
            return;
        }
View Full Code Here

    }

    public void testGetAttributeAsBoolean()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        final String value = "true";
        configuration.setAttribute( key, value );
        assertEquals( "getAttribute('key')",
                      true,
                      configuration.getAttributeAsBoolean( key ) );
        assertEquals( "getAttribute('key','false')",
                      true,
                      configuration.getAttributeAsBoolean( key, false ) );
    }
View Full Code Here

    }

    public void testGetMissingAttributeAsBoolean()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        assertEquals( "getAttribute('key','false')",
                      false,
                      configuration.getAttributeAsBoolean( key, false ) );
        try
        {
            configuration.getAttribute( key );
        }
        catch( ConfigurationException e )
        {
            return;
        }
View Full Code Here

    }

    public void testGetAttributeAsInteger()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        final String value = "3";
        configuration.setAttribute( key, value );
        assertEquals( "getAttribute('key')",
                      3,
                      configuration.getAttributeAsInteger( key ) );
        assertEquals( "getAttribute('key','1')",
                      3,
                      configuration.getAttributeAsInteger( key, 1 ) );
    }
View Full Code Here

    }

    public void testGetMissingAttributeAsInteger()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        assertEquals( "getAttribute('key','defaultValue')",
                      1,
                      configuration.getAttributeAsInteger( key, 1 ) );

        try
        {
            configuration.getAttributeAsInteger( key );
        }
        catch( ConfigurationException e )
        {
            return;
        }
View Full Code Here

    }

    public void testGetMalformedAttributeAsInteger()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        final String value = "malformed";
        configuration.setAttribute( key, value );
        assertEquals( "getAttribute('key','defaultValue')",
                      1,
                      configuration.getAttributeAsInteger( key, 1 ) );

        try
        {
            configuration.getAttributeAsInteger( key );
        }
        catch( ConfigurationException e )
        {
            return;
        }
View Full Code Here

    }

    public void testGetAttributeAsLong()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        final String value = "3";
        configuration.setAttribute( key, value );
        assertEquals( "getAttribute('key')",
                      3,
                      configuration.getAttributeAsLong( key ) );
        assertEquals( "getAttribute('key','1')",
                      3,
                      configuration.getAttributeAsLong( key, 1 ) );
    }
View Full Code Here

    }

    public void testGetMissingAttributeAsLong()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        assertEquals( "getAttribute('key','1')",
                      1,
                      configuration.getAttributeAsLong( key, 1 ) );

        try
        {
            configuration.getAttributeAsLong( key );
        }
        catch( ConfigurationException e )
        {
            return;
        }
View Full Code Here

TOP

Related Classes of org.codehaus.dna.impl.DefaultConfiguration

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.