You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2019/01/22 06:02:31 UTC
[maven-surefire] branch SUREFIRE-1534 updated: IT
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch SUREFIRE-1534
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/SUREFIRE-1534 by this push:
new de61fc8 IT
de61fc8 is described below
commit de61fc854b266e685116f5cb924bb9eb81f0e533
Author: tibordigana <ti...@apache.org>
AuthorDate: Tue Jan 22 07:02:21 2019 +0100
IT
---
surefire-its/pom.xml | 2 +-
...urefire1534ReuseForksFalseWithJavaModuleIT.java | 79 ++++++++++++++++++++++
.../pom.xml | 62 +++++++++++++++++
.../src/main/java/it/Main.java | 17 +++++
.../src/main/java/module-info.java | 4 ++
.../src/test/java/it/MainTest.java | 29 ++++++++
.../surefire/junitplatform/RunListenerAdapter.java | 15 +++-
7 files changed, 204 insertions(+), 4 deletions(-)
diff --git a/surefire-its/pom.xml b/surefire-its/pom.xml
index 0cea53e..f67838f 100644
--- a/surefire-its/pom.xml
+++ b/surefire-its/pom.xml
@@ -169,7 +169,7 @@
<forkMode>once</forkMode>
<argLine>-server -Xmx64m -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
<includes>
- <include>org/apache/**/*IT*.java</include>
+ <include>org/apache/**/Surefire1534ReuseForksFalseWithJavaModuleIT.java</include>
</includes>
<!-- Pass current surefire version to the main suite so that it -->
<!-- can forward to all integration test projects. SUREFIRE-513 -->
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1534ReuseForksFalseWithJavaModuleIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1534ReuseForksFalseWithJavaModuleIT.java
new file mode 100644
index 0000000..5773026
--- /dev/null
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1534ReuseForksFalseWithJavaModuleIT.java
@@ -0,0 +1,79 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.its.AbstractJigsawIT;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.TestFile;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertTrue;
+
+public class Surefire1534ReuseForksFalseWithJavaModuleIT
+ extends AbstractJigsawIT
+{
+
+ @Test
+ public void testExecuteWithReuseForksFalseWithJavaModule()
+ throws IOException
+ {
+ OutputValidator validator = assumeJigsaw()
+ .reuseForks( false )
+ .forkCount( 1 )
+ .executeTest();
+
+ validator.assertTestSuiteResults( 2, 0, 0, 0 );
+ validator.verifyErrorFreeLog();
+
+ TestFile report = validator.getSurefireReportsFile( "TEST-MainTest.xml", UTF_8 );
+ assertTrue( report.exists() );
+ report.assertContainsText( "<property name=\"reuseForks\" value=\"false\"/>" )
+ .assertContainsText( "<property name=\"forkCount\" value=\"1\"/>" )
+ .assertContainsText( "<testcase name=\"test1\"" )
+ .assertContainsText( "<testcase name=\"test2\"" );
+ }
+
+ @Test
+ public void testExecuteWithZeroForkCountWithJavaModule()
+ throws IOException
+ {
+ OutputValidator validator = assumeJigsaw()
+ .forkCount( 0 )
+ .executeTest();
+
+ validator.assertTestSuiteResults( 2, 0, 0, 0 );
+ validator.verifyErrorFreeLog();
+
+ TestFile report = validator.getSurefireReportsFile( "TEST-MainTest.xml", UTF_8 );
+ assertTrue( report.exists() );
+ report.assertContainsText( "<property name=\"forkCount\" value=\"1\"/>" )
+ .assertContainsText( "<testcase name=\"test1\"" )
+ .assertContainsText( "<testcase name=\"test2\"" );
+ }
+
+ @Override
+ protected String getProjectDirectoryName()
+ {
+ return "surefire-1534-reuse-forks-false-java-module";
+ }
+}
diff --git a/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/pom.xml b/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/pom.xml
new file mode 100644
index 0000000..0b0ce25
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.example</groupId>
+ <artifactId>surefire-1534</artifactId>
+ <version>1.0</version>
+
+ <properties>
+ <maven.compiler.source>9</maven.compiler.source>
+ <maven.compiler.target>9</maven.compiler.target>
+ <junit.version>5.3.2</junit.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <version>${junit.version}</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>
\ No newline at end of file
diff --git a/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/main/java/it/Main.java b/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/main/java/it/Main.java
new file mode 100644
index 0000000..86491ff
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/main/java/it/Main.java
@@ -0,0 +1,17 @@
+package it;
+
+public class Main
+{
+ private String id;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+}
diff --git a/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/main/java/module-info.java b/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/main/java/module-info.java
new file mode 100644
index 0000000..3df6ca9
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/main/java/module-info.java
@@ -0,0 +1,4 @@
+module it
+{
+ exports it;
+}
diff --git a/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/test/java/it/MainTest.java b/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/test/java/it/MainTest.java
new file mode 100644
index 0000000..fbc0e07
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1534-reuse-forks-false-java-module/src/test/java/it/MainTest.java
@@ -0,0 +1,29 @@
+package it;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class MainTest
+{
+
+ // The intent is to run these two tests in different JVMs
+
+ @Test
+ public void test1()
+ {
+ Main main = new Main();
+ main.setId( "test1" );
+ assertEquals( "test1", main.getId() );
+ }
+
+ @Test
+ public void test2()
+ {
+ Main main = new Main();
+ main.setId( "test2" );
+ assertEquals( "test2", main.getId() );
+ }
+
+}
+
diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
index 85227f3..71c8bc0 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
@@ -19,10 +19,13 @@ package org.apache.maven.surefire.junitplatform;
* under the License.
*/
+import static java.util.Collections.emptyMap;
import static org.apache.maven.surefire.report.SimpleReportEntry.ignored;
+import static org.apache.maven.surefire.util.internal.ObjectUtils.systemProps;
import static org.junit.platform.engine.TestExecutionResult.Status.ABORTED;
import static org.junit.platform.engine.TestExecutionResult.Status.FAILED;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -165,7 +168,7 @@ final class RunListenerAdapter
private void completeTestSet( TestIdentifier testIdentifier )
{
- runListener.testSetCompleted( createTestSetReportEntry( testIdentifier ) );
+ runListener.testSetCompleted( createTestSetReportEntry( testIdentifier, systemProps() ) );
testSetNodes.remove( testIdentifier );
}
@@ -185,8 +188,14 @@ final class RunListenerAdapter
private SimpleReportEntry createTestSetReportEntry( TestIdentifier testIdentifier )
{
- return new SimpleReportEntry(
- JUnitPlatformProvider.class.getName(), testIdentifier.getLegacyReportingName() );
+ return createTestSetReportEntry( testIdentifier, emptyMap() );
+ }
+
+ private SimpleReportEntry createTestSetReportEntry( TestIdentifier testIdentifier,
+ Map<String, String> systemProperties )
+ {
+ return new SimpleReportEntry( JUnitPlatformProvider.class.getName(),
+ testIdentifier.getLegacyReportingName(), systemProperties );
}
private SimpleReportEntry createReportEntry( TestIdentifier testIdentifier )