Package org.apache.maven.shared.utils.xml

Examples of org.apache.maven.shared.utils.xml.Xpp3Dom


    }

    @Test
    public void combineAppend()
    {
        Xpp3Dom t1 = new Xpp3Dom( "root" );
        t1.setAttribute( Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND );
        t1.addChild( createElement( "sub", "s1Value" ) );

        Xpp3Dom t2 = new Xpp3Dom( "root" );
        t2.addChild( createElement( "sub", "s1Value" ) );

        Xpp3Dom result = mergeXpp3Dom( t1, t2 );

        assertEquals( 2, result.getChildren( "sub" ).length );
    }
View Full Code Here


    }

    @Test
    public void mergeOverride()
    {
        Xpp3Dom t1 = new Xpp3Dom( "root" );
        t1.setAttribute( Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND );
        t1.addChild( createElement( "sub", "s1Value" ) );

        Xpp3Dom t2 = new Xpp3Dom( "root" );
        t2.addChild( createElement( "sub", "s1Value" ) );

        Xpp3Dom result = mergeXpp3Dom( t1, t2, Boolean.TRUE );

        assertEquals( 1, result.getChildren( "sub" ).length );
    }
View Full Code Here

    @Test( expected = NullPointerException.class )
    public void nullValue()
    {
        //noinspection ConstantConditions
        new Xpp3Dom( "top" ).setAttribute( null, "value" );
    }
View Full Code Here

    @Test( expected = NullPointerException.class )
    public void nullAttribute()
    {
        //noinspection ConstantConditions
        new Xpp3Dom( "root" ).setAttribute( "attr", null );
    }
View Full Code Here


    @Test
    public void testEquals()
    {
        Xpp3Dom dom = new Xpp3Dom( "single" );
        dom.addChild( new Xpp3Dom( "kid" ) );

        Xpp3Dom other = new Xpp3Dom( "single" );
        other.addChild( new Xpp3Dom( "kid2" ) );

        assertEquals( dom, dom );
        //noinspection ObjectEqualsNull
        assertFalse( dom.equals( null ) );
        assertFalse( dom.equals( new Xpp3Dom( (String) null ) ) );
        assertFalse( dom.equals( other ) );
    }
View Full Code Here

    @Test
    public void dominantWinsCollections()
        throws XmlPullParserException
    {
        Xpp3Dom parent = build( "<root><entries><entry>uno</entry><entry>dos</entry></entries></root>" );
        Xpp3Dom dominant = build( "<root><entries><entry>tres</entry></entries></root>" );

        Xpp3Dom result = mergeXpp3Dom( dominant, parent );

        Xpp3Dom items = result.getChild( "entries" );
        assertEquals( 1, items.getChildCount() );

        assertElemEquals( "tres", items.getChild( 0 ) );
    }
View Full Code Here

    @Test
    public void combineChildrenAppendTest()
        throws XmlPullParserException
    {
        Xpp3Dom parent =
            build( "<root><entries><entry>uno</entry><entry>dos</entry><entry>tres</entry></entries></root>" );
        Xpp3Dom child = build( "<root><entries combine.children=\"append\"><entry>quatro</entry></entries></root>" );

        Xpp3Dom result = mergeXpp3Dom( child, parent );

        Xpp3Dom items = result.getChild( "entries" );
        assertEquals( 4, items.getChildCount() );

        Xpp3Dom[] item = items.getChildren();

        assertElemEquals( "uno", item[0] );
        assertElemEquals( "dos", item[1] );
        assertElemEquals( "tres", item[2] );
        assertElemEquals( "quatro", item[3] );
View Full Code Here

    @Test
    public void unchangedWithFirstOrLastEmpty()
        throws Exception
    {
        String configStr = "<root><entries><entry/><entry>test</entry><entry/></entries></root>";
        Xpp3Dom dominant = build( configStr );
        Xpp3Dom duplicatedDominant = build( configStr );
        validateEntries( dominant );
        Xpp3Dom result = mergeXpp3Dom( dominant, duplicatedDominant );
        validateEntries( result );
    }
View Full Code Here

        validateEntries( result );
    }

    private void validateEntries( Xpp3Dom result )
    {
        Xpp3Dom entries = result.getChild( "entries" );
        assertEquals( 3, entries.getChildCount() );
        assertXpp3Null( entries.getChild( 0 ) );
        assertEquals( "test", entries.getChild( 1 ).getValue() );
        assertXpp3Null( entries.getChild( 2 ) );
    }
View Full Code Here

        throws Exception
    {
        String dominant = "<root><baz>bazzy</baz></root>";
        String recessive = "<root><bar>barry</bar></root>";

        Xpp3Dom merged = mergeXpp3Dom( build( dominant ), build( recessive ) );

        assertEquals( 2, merged.getChildCount() );
        assertEquals( "bazzy", merged.getChild( "baz" ).getValue() );
        assertEquals( "barry", merged.getChild( "bar" ).getValue() );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.shared.utils.xml.Xpp3Dom

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.