Package org.codehaus.dna.impl

Examples of org.codehaus.dna.impl.DefaultConfiguration


    }

    public void testGetMalformedAttributeAsLong()
        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','1')",
                      1,
                      configuration.getAttributeAsLong( key, 1 ) );

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


    }

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

    }

    public void testGetMissingAttributeAsFloat()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final String key = "key";
        assertTrue( "getAttribute('key','defaultValue')",
                    1.0 == configuration.getAttributeAsFloat( key, 1 ) );

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

    }

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

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

    }

    public void testGetAttributes()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        configuration.setAttribute( "key1", "value1" );
        configuration.setAttribute( "key2", "value2" );

        final String[] names = configuration.getAttributeNames();
        assertEquals( "names.length", 2, names.length );
    }
View Full Code Here

    }

    public void testGetAttributesWithNoAttributesSet()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );

        final String[] names = configuration.getAttributeNames();
        assertEquals( "names.length", 0, names.length );
    }
View Full Code Here

    }

    public void testGetChildren()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final DefaultConfiguration child =
            new DefaultConfiguration( "mychild", "file.xml:20", "/myElement" );

        configuration.addChild( child );

        final Configuration[] children = configuration.getChildren();
        assertEquals( "children.length", 1, children.length );
View Full Code Here

    }

    public void testGetChildrenWithNoChildren()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );

        final Configuration[] children = configuration.getChildren();
        assertEquals( "children.length", 0, children.length );
    }
View Full Code Here

    }

    public void testGetChild()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        final DefaultConfiguration child =
            new DefaultConfiguration( "mychild", "file.xml:20", "/myElement" );
        configuration.addChild( child );

        final Configuration test = configuration.getChild( "mychild" );
        assertEquals( child, test );
    }
View Full Code Here

    }

    public void testGetNotExistentChildWithNoAutoCreateButOtherChildren()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );

        final DefaultConfiguration child =
            new DefaultConfiguration( "meep", "file.xml:20", "/myElement" );
        configuration.addChild( child );

        final Configuration test = configuration.getChild( "mychild", false );
        assertEquals( null, test );
    }
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.