Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SUREFIRE-2062] Remove code corresponding to jdk 7 from IT tests #515

Merged
merged 1 commit into from Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -52,11 +52,11 @@ Build the Surefire project using **Maven 3.2.5+** and **JDK 1.8+**.

On Linux/Unix:
```
export MAVEN_OPTS="-server -Xmx512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true -Dhttps.protocols=TLSv1.2"
export MAVEN_OPTS="-server -Xmx512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true"
```
On Windows:
```
set MAVEN_OPTS="-server -Xmx256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true -Dhttps.protocols=TLSv1.2"
set MAVEN_OPTS="-server -Xmx256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true"
```

* In order to build and run the tests:
Expand Down
Expand Up @@ -20,23 +20,14 @@
*/

import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Before;
import org.junit.Test;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;

/**
*/
@SuppressWarnings( "checkstyle:magicnumber" )
public class CheckTestNg740ParallelIT
extends SurefireJUnit4IntegrationTestCase
{
@Before
public void assumeJava8Plus()
{
assumeJavaVersion( 1.8d );
}

@Test
public void withTestNG740AndParallelSet()
{
Expand Down
Expand Up @@ -29,7 +29,6 @@
import org.junit.runners.Parameterized;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaMaxVersion;
import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
import static org.junit.runners.Parameterized.Parameter;
import static org.junit.runners.Parameterized.Parameters;

Expand All @@ -49,10 +48,10 @@ public static Collection<Object[]> data()
{
return Arrays.asList( new Object[][]
{
{ "5.6", "jdk15", 1.5d }, // First TestNG version with reporter support
{ "5.7", "jdk15", 1.5d }, // default version from pom of the test case
{ "5.10", "jdk15", 1.5d },
{ "5.13", null, 1.5d }, // "reporterslist" param becomes String instead of List<ReporterConfig>
{ "5.6", "jdk15" }, // First TestNG version with reporter support
{ "5.7", "jdk15" }, // default version from pom of the test case
{ "5.10", "jdk15" },
{ "5.13", null }, // "reporterslist" param becomes String instead of List<ReporterConfig>
// "listener" param becomes String instead of List<Class>

// configure(Map) in 5.14.1 and 5.14.2 is transforming List<Class> into a String with a space as separator.
Expand All @@ -71,11 +70,11 @@ public static Collection<Object[]> data()
//{ "5.14.4", null, "1.5" }, { "5.14.5", null, "1.5" }, // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI
// ClassNotFoundException: com.beust.jcommander.ParameterException

{ "5.14.6", null, 1.5d }, // Usage of org.testng:guice removed
{ "5.14.9", null, 1.5d }, // Latest 5.14.x TestNG version
{ "6.0", null, 1.5d },
{ "6.14.3", null, 1.7d },
{ "7.0.0", null, 1.8d } // Currently latest TestNG version
{ "5.14.6", null }, // Usage of org.testng:guice removed
{ "5.14.9", null }, // Latest 5.14.x TestNG version
{ "6.0", null },
{ "6.14.3", null },
{ "7.0.0", null } // Currently latest TestNG version
} );
}

Expand All @@ -87,15 +86,9 @@ public static Collection<Object[]> data()
@SuppressWarnings( "checkstyle:visibilitymodifier" )
public String classifier;

@Parameter( 2 )
@SuppressWarnings( "checkstyle:visibilitymodifier" )
public double javaVersion;

@Test
public void testNgListenerReporter()
{
assumeJavaVersion( javaVersion );

if ( version.equals( "5.13" ) )
{
// only 5.13 uses Google Guice, reflection which breaks jdk 16+
Expand Down
Expand Up @@ -23,14 +23,12 @@

import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;

Expand All @@ -51,12 +49,6 @@ public class JUnit47RerunFailingTestWithCucumberIT extends SurefireJUnit4Integra
private static final String SUREFIRE_FORK_NODE =
"org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory";

@Before
public void assumeJava8Plus()
{
assumeJavaVersion( 1.8d );
}

@Parameters
public static Iterable<Object[]> data()
{
Expand Down
Expand Up @@ -20,11 +20,8 @@
*/

import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Before;
import org.junit.Test;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;

/**
* Tests the JUnit 47 provider with the cucumber runner. At the moment, they don't play along that perfectly (minor
* glitches in the reports with parallel=classes), but at least all tests are executed, the execution times are counted
Expand All @@ -37,12 +34,6 @@
public class JUnit47WithCucumberIT
extends SurefireJUnit4IntegrationTestCase
{
@Before
public void assumeJava8Plus()
{
assumeJavaVersion( 1.8d );
}

@Test
public void testWithoutParallel()
{
Expand Down
Expand Up @@ -25,15 +25,13 @@
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 org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
import static org.apache.maven.surefire.its.fixture.IsRegex.regex;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.util.Sets.set;
Expand Down Expand Up @@ -87,12 +85,6 @@ public static Iterable<Object[]> artifactVersions()
return args;
}

@Before
public void setUp()
{
assumeJavaVersion( 1.8d );
}

@Test
public void testToRegex()
{
Expand Down
Expand Up @@ -23,15 +23,13 @@

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 org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;

/**
*
Expand Down Expand Up @@ -62,12 +60,6 @@ public static Iterable<Object[]> artifactVersions()
return args;
}

@Before
public void setUp()
{
assumeJavaVersion( 1.8d );
}

@Test
public void testVintageEngine()
{
Expand Down
Expand Up @@ -22,11 +22,8 @@
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.junit.Before;
import org.junit.Test;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;

/**
* JUnit4 RunListener Integration Test.
*
Expand All @@ -43,12 +40,6 @@ private SurefireLauncher unpack()
return unpack( "/junit-platform-rerun-failing-tests" );
}

@Before
public void setup()
{
assumeJavaVersion( 1.8 );
}

@Test
public void testRerunFailingErrorTestsWithOneRetry()
{
Expand Down
Expand Up @@ -22,13 +22,11 @@
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.Ignore;
import org.junit.Test;

import java.util.List;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.startsWith;

Expand All @@ -39,12 +37,6 @@
public class JUnitPlatformStreamCorruptionIT
extends SurefireJUnit4IntegrationTestCase
{
@Before
public void setUp()
{
assumeJavaVersion( 1.8d );
}

@Test
public void warningIsNotEmitted() throws VerificationException
{
Expand Down
Expand Up @@ -27,8 +27,6 @@
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;

/**
* Verifies the runOrder setting and its effect
*
Expand Down Expand Up @@ -56,7 +54,6 @@ public void testAlphabeticalJUnit4()
public void testAlphabeticalJUnit5()
throws Exception
{
assumeJavaVersion( 1.8d );
OutputValidator validator = executeWithRunOrder( "alphabetical", "junit5" );
assertTestnamesAppearInSpecificOrder( validator, TESTS_IN_ALPHABETICAL_ORDER );
}
Expand Down Expand Up @@ -110,7 +107,6 @@ public void testReverseAlphabeticalJUnit4()
public void testReverseAlphabeticalJUnit5()
throws Exception
{
assumeJavaVersion( 1.8d );
OutputValidator validator = executeWithRunOrder( "reversealphabetical", "junit5" );
assertTestnamesAppearInSpecificOrder( validator, TESTS_IN_REVERSE_ALPHABETICAL_ORDER );
}
Expand All @@ -136,7 +132,6 @@ public void testHourlyJUnit4()
public void testHourlyJUnit5()
throws Exception
{
assumeJavaVersion( 1.8d );
int startHour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
OutputValidator validator = executeWithRunOrder( "hourly", "junit5" );
int endHour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
Expand Down Expand Up @@ -166,7 +161,6 @@ public void testNonExistingRunOrderJUnit4()
@Test
public void testNonExistingRunOrderJUnit5()
{
assumeJavaVersion( 1.8d );
unpack()
.activateProfile( "junit5" )
.forkMode( getForkMode() )
Expand Down
Expand Up @@ -19,9 +19,6 @@
* under the License.
*/

import java.io.File;
import java.io.IOException;

import static java.lang.Double.parseDouble;

/**
Expand All @@ -38,8 +35,6 @@ public abstract class SurefireJUnit4IntegrationTestCase
{
private static final int JAVA9_VERSION = 9;

public static final File JAVA_HOME = javaHome();

public static final double JAVA_VERSION = javaVersion();

public static final boolean IS_JAVA9_PLUS = isJDK9Plus();
Expand Down Expand Up @@ -72,7 +67,7 @@ public static SurefireLauncher unpack( Class<?> testClass, String sourceName, St
private static SurefireLauncher unpack( Class<?> testClass, String sourceName, String suffix, String[] cli )
{
MavenLauncher mavenLauncher = new MavenLauncher( testClass, sourceName, suffix, cli );
return new SurefireLauncher( mavenLauncher, JAVA_HOME );
return new SurefireLauncher( mavenLauncher );
}

private static double javaVersion()
Expand All @@ -84,32 +79,4 @@ private static boolean isJDK9Plus()
{
return javaVersion() >= JAVA9_VERSION;
}

private static File javaHome()
{
String javaHome = System.getProperty( "java.home" );
if ( !isJDK9Plus() )
{
File jre = new File( javaHome );
if ( "jre".equals( jre.getName() ) )
{
javaHome = jre.getParent();
}
}

try
{
File javaHomeAsDir = new File( javaHome ).getCanonicalFile();
if ( !javaHomeAsDir.isDirectory() )
{
throw new RuntimeException( javaHomeAsDir.getAbsolutePath() + " is not a JAVA_HOME directory." );
}
System.out.println( "Using JAVA_HOME=" + javaHomeAsDir.getAbsolutePath() + " in forked launcher." );
return javaHomeAsDir;
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
}
}
Expand Up @@ -39,13 +39,9 @@ public final class SurefireLauncher

private final String surefireVersion = System.getProperty( "surefire.version" );

private final File javaHome;

public SurefireLauncher( MavenLauncher mavenLauncher, File javaHome )
public SurefireLauncher( MavenLauncher mavenLauncher )
{
this.mavenLauncher = mavenLauncher;
this.javaHome = javaHome;
mavenLauncher.addEnvVar( "JAVA_HOME", javaHome.getAbsolutePath() );
reset();
}

Expand All @@ -70,7 +66,7 @@ public void reset()

public SurefireLauncher getSubProjectLauncher( String subProject )
{
return new SurefireLauncher( mavenLauncher.getSubProjectLauncher( subProject ), javaHome );
return new SurefireLauncher( mavenLauncher.getSubProjectLauncher( subProject ) );
}

public OutputValidator getSubProjectValidator( String subProject )
Expand Down Expand Up @@ -98,9 +94,6 @@ private List<String> getInitialGoals()

String jacocoAgent = System.getProperty( "jacoco.agent", "" );
goals.add( "-Djacoco.agent=" + jacocoAgent );

goals.add( "-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2" );

goals.add( "-nsu" );

return goals;
Expand Down