You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by so...@apache.org on 2018/12/12 22:05:01 UTC
[maven-surefire] branch SUREFIRE-1614 created (now 938d422)
This is an automated email from the ASF dual-hosted git repository.
sor pushed a change to branch SUREFIRE-1614
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.
at 938d422 [SUREFIRE-1614] Fix corrupted stream warning
This branch includes the following new commits:
new de1c687 [SUREFIRE-1614] Add failing IT
new 938d422 [SUREFIRE-1614] Fix corrupted stream warning
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven-surefire] 01/02: [SUREFIRE-1614] Add failing IT
Posted by so...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sor pushed a commit to branch SUREFIRE-1614
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit de1c687f7e8280ce472ee07fd3673933120b954d
Author: Christian Stein <so...@gmail.com>
AuthorDate: Wed Dec 12 23:02:33 2018 +0100
[SUREFIRE-1614] Add failing IT
---
.../its/JUnitPlatformStreamCorruptionIT.java | 55 ++++++++++++++++++++++
.../surefire-1614-stream-corruption/pom.xml | 35 ++++++++++++++
.../test/java/com/example/demo/CustomRunner.java | 19 ++++++++
.../example/demo/SurefireStreamCorruptionTest.java | 13 +++++
4 files changed, 122 insertions(+)
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformStreamCorruptionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformStreamCorruptionIT.java
new file mode 100644
index 0000000..5820114
--- /dev/null
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformStreamCorruptionIT.java
@@ -0,0 +1,55 @@
+package org.apache.maven.surefire.its;
+
+/*
+ * 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.it.VerificationException;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
+import static org.fest.assertions.Assertions.assertThat;
+import static org.hamcrest.CoreMatchers.startsWith;
+
+public class JUnitPlatformStreamCorruptionIT
+ extends SurefireJUnit4IntegrationTestCase
+{
+ @Before
+ public void setUp()
+ {
+ assumeJavaVersion( 1.8d );
+ }
+
+ @Test
+ public void warningIsNotEmitted() throws VerificationException
+ {
+ OutputValidator validator = unpack( "/surefire-1614-stream-corruption" )
+ .executeTest()
+ .verifyErrorFree( 1 );
+
+ List<String> lines = validator.loadLogLines( startsWith( "[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM" ) );
+
+ assertThat( lines )
+ .hasSize( 0 );
+ }
+}
diff --git a/surefire-its/src/test/resources/surefire-1614-stream-corruption/pom.xml b/surefire-its/src/test/resources/surefire-1614-stream-corruption/pom.xml
new file mode 100644
index 0000000..adab6e7
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1614-stream-corruption/pom.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>junit-platform-1.0.0</artifactId>
+ <version>1.0</version>
+ <name>[SUREFIRE-1614] JUnit 5: Vintage Output Stream Corruption</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <version>5.3.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/surefire-its/src/test/resources/surefire-1614-stream-corruption/src/test/java/com/example/demo/CustomRunner.java b/surefire-its/src/test/resources/surefire-1614-stream-corruption/src/test/java/com/example/demo/CustomRunner.java
new file mode 100644
index 0000000..ea9340e
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1614-stream-corruption/src/test/java/com/example/demo/CustomRunner.java
@@ -0,0 +1,19 @@
+package com.example.demo;
+
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.TestClass;
+
+public class CustomRunner extends BlockJUnit4ClassRunner {
+
+ public CustomRunner(Class<?> klass) throws InitializationError {
+ super(klass);
+ }
+
+ @Override
+ protected TestClass createTestClass(Class<?> testClass) {
+ System.out.println("Creating test class");
+ return super.createTestClass(testClass);
+ }
+
+}
diff --git a/surefire-its/src/test/resources/surefire-1614-stream-corruption/src/test/java/com/example/demo/SurefireStreamCorruptionTest.java b/surefire-its/src/test/resources/surefire-1614-stream-corruption/src/test/java/com/example/demo/SurefireStreamCorruptionTest.java
new file mode 100644
index 0000000..ea82c83
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1614-stream-corruption/src/test/java/com/example/demo/SurefireStreamCorruptionTest.java
@@ -0,0 +1,13 @@
+package com.example.demo;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(CustomRunner.class)
+public class SurefireStreamCorruptionTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
[maven-surefire] 02/02: [SUREFIRE-1614] Fix corrupted stream warning
Posted by so...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sor pushed a commit to branch SUREFIRE-1614
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 938d422802e431682a866c90f7269ca2fa85f790
Author: Christian Stein <so...@gmail.com>
AuthorDate: Wed Dec 12 23:04:47 2018 +0100
[SUREFIRE-1614] Fix corrupted stream warning
---
.../junitplatform/JUnitPlatformProvider.java | 31 +++++++++-------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
index 177adef..868b369 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
@@ -104,22 +104,29 @@ public class JUnitPlatformProvider
public RunResult invoke( Object forkTestSet )
throws TestSetFailedException, ReporterException
{
+ ReporterFactory reporterFactory = parameters.getReporterFactory();
+ RunListener runListener = reporterFactory.createReporter();
+
+ ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) runListener );
+
if ( forkTestSet instanceof TestsToRun )
{
- return invokeAllTests( (TestsToRun) forkTestSet );
+ invokeAllTests( (TestsToRun) forkTestSet, runListener );
}
else if ( forkTestSet instanceof Class )
{
- return invokeAllTests( TestsToRun.fromClass( (Class<?>) forkTestSet ) );
+ invokeAllTests( TestsToRun.fromClass( (Class<?>) forkTestSet ), runListener );
}
else if ( forkTestSet == null )
{
- return invokeAllTests( scanClasspath() );
+ invokeAllTests( scanClasspath(), runListener );
}
else
{
throw new IllegalArgumentException( "Unexpected value of forkTestSet: " + forkTestSet );
}
+
+ return reporterFactory.close();
}
private TestsToRun scanClasspath()
@@ -130,22 +137,10 @@ public class JUnitPlatformProvider
return parameters.getRunOrderCalculator().orderTestClasses( scannedClasses );
}
- private RunResult invokeAllTests( TestsToRun testsToRun )
+ private void invokeAllTests( TestsToRun testsToRun, RunListener runListener )
{
- RunResult runResult;
- ReporterFactory reporterFactory = parameters.getReporterFactory();
- try
- {
- RunListener runListener = reporterFactory.createReporter();
- ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) runListener );
- LauncherDiscoveryRequest discoveryRequest = buildLauncherDiscoveryRequest( testsToRun );
- launcher.execute( discoveryRequest, new RunListenerAdapter( runListener ) );
- }
- finally
- {
- runResult = reporterFactory.close();
- }
- return runResult;
+ LauncherDiscoveryRequest discoveryRequest = buildLauncherDiscoveryRequest( testsToRun );
+ launcher.execute( discoveryRequest, new RunListenerAdapter( runListener ) );
}
private LauncherDiscoveryRequest buildLauncherDiscoveryRequest( TestsToRun testsToRun )