aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test/java/org/aspectj/systemtest/ajc197
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2024-02-19 22:01:05 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2024-02-19 22:01:05 +0700
commit47db35bb48a1ef0919dff62521ca38cd7cf3ccec (patch)
treefce4041a52368870ec8beb8eb5b9a16f36b98ecc /tests/src/test/java/org/aspectj/systemtest/ajc197
parent4e4641f8cc06176377a1faf8378e93df9bf248e1 (diff)
downloadaspectj-47db35bb48a1ef0919dff62521ca38cd7cf3ccec.tar.gz
aspectj-47db35bb48a1ef0919dff62521ca38cd7cf3ccec.zip
New abstract class JavaVersionSpecificXMLBasedAjcTestCase
Replaces now obsolete base classes - XMLBasedAjcTestCaseForJava[n]OrLater, - XMLBasedAjcTestCaseForJava[n]Only. The new class is parametrised with minimum and maximum Java version and hence can replace all the other classes. This does not only apply the DRY principle, but also makes adding tests for new Java versions less tedious. By chance, I also noticed missing sanity tests for Java 12, which I added as a little drive-by benefit. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/src/test/java/org/aspectj/systemtest/ajc197')
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java24
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java15
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java8
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java8
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java8
5 files changed, 43 insertions, 20 deletions
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java
index 8a1f794f4..4150ea8b7 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java
@@ -9,47 +9,53 @@ package org.aspectj.systemtest.ajc197;
import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
-import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;
/**
* @author Alexander Kriegisch
*/
-public class Ajc197TestsJava extends XMLBasedAjcTestCaseForJava16OrLater {
+public class Ajc197TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {
+
+ private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(16);
+
+ public Ajc197TestsJava() {
+ super(16);
+ }
public void testHiddenClass() {
runTest("hidden class");
- checkVersion("HiddenClassDemo", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
+ checkVersion("HiddenClassDemo", classFileVersion.MAJOR, classFileVersion.MINOR);
}
public void testTextBlock1() {
runTest("textblock 1");
- checkVersion("Code", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
+ checkVersion("Code", classFileVersion.MAJOR, classFileVersion.MINOR);
}
public void testTextBlock2() {
runTest("textblock 2");
- checkVersion("Code2", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
+ checkVersion("Code2", classFileVersion.MAJOR, classFileVersion.MINOR);
}
public void testRecords() {
runTest("simple record");
- checkVersion("Person", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
+ checkVersion("Person", classFileVersion.MAJOR, classFileVersion.MINOR);
}
public void testRecords2() {
runTest("using a record");
- checkVersion("UsingPersonRecord", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
+ checkVersion("UsingPersonRecord", classFileVersion.MAJOR, classFileVersion.MINOR);
}
public void testAdvisingRecords() {
runTest("advising records");
- checkVersion("TraceRecordComponents", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
+ checkVersion("TraceRecordComponents", classFileVersion.MAJOR, classFileVersion.MINOR);
}
public void testInstanceofPatterns() {
runTest("instanceof patterns");
- checkVersion("Jep305", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
+ checkVersion("Jep305", classFileVersion.MAJOR, classFileVersion.MINOR);
}
public static Test suite() {
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java
index 7feccc2e2..999071a9f 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java
@@ -9,6 +9,7 @@ package org.aspectj.systemtest.ajc197;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.aspectj.tools.ant.taskdefs.AjcTask;
import org.aspectj.util.LangUtil;
/**
@@ -16,21 +17,25 @@ import org.aspectj.util.LangUtil;
*/
public class AllTestsAspectJ197 {
+ private static final int JAVA_VERSION = 16;
+
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.7 tests");
+ //suite.addTest(Bugs197Tests.suite());
if (LangUtil.isVMGreaterOrEqual(15)) {
suite.addTest(SanityTestsJava15.suite());
}
- if (LangUtil.isVMGreaterOrEqual(16)) {
+ if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
suite.addTest(SanityTestsJava16.suite());
suite.addTest(Ajc197TestsJava.suite());
}
+
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
- /*
- if (LangUtil.isVMGreaterOrEqual(16) && !LangUtil.isVMGreaterOrEqual(17)) {
- suite.addTest(Java16PreviewFeaturesTests.suite());
+ if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
+ if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
+ suite.addTest(Java16PreviewFeaturesTests.suite());
+ }
}
- */
return suite;
}
}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java
index f2c04e08c..7a8a61fd6 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java
@@ -9,15 +9,19 @@ package org.aspectj.systemtest.ajc197;
import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
-import org.aspectj.testing.XMLBasedAjcTestCaseForJava16Only;
/**
* @author Alexander Kriegisch
*/
-public class Java16PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava16Only {
+public class Java16PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(16);
+ public Java16PreviewFeaturesTests() {
+ super(16, 16);
+ }
+
public void testSealedClassWithLegalSubclasses() {
runTest("sealed class with legal subclasses");
checkVersion("Employee", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java
index d244ebea7..570b86511 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java
@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc197;
import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
-import org.aspectj.testing.XMLBasedAjcTestCaseForJava15OrLater;
/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,14 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava15OrLater;
*
* @author Alexander Kriegisch
*/
-public class SanityTestsJava15 extends XMLBasedAjcTestCaseForJava15OrLater {
+public class SanityTestsJava15 extends JavaVersionSpecificXMLBasedAjcTestCase {
public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(15).MAJOR;
+ public SanityTestsJava15() {
+ super(15);
+ }
+
// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java
index 1e42ce6d7..d86264a91 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java
@@ -9,8 +9,8 @@ package org.aspectj.systemtest.ajc197;
import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCase;
-import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;
/*
* Some very trivial tests that help verify things are OK.
@@ -19,10 +19,14 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;
*
* @author Alexander Kriegisch
*/
-public class SanityTestsJava16 extends XMLBasedAjcTestCaseForJava16OrLater {
+public class SanityTestsJava16 extends JavaVersionSpecificXMLBasedAjcTestCase {
public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(16).MAJOR;
+ public SanityTestsJava16() {
+ super(16);
+ }
+
// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
public void testSimpleJava_A() {
runTest("simple - a");