maven-surefire git commit: [SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console
Repository: maven-surefire Updated Branches: refs/heads/master 2360dacc9 -> 572954801 [SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/57295480 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/57295480 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/57295480 Branch: refs/heads/master Commit: 572954801c0d192a68b42116f28a7dd4c4c20ba6 Parents: 2360dac Author: Tibor17 Authored: Mon Feb 13 18:20:26 2017 +0100 Committer: Tibor17 Committed: Mon Feb 13 18:20:26 2017 +0100 -- .../surefire/booterclient/ForkStarter.java | 13 ++- .../booterclient/output/ForkClient.java | 18 ++- .../output/InPluginProcessDumpSingleton.java| 65 +++ .../output/LostCommandsDumpSingleton.java | 1 - .../output/MultipleFailureException.java| 72 .../output/NativeStdErrStreamConsumer.java | 2 +- .../output/ThreadedStreamConsumer.java | 112 --- .../maven/surefire/booter/CommandReader.java| 26 ++--- .../surefire/booter/DumpErrorSingleton.java | 99 .../surefire/booter/ForkingRunListener.java | 13 +++ .../surefire/booter/MasterProcessCommand.java | 23 +--- .../maven/surefire/booter/ForkedBooter.java | 25 + ...urefire1295AttributeJvmCrashesToTestsIT.java | 6 +- .../jiras/Surefire141PluggableProvidersIT.java | 75 ++--- ...e735ForkFailWithRedirectConsoleOutputIT.java | 29 +++-- 15 files changed, 439 insertions(+), 140 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/57295480/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java -- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java index 05c4cc2..54d304a 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java @@ -28,6 +28,7 @@ import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStre import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream; import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream; import org.apache.maven.plugin.surefire.booterclient.output.ForkClient; +import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton; import org.apache.maven.plugin.surefire.booterclient.output.NativeStdErrStreamConsumer; import org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer; import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; @@ -158,7 +159,7 @@ public class ForkStarter /** * Closes stuff, with a shutdown hook to make sure things really get closed. */ -private static class CloseableCloser +private final class CloseableCloser implements Runnable, Closeable { private final Queue testProvidingInputStream; @@ -191,7 +192,15 @@ public class ForkStarter } catch ( IOException e ) { -// ignore +// This error does not fail a test and does not necessarily mean that the forked JVM std/out stream +// was not closed, see ThreadedStreamConsumer. This error means that JVM wrote messages to a native +// stream which could not be parsed or report failed. The tests may still correctly run nevertheless +// this exception happened => warning on console. The user would see hint to check dump file only +// if tests failed, but if this does not happen then printing warning to console is the only way to +// inform the users. +String msg = "ForkStarter IOException: " + e.getLocalizedMessage(); +log.warning( msg ); +InPluginProcessDumpSingleton.getSingleton().dumpException( e, msg, defaultReporterFactory ); } } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/57295480/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java -- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ou
[2/2] maven-surefire git commit: [SUREFIRE-1322] - Surefire and Failsafe should dump critical errors in dump file and console
[SUREFIRE-1322] - Surefire and Failsafe should dump critical errors in dump file and console Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/4d3673c4 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/4d3673c4 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/4d3673c4 Branch: refs/heads/master Commit: 4d3673c42e2af75c22f3abbaa2a0237a5c25e0ce Parents: b50ea3a Author: Tibor17 Authored: Sun Jan 8 00:22:48 2017 +0100 Committer: Tibor17 Committed: Sun Jan 8 00:22:48 2017 +0100 -- .../apache/maven/surefire/booter/CommandReader.java | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d3673c4/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java -- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java index 3990d46..3f24a1b 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java @@ -377,7 +377,7 @@ public final class CommandReader if ( command == null ) { String errorMessage = "[SUREFIRE] std/in stream corrupted: first sequence not recognized"; -DumpErrorSingleton.getSingleton().dumpText( errorMessage ); +DumpErrorSingleton.getSingleton().dumpStreamText( errorMessage ); logger.error( errorMessage ); break; } @@ -414,24 +414,27 @@ public final class CommandReader } catch ( EOFException e ) { -DumpErrorSingleton.getSingleton().dumpException( e ); - CommandReader.this.state.set( TERMINATED ); if ( !isTestSetFinished ) { +String msg = "TestSet has not finished before stream error has appeared >> " + + "initializing exit by non-null configuration: " + + CommandReader.this.shutdown; +DumpErrorSingleton.getSingleton().dumpStreamException( e, msg ); + exitByConfiguration(); // does not go to finally } } catch ( IOException e ) { -DumpErrorSingleton.getSingleton().dumpException( e ); - CommandReader.this.state.set( TERMINATED ); // If #stop() method is called, reader thread is interrupted and cause is InterruptedException. if ( !( e.getCause() instanceof InterruptedException ) ) { -logger.error( "[SUREFIRE] std/in stream corrupted", e ); +String msg = "[SUREFIRE] std/in stream corrupted"; +DumpErrorSingleton.getSingleton().dumpStreamException( e, msg ); +logger.error( msg, e ); } } finally
maven-surefire git commit: [SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console
Repository: maven-surefire Updated Branches: refs/heads/master 27fbe2c19 -> 66bc4c083 [SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/66bc4c08 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/66bc4c08 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/66bc4c08 Branch: refs/heads/master Commit: 66bc4c0839ba11af7a8915930f76abf3cd58ee53 Parents: 27fbe2c Author: Tibor17 Authored: Sat Dec 31 10:25:00 2016 +0100 Committer: Tibor17 Committed: Sat Dec 31 10:25:00 2016 +0100 -- .../surefire/util/internal/DumpFileUtils.java | 2 +- ...e735ForkFailWithRedirectConsoleOutputIT.java | 32 +--- 2 files changed, 28 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/66bc4c08/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java -- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java index 47a1386..2c110f5 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java @@ -1 +1 @@ -package org.apache.maven.surefire.util.internal; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.surefire.report.ReporterConfiguration; import java.io.File; import java.io.FileOutputStream; import java.io.IOE xception; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.text.SimpleDateFormat; import java.util.Date; /** * Dumps a text or exception in dump file. * Each call logs a date when it was written to the dump file. * * @author mailto:tibordig...@apache.org";>Tibor Digana (tibor17) * @since 2.19.2 */ public final class DumpFileUtils { private DumpFileUtils() { throw new IllegalStateException( "no instantiable constructor" ); } /** * New dump file. Synchronized object appears in main memory and perfectly visible in other threads. */ public static synchronized File newDumpFile( String dumpFileName, ReporterConfiguration configuration ) { return new File( configuration.getReportsDirectory(), dumpFileName ); } public static void dumpException( Throwable t, File dumpFile ) { dumpException( t, null, dumpFile ); } public static void dumpException ( Throwable t, String msg, File dumpFile ) { try { if ( t != null && dumpFile != null && ( dumpFile.exists() || dumpFile.createNewFile() ) ) { Writer fw = createWriter( dumpFile ); if ( msg != null ) { fw.append( msg ) .append( StringUtils.NL ); } PrintWriter pw = new PrintWriter( fw ); t.printStackTrace( pw ); pw.flush(); fw.append( StringUtils.NL ) .append( StringUtils.NL ); fw.flush(); fw.close(); } } catch ( Exception e ) { // do nothing } } public static void dumpText( String msg, File dumpFile ) { try { if ( msg != null && dumpFile != null && ( dumpFile.exists() || dumpFile.createNewFile() ) ) { Writer fw = createWriter( dumpFile ) .append( msg ) .append( StringUtils.NL ) .append( StringUtils.NL ); fw.flush(); fw.close(); } } catch ( Exception e ) { // do nothing }
maven-surefire git commit: [SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console
Repository: maven-surefire Updated Branches: refs/heads/master 9dd4074e8 -> df7e143c2 [SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/df7e143c Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/df7e143c Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/df7e143c Branch: refs/heads/master Commit: df7e143c26b09678a0e6885b7ffcc65070688eb9 Parents: 9dd4074 Author: Tibor17 Authored: Sat Dec 31 06:26:36 2016 +0100 Committer: Tibor17 Committed: Sat Dec 31 06:26:36 2016 +0100 -- .../maven/plugin/surefire/booterclient/ForkStarter.java | 9 ++--- .../plugin/surefire/booterclient/output/ForkClient.java | 3 --- .../booterclient/output/NativeStdErrStreamConsumer.java | 10 +- 3 files changed, 15 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e143c/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java -- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java index 2d0ae38..05c4cc2 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java @@ -603,10 +603,13 @@ public class ForkStarter SurefireBooterForkException booterForkException = null; try { +NativeStdErrStreamConsumer stdErrConsumer = +new NativeStdErrStreamConsumer( forkClient.getDefaultReporterFactory() ); + CommandLineCallable future = -executeCommandLineAsCallable( cli, testProvidingInputStream, threadedStreamConsumer, - new NativeStdErrStreamConsumer(), 0, closer, - Charset.forName( FORK_STREAM_CHARSET_NAME ) ); +executeCommandLineAsCallable( cli, testProvidingInputStream, threadedStreamConsumer, +stdErrConsumer, 0, closer, +Charset.forName( FORK_STREAM_CHARSET_NAME ) ); currentForkClients.add( forkClient ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e143c/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java -- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java index 46c747b..d0aecf9 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java @@ -272,19 +272,16 @@ public class ForkClient break; default: LostCommandsDumpSingleton.getSingleton().dumpText( s, defaultReporterFactory ); -log.warning( s ); } } catch ( NumberFormatException e ) { // SUREFIRE-859 -log.warning( s ); LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory ); } catch ( NoSuchElementException e ) { // SUREFIRE-859 -log.warning( s ); LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory ); } catch ( ReporterException e ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e143c/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NativeStdErrStreamConsumer.java -- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NativeStdErrStreamConsumer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NativeStdErrStreamConsumer.java index 84ca474..c92361d 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NativeStdErrStreamConsumer.java +++ b/maven-surefire-common/src/main/java/org/apache/ma
[9/9] maven-surefire git commit: [SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console
[SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/303cc8ac Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/303cc8ac Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/303cc8ac Branch: refs/heads/master Commit: 303cc8acdaf677bee9751da94de16e07083febb7 Parents: 9964119 Author: Tibor17 Authored: Mon Dec 26 16:26:18 2016 +0100 Committer: Tibor17 Committed: Mon Dec 26 16:26:18 2016 +0100 -- .../plugin/failsafe/IntegrationTestMojo.java| 47 ++--- .../maven/plugin/failsafe/VerifyMojo.java | 71 - .../plugin/failsafe/xmlsummary/ErrorType.java | 1 + .../failsafe/xmlsummary/FailsafeSummary.java| 1 + .../xmlsummary/FailsafeSummaryXmlUtils.java | 1 + .../maven/plugin/failsafe/xmlsummary/JAXB.java | 1 + .../failsafe/xmlsummary/ObjectFactory.java | 1 + .../failsafe/MarshallerUnmarshallerTest.java| 1 + .../maven/plugin/failsafe/RunResultTest.java| 1 + .../maven/plugin/failsafe/failsafe-summary.xml | 1 + .../maven/plugin/surefire/SurefireHelper.java | 25 +++-- .../surefire/booterclient/ForkStarter.java | 30 -- .../booterclient/output/ForkClient.java | 6 +- .../output/LostCommandsDumpSingleton.java | 1 + .../surefire/report/DefaultReporterFactory.java | 6 ++ .../src/site/apt/developing.apt.vm | 4 +- .../src/site/apt/examples/shutdown.apt.vm | 5 +- maven-surefire-plugin/src/site/apt/index.apt.vm | 9 +- maven-surefire-plugin/src/site/fml/faq.fml | 25 - .../src/site/resources/xsd/bindings.xml | 1 + .../src/site/resources/xsd/failsafe-summary.xsd | 1 + .../maven/surefire/booter/CommandReader.java| 18 +++- .../apache/maven/surefire/suite/RunResult.java | 101 ++- .../surefire/util/internal/DumpFileUtils.java | 1 + .../maven/surefire/suite/RunResultTest.java | 83 +-- .../maven/surefire/booter/ForkedBooter.java | 74 ++ .../surefire/its/CheckTestNgExecuteErrorIT.java | 28 - .../surefire/its/fixture/OutputValidator.java | 9 +- .../jiras/Surefire141PluggableProvidersIT.java | 35 +-- 29 files changed, 281 insertions(+), 307 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/303cc8ac/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java -- diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java index c0048d5..2d78109 100644 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java +++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java @@ -19,12 +19,6 @@ package org.apache.maven.plugin.failsafe; * under the License. */ -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.surefire.AbstractSurefireMojo; @@ -36,6 +30,16 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.shared.utils.StringUtils; import org.apache.maven.surefire.suite.RunResult; +import javax.xml.bind.JAXBException; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +import static org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummaryXmlUtils.writeSummary; import static org.apache.maven.shared.utils.ReaderFactory.FILE_ENCODING; /** @@ -46,9 +50,9 @@ import static org.apache.maven.shared.utils.ReaderFactory.FILE_ENCODING; * @noinspection JavaDoc, */ @Mojo( name = "integration-test", requiresProject = true, requiresDependencyResolution = ResolutionScope.TEST, - defaultPhase = LifecyclePhase.INTEGRATION_TEST, threadSafe = true ) + defaultPhase = LifecyclePhase.INTEGRATION_TEST, threadSafe = true ) public class IntegrationTestMojo -extends AbstractSurefireMojo +extends AbstractSurefireMojo { private static final String FAILSAFE_IN_PROGRESS_CONTEXT_KEY = "failsafe-in-progress"; @@ -235,7 +239,7 @@ public class IntegrationTestMojo * By default, Surefire forks your tests using a manifest-only JAR; set this parameter to "false" to force it to * laun
[8/9] maven-surefire git commit: [SUREFIRE-1322] Surefire and Failsafe should dump critical errors in dump file and console
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/303cc8ac/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java -- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java index a8466b2..1525e80 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java @@ -19,21 +19,7 @@ package org.apache.maven.surefire.suite; * under the License. */ -import org.apache.maven.shared.utils.StringUtils; -import org.apache.maven.shared.utils.io.IOUtil; -import org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter; -import org.apache.maven.shared.utils.xml.Xpp3Dom; -import org.apache.maven.shared.utils.xml.Xpp3DomBuilder; -import org.apache.maven.shared.utils.xml.Xpp3DomWriter; - -import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; import java.io.PrintWriter; /** @@ -79,8 +65,7 @@ public class RunResult private static RunResult errorCode( RunResult other, String failure, boolean timeout ) { return new RunResult( other.getCompletedCount(), other.getErrors(), other.getFailures(), other.getSkipped(), - failure, timeout ); - +failure, timeout ); } public RunResult( int completedCount, int errors, int failures, int skipped ) @@ -171,7 +156,12 @@ public class RunResult /* Indicates if the tests are error free */ public boolean isErrorFree() { -return getFailures() == 0 && getErrors() == 0; +return getFailures() == 0 && getErrors() == 0 && !isFailure(); +} + +public boolean isInternalError() +{ +return getFailures() == 0 && getErrors() == 0 && isFailure(); } /* Indicates test timeout or technical failure */ @@ -212,83 +202,6 @@ public class RunResult return new RunResult( 0, 0, 0, 0 ); } -private Xpp3Dom create( String node, String value ) -{ -Xpp3Dom dom = new Xpp3Dom( node ); -dom.setValue( value ); -return dom; -} - -private Xpp3Dom create( String node, int value ) -{ -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; -} - -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 ); -} - -public void writeSummary( File summaryFile, boolean inProgress, String encoding ) -throws IOException -{ -if ( !summaryFile.getParentFile().isDirectory() ) -{ -//noinspection ResultOfMethodCallIgnored -summaryFile.getParentFile().mkdirs(); -} - -FileInputStream fin = null; -FileWriter writer = null; -try -{ -RunResult mergedSummary = this; -if ( summaryFile.exists() && inProgress ) -{ -fin = new FileInputStream( summaryFile ); - -RunResult runResult = RunResult.fromInputStream( new BufferedInputStream( fin ), encoding ); -mergedSummary = mergedSummary.aggregate( runResult ); -} - -writer = new