Skip to content

Commit

Permalink
Use runtime version instead of system property in the language featur…
Browse files Browse the repository at this point in the history
…e test.
  • Loading branch information
tsaglam committed Jul 9, 2024
1 parent 39b4a94 commit d7340d0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions core/src/test/java/de/jplag/NewJavaFeaturesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@ public class NewJavaFeaturesTest extends TestBase {
private static final String CHANGE_MESSAGE = "Number of %s changed! If intended, modify the test case!";
private static final String VERSION_MISMATCH_MESSAGE = "Using Java version %s instead of %s may skew the results.";
private static final String VERSION_MATCH_MESSAGE = "Java version matches, but results deviate from expected values";
private static final String JAVA_VERSION_KEY = "java.version";
private static final String CI_VARIABLE = "CI";

public static final int JAVA_VERSION = 21;
public static final int EXPECTED_JAVA_VERSION = 21;

@Test
@DisplayName("test comparison of Java files with modern language features")
public void testJavaFeatureDuplicates() throws ExitException {
// pre-condition
String actualJavaVersion = System.getProperty(JAVA_VERSION_KEY);
int javaVersion = Runtime.version().feature();
boolean isCiRun = System.getenv(CI_VARIABLE) != null;
boolean isCorrectJavaVersion = actualJavaVersion.startsWith(String.valueOf(JAVA_VERSION));
assumeTrue(isCorrectJavaVersion || isCiRun, VERSION_MISMATCH_MESSAGE.formatted(actualJavaVersion, JAVA_VERSION));
assumeTrue(javaVersion == EXPECTED_JAVA_VERSION || isCiRun, VERSION_MISMATCH_MESSAGE.formatted(javaVersion, EXPECTED_JAVA_VERSION));

JPlagResult result = runJPlagWithExclusionFile(ROOT_DIRECTORY, EXCLUSION_FILE_NAME);

Expand Down

0 comments on commit d7340d0

Please sign in to comment.