[SUREFIRE-1461] UnicodeTestNamesIT should be able to run multiple times
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/2c5c5945 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/2c5c5945 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/2c5c5945 Branch: refs/heads/SUREFIRE-1455 Commit: 2c5c59452c4034bd06a6d7e0212a4f7ac0ee54d5 Parents: 7a33fd6 Author: Tibor17 <[email protected]> Authored: Thu Jan 4 01:06:04 2018 +0100 Committer: Tibor17 <[email protected]> Committed: Fri Jan 12 03:57:04 2018 +0100 ---------------------------------------------------------------------- .../maven/surefire/its/UnicodeTestNamesIT.java | 51 +++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2c5c5945/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java index 5470a3f..64db960 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java @@ -19,42 +19,57 @@ package org.apache.maven.surefire.its; * under the LicenseUni. */ -import java.io.File; import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; - -import org.junit.Assert; -import org.junit.Assume; import org.junit.Test; +import java.io.File; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeFalse; + /** * Verifies unicode filenames pass through correctly. - * <br> - * If the underlying file system turns out not to support unicode, we just fail an assumption.s */ public class UnicodeTestNamesIT - extends SurefireJUnit4IntegrationTestCase + extends SurefireJUnit4IntegrationTestCase { + private static final String TXT_REPORT = "junit.twoTestCases.\u800C\u7D22\u5176\u60C5Test.txt"; + private static final String XML_REPORT = "TEST-junit.twoTestCases.\u800C\u7D22\u5176\u60C5Test.xml"; + @Test public void checkFileNamesWithUnicode() { SurefireLauncher unpacked = unpack( "unicode-testnames" ); - File xxyz = new File( unpacked.getUnpackedAt(), "src/test/java/junit/twoTestCases/XXYZTest.java" ); + File basedir = unpacked.getUnpackedAt(); + + unpacked.execute( "clean" ); + + File xxyz = new File( basedir, "src/test/java/junit/twoTestCases/XXYZTest.java" ); + File dest = new File( basedir, "src/test/java/junit/twoTestCases/\u800C\u7D22\u5176\u60C5Test.java" ); + + //noinspection ResultOfMethodCallIgnored + dest.delete(); + assertTrue( xxyz.renameTo( dest ) ); + + assertTrue( dest.exists() ); + assumeFalse( new File( basedir, "src/test/java/junit/twoTestCases/????Test.java" ).exists() ); - File dest = new File( unpacked.getUnpackedAt(), - "src/test/java/junit/twoTestCases/\u800C\u7D22\u5176\u60C5Test.java" ); + OutputValidator outputValidator = + unpacked.executeTest() + .assertTestSuiteResults( 2, 0, 0, 0 ); - Assume.assumeTrue( xxyz.renameTo( dest ) ); - Assume.assumeTrue( dest.exists() ); - Assume.assumeTrue( - !new File( unpacked.getUnpackedAt(), "src/test/java/junit/twoTestCases/????Test.java" ).exists() ); + TestFile surefireReportFile = outputValidator.getSurefireReportsFile( TXT_REPORT ); + assertTrue( surefireReportFile.exists() ); + surefireReportFile.assertContainsText( "junit.twoTestCases.????Test" ); - OutputValidator outputValidator = unpacked.executeTest().assertTestSuiteResults( 2, 0, 0, 0 ); - TestFile surefireReportsFile = outputValidator.getSurefireReportsFile( "junit.twoTestCases.èç´¢å ¶æ Test.txt" ); - Assert.assertTrue( surefireReportsFile.exists() ); - //surefireReportsFile .assertContainsText( "junit.twoTestCases.\u800C\u7D22\u5176\u60C5Test.txt" ); + TestFile surefireXmlReportFile = outputValidator.getSurefireReportsXmlFile( XML_REPORT ); + assertTrue( surefireXmlReportFile.exists() ); + assertFalse( surefireXmlReportFile.readFileToString().isEmpty() ); + surefireXmlReportFile.assertContainsText( "junit.twoTestCases.\u800C\u7D22\u5176\u60C5Test" ); } }
