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

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


    }

    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


    {
        Xpp3Dom[] children = readTests( validator, className );

        Assert.assertEquals( 1, children.length );

        Xpp3Dom child = children[0];

        Assert.assertEquals( className, child.getAttribute( "classname" ) );
        Assert.assertEquals( className, child.getAttribute( "name" ) );

        Assert.assertEquals( "Expected error tag for failed BeforeClass method for " + className, 1,
                             child.getChildren( "error" ).length );

        Assert.assertTrue( "time for test failure in BeforeClass is expected to be positive",
                           Double.compare( Double.parseDouble( child.getAttribute( "time" ) ), 0.0d ) >= 0 );

        Assert.assertTrue( "time for test failure in BeforeClass is expected to be resonably low",
                           Double.compare( Double.parseDouble( child.getAttribute( "time" ) ), 2.0d ) <= 0 );

    }
View Full Code Here

    {
        Xpp3Dom[] children = readTests( validator, className );

        Assert.assertEquals( 1, children.length );

        Xpp3Dom child = children[0];

        Assert.assertEquals( className, child.getAttribute( "classname" ) );
        Assert.assertEquals( className, child.getAttribute( "name" ) );

        Assert.assertEquals( "Expected skipped tag for ignored method for " + className, 1,
                             child.getChildren( "skipped" ).length );

        Assert.assertTrue( "time for ignored test is expected to be zero",
                           Double.compare( Double.parseDouble( child.getAttribute( "time" ) ), 0.0d ) == 0 );
    }
View Full Code Here

    }

    private Xpp3Dom[] readTests( OutputValidator validator, String className )
        throws FileNotFoundException
    {
        Xpp3Dom testResult =
            Xpp3DomBuilder.build( validator.getSurefireReportsXmlFile( "TEST-" + className + ".xml" ).getFileInputStream(),
                                  "UTF-8" );
        Xpp3Dom[] children = testResult.getChildren( "testcase" );
        return children;
    }
View Full Code Here

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

        Xpp3Dom testSuite = Xpp3DomBuilder.build( new FileReader( expectedReportFile ) );
        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( "std-out!", tcb.getChild( "system-out" ).getValue() );
        assertEquals( "std-err?", tcb.getChild( "system-err" ).getValue() );

        expectedReportFile.delete();
    }
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.intValue() ) );
        }
        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

    }

    private void validate( OutputValidator validator, String className )
        throws FileNotFoundException
    {
        Xpp3Dom testResult =
            Xpp3DomBuilder.build( validator.getSurefireReportsFile( "TEST-" + className + ".xml" ).getFileInputStream(),
                                  "UTF-8" );
        Xpp3Dom[] children = testResult.getChildren( "testcase" );

        Assert.assertEquals( 2, children.length );

        for ( Xpp3Dom child : children )
        {
View Full Code Here

        StatelessXmlReporter reporter = new StatelessXmlReporter( new File( "." ), null, false, 0 );
        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( TEST_ONE, 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( TEST_TWO, 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

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.