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

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


        StatelessXmlReporter reporter = new StatelessXmlReporter( new File( "." ), null, false );
        reporter.testSetCompleted( testSetReportEntry, stats );

        FileInputStream fileInputStream = new FileInputStream( expectedReportFile );

        Xpp3Dom testSuite = Xpp3DomBuilder.build( new InputStreamReader( fileInputStream, "UTF-8") );
        assertEquals( "testsuite", testSuite.getName() );
        Xpp3Dom properties = testSuite.getChild( "properties" );
        assertEquals( System.getProperties().size(), properties.getChildCount() );
        Xpp3Dom child = properties.getChild( 1 );
        assertFalse( StringUtils.isEmpty( child.getAttribute( "value" ) ) );
        assertFalse( StringUtils.isEmpty( child.getAttribute( "name" ) ) );

        Xpp3Dom[] testcase = testSuite.getChildren( "testcase" );
        Xpp3Dom tca = testcase[0];
        assertEquals( testName, tca.getAttribute( "name" ) ); // Hopefully same order on jdk5
        assertEquals( "0.012", tca.getAttribute( "time" ) );
        assertEquals( this.getClass().getName(), tca.getAttribute( "classname" ) );

        Xpp3Dom tcb = testcase[1];
        assertEquals( testName2, tcb.getAttribute( "name" ) );
        assertEquals( "0.013", tcb.getAttribute( "time" ) );
        assertEquals( Inner.class.getName(), tcb.getAttribute( "classname" ) );
        Xpp3Dom errorNode = tcb.getChild( "error" );
        assertNotNull( errorNode );
        assertEquals( "A fud msg", errorNode.getAttribute( "message" ) );
        assertEquals( "fail at foo", errorNode.getAttribute( "type" ) );
        assertEquals( stdOutPrefix + "<null>! &amp#0;&amp#31;", tcb.getChild( "system-out" ).getValue() );


        assertEquals( stdErrPrefix + "?&-&amp;&#163; &amp#0;&amp#31;", tcb.getChild( "system-err" ).getValue() );
    }
View Full Code Here


        return new RunResult( 0, 0, 0, 0 );
    }

    private Xpp3Dom create( String node, String value )
    {
        Xpp3Dom dom = new Xpp3Dom( node );
        dom.setValue( value );
        return dom;
    }
View Full Code Here

        return create( node, Integer.toString( value ) );
    }

    Xpp3Dom asXpp3Dom()
    {
        Xpp3Dom dom = new Xpp3Dom( "failsafe-summary" );
        Integer failsafeCode = getFailsafeCode();
        if ( failsafeCode != null )
        {
            dom.setAttribute( "result", Integer.toString( failsafeCode ) );
        }
        dom.setAttribute( "timeout", Boolean.toString( this.timeout ) );
        dom.addChild( create( "completed", this.completedCount ) );
        dom.addChild( create( "errors", this.errors ) );
        dom.addChild( create( "failures", this.failures ) );
        dom.addChild( create( "skipped", this.skipped ) );
        dom.addChild( create( "failureMessage", this.failure ) );
        return dom;
    }
View Full Code Here

    }

    public static RunResult fromInputStream( InputStream inputStream, String encoding )
        throws FileNotFoundException
    {
        Xpp3Dom dom = Xpp3DomBuilder.build( inputStream, encoding );
        boolean timeout = Boolean.parseBoolean( dom.getAttribute( "timeout" ) );
        int completed = Integer.parseInt( dom.getChild( "completed" ).getValue() );
        int errors = Integer.parseInt( dom.getChild( "errors" ).getValue() );
        int failures = Integer.parseInt( dom.getChild( "failures" ).getValue() );
        int skipped = Integer.parseInt( dom.getChild( "skipped" ).getValue() );
        String failureMessage1 = dom.getChild( "failureMessage" ).getValue();
        String failureMessage = StringUtils.isEmpty( failureMessage1 ) ? null : failureMessage1;
        return new RunResult( completed, errors, failures, skipped, failureMessage, timeout );
    }
View Full Code Here

public class Xpp3DomTest
{

    private Xpp3Dom createElement( String element, String value )
    {
        Xpp3Dom t1s1 = new Xpp3Dom( element );
        t1s1.setValue( value );
        return t1s1;
    }
View Full Code Here

    @Test
    public void mergePrecedenceSelfClosed()
        throws XmlPullParserException, IOException
    {
        Xpp3Dom parentConfig = build( "<configuration><items><item/></items></configuration>" );
        Xpp3Dom childConfig = build( "<configuration><items><item>ooopise</item></items></configuration>" );

        Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( childConfig, parentConfig );
        Xpp3Dom items = result.getChild( "items" );

        assertEquals( 1, items.getChildCount() );
        Xpp3Dom item = items.getChild( 0 );
        assertEquals( "ooopise", item.getValue() );
    }
View Full Code Here

    @Test
    public void mergePrecedenceOpenClose()
        throws XmlPullParserException, IOException
    {
        Xpp3Dom parentConfig = build( "<configuration><items><item></item></items></configuration>" );
        Xpp3Dom childConfig = build( "<configuration><items><item>ooopise</item></items></configuration>" );

        Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( childConfig, parentConfig );
        Xpp3Dom items = result.getChild( "items" );

        assertEquals( 1, items.getChildCount() );
        Xpp3Dom item = items.getChild( 0 );
        assertEquals( "ooopise", item.getValue() );
    }
View Full Code Here

    public void selfOverrideOnRootNode()
    {
        // Todo: This does not work when loaded. Probably a bug related to null vs "" handling
        //      Xpp3Dom t1 = build( "<top combine.self='override' attr='value'></top>" );

        Xpp3Dom t1 = new Xpp3Dom( "top" );
        t1.setAttribute( "attr", "value" );

        t1.setAttribute( Xpp3Dom.SELF_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.SELF_COMBINATION_OVERRIDE );

        Xpp3Dom t2 = build( "<top attr2='value2'>val2</top>" );
        Xpp3Dom result = mergeXpp3Dom( t1, t2 );

        assertEquals( 2, result.getAttributeNames().length );
        assertNull( result.getValue() );
    }
View Full Code Here

    }

    @Test
    public void mergeValuesOnRootNode()
    {
        Xpp3Dom t1 = build( "<root attr='value'/>" );
        Xpp3Dom t2 = build( "<root attr2='value2'>t2Val</root>" );
        Xpp3Dom result = mergeXpp3Dom( t1, t2 );
        assertEquals( 2, result.getAttributeNames().length );
        assertEquals( result.getValue(), t2.getValue() );
    }
View Full Code Here

    }

    @Test
    public void mergeAttributesOnRootNode()
    {
        Xpp3Dom t1 = build( "<root combine.self='merge' attr='value'/>" );
        Xpp3Dom t2 = build( "<root attr2='value2'/>" );

        Xpp3Dom dom = mergeXpp3Dom( t1, t2 );
        assertEquals( 3, dom.getAttributeNames().length );
    }
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.