Repository: maven-surefire Updated Branches: refs/heads/master 8881fabb9 -> feda08851
[SUREFIRE] refactoring Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/0d22ea7f Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/0d22ea7f Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/0d22ea7f Branch: refs/heads/master Commit: 0d22ea7f3b8e1c5114de5351841010ab6e87506b Parents: 8881fab Author: Tibor17 <tibo...@lycos.com> Authored: Sun Sep 27 22:59:03 2015 +0200 Committer: Tibor17 <tibo...@lycos.com> Committed: Sun Sep 27 22:59:03 2015 +0200 ---------------------------------------------------------------------- .../report/StatelessXmlReporterTest.java | 53 +++++++++----------- .../src/test/java/jiras/surefire1098/ATest.java | 2 +- 2 files changed, 26 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0d22ea7f/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java index dad0ac2..bcb5d57 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java @@ -19,14 +19,12 @@ package org.apache.maven.plugin.surefire.report; * under the License. */ -import junit.framework.AssertionFailedError; import junit.framework.TestCase; import org.apache.maven.plugin.surefire.booterclient.output.DeserializedStacktraceWriter; import org.apache.maven.shared.utils.StringUtils; import org.apache.maven.shared.utils.xml.Xpp3Dom; import org.apache.maven.shared.utils.xml.Xpp3DomBuilder; -import org.apache.maven.surefire.report.LegacyPojoStackTraceWriter; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.report.StackTraceWriter; @@ -39,45 +37,45 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; @SuppressWarnings( "ResultOfMethodCallIgnored" ) public class StatelessXmlReporterTest extends TestCase { - - private StatelessXmlReporter reporter = new StatelessXmlReporter( new File( "." ), null, false, 0, - Collections.synchronizedMap( new HashMap<String, Map<String, List<WrappedReportEntry>>>() ) ); - - private ReportEntry reportEntry; - private TestSetStats stats; private TestSetStats rerunStats; private File expectedReportFile; + private File reportDir; + private final static String TEST_ONE = "aTestMethod"; private final static String TEST_TWO = "bTestMethod"; private final static String TEST_THREE = "cTestMethod"; + private static volatile int folderPostfix; + @Override protected void setUp() throws Exception { - super.setUp(); - reportEntry = new SimpleReportEntry( this.getClass().getName(), "StatelessXMLReporterTest", - new LegacyPojoStackTraceWriter( "", "", new AssertionFailedError() ), 17 ); stats = new TestSetStats( false, true ); rerunStats = new TestSetStats( false, true ); - reporter.cleanTestHistoryMap(); + + File basedir = new File( "." ); + File target = new File( basedir.getCanonicalFile(), "target" ); + target.mkdir(); + String reportRelDir = getClass().getSimpleName() + "-" + ++folderPostfix; + reportDir = new File( target, reportRelDir ); + reportDir.mkdir(); } @Override protected void tearDown() throws Exception { - super.tearDown(); - if ( expectedReportFile != null ) { expectedReportFile.delete(); @@ -86,15 +84,18 @@ public class StatelessXmlReporterTest public void testFileNameWithoutSuffix() { - File reportDir = new File( "." ); - String testName = "org.apache.maven.plugin.surefire.report.StatelessXMLReporterTest"; - reportEntry = new SimpleReportEntry( this.getClass().getName(), testName, 12 ); + StatelessXmlReporter reporter = + new StatelessXmlReporter( reportDir, null, false, 0, + new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>() ); + reporter.cleanTestHistoryMap(); + + ReportEntry reportEntry = new SimpleReportEntry( getClass().getName(), getClass().getName(), 12 ); WrappedReportEntry testSetReportEntry = new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null ); stats.testSucceeded( testSetReportEntry ); reporter.testSetCompleted( testSetReportEntry, stats ); - expectedReportFile = new File( reportDir, "TEST-" + testName + ".xml" ); + expectedReportFile = new File( reportDir, "TEST-" + getClass().getName() + ".xml" ); assertTrue( "Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist", expectedReportFile.exists() ); } @@ -103,9 +104,7 @@ public class StatelessXmlReporterTest public void testAllFieldsSerialized() throws IOException { - File reportDir = new File( "." ); - - reportEntry = new SimpleReportEntry( this.getClass().getName(), TEST_ONE, 12 ); + ReportEntry reportEntry = new SimpleReportEntry( getClass().getName(), TEST_ONE, 12 ); WrappedReportEntry testSetReportEntry = new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null ); expectedReportFile = new File( reportDir, "TEST-" + TEST_ONE + ".xml" ); @@ -139,7 +138,7 @@ public class StatelessXmlReporterTest ReportEntryType.ERROR, 13, stdOut, stdErr ); stats.testSucceeded( t2 ); - StatelessXmlReporter reporter = new StatelessXmlReporter( new File( "." ), null, false, 0, + StatelessXmlReporter reporter = new StatelessXmlReporter( reportDir, null, false, 0, Collections.synchronizedMap( new HashMap<String, Map<String, List<WrappedReportEntry>>>() ) ); reporter.testSetCompleted( testSetReportEntry, stats ); @@ -157,7 +156,7 @@ public class StatelessXmlReporterTest 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" ) ); + assertEquals( getClass().getName(), tca.getAttribute( "classname" ) ); Xpp3Dom tcb = testcase[1]; assertEquals( TEST_TWO, tcb.getAttribute( "name" ) ); @@ -176,8 +175,7 @@ public class StatelessXmlReporterTest public void testOutputRerunFlakyFailure() throws IOException { - File reportDir = new File( "." ); - reportEntry = new SimpleReportEntry( this.getClass().getName(), TEST_ONE, 12 ); + ReportEntry reportEntry = new SimpleReportEntry( getClass().getName(), TEST_ONE, 12 ); WrappedReportEntry testSetReportEntry = new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null ); @@ -220,8 +218,7 @@ public class StatelessXmlReporterTest rerunStats.testSucceeded( testThreeSecondRun ); StatelessXmlReporter reporter = - new StatelessXmlReporter( - new File( "." ), + new StatelessXmlReporter( reportDir, null, false, 1, @@ -246,7 +243,7 @@ public class StatelessXmlReporterTest Xpp3Dom testCaseOne = testcase[0]; assertEquals( TEST_ONE, testCaseOne.getAttribute( "name" ) ); assertEquals( "0.012", testCaseOne.getAttribute( "time" ) ); - assertEquals( this.getClass().getName(), testCaseOne.getAttribute( "classname" ) ); + assertEquals( getClass().getName(), testCaseOne.getAttribute( "classname" ) ); Xpp3Dom testCaseTwo = testcase[1]; assertEquals( TEST_TWO, testCaseTwo.getAttribute( "name" ) ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0d22ea7f/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/src/test/java/jiras/surefire1098/ATest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/src/test/java/jiras/surefire1098/ATest.java b/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/src/test/java/jiras/surefire1098/ATest.java index bcacf89..34bb895 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/src/test/java/jiras/surefire1098/ATest.java +++ b/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/src/test/java/jiras/surefire1098/ATest.java @@ -28,7 +28,7 @@ public final class ATest { @Test public void someMethod() throws InterruptedException { System.out.println(getClass() + " " + Thread.currentThread().getName()); - TimeUnit.SECONDS.sleep(1); + TimeUnit.MILLISECONDS.sleep(100); } }