diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-21 02:16:20 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-21 02:16:20 +0700 |
commit | 68ad86eb6ed70c15ad4209295903a9a977b001f6 (patch) | |
tree | e65d53e92cf4136d76337bd5e6f8e55da958fff5 /testing/src | |
parent | a1867b05ba6443d32abc4049c26b92fc226d6f78 (diff) | |
download | aspectj-68ad86eb6ed70c15ad4209295903a9a977b001f6.tar.gz aspectj-68ad86eb6ed70c15ad4209295903a9a977b001f6.zip |
Add Java 16 test suite for AspectJ 1.9.7 + test refactorings
- Test all features which were preview in 14+15 and are now final in 16,
compiling them with language level 16.
- For Java 15 we only have sanity tests (and of course the Java <14
tests), compiling Java 16 features to target 15 does not seem to work.
- Test remaining Java 16 preview feature (sealed classes).
- Instead of overriding runTest(String) in several base classes like
XMLBasedAjcTestCaseForJava*Only or XMLBasedAjcTestCaseForJava*OrLater,
we now override setUp() from JUnit's TestCase base class. This will
run before runTest(String) and make the tests fail much faster, if a
user tries to run them on the wrong VM.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'testing/src')
11 files changed, 95 insertions, 42 deletions
diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java index 4a8c63f11..753de0c80 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java @@ -21,11 +21,10 @@ import org.aspectj.util.LangUtil; public abstract class XMLBasedAjcTestCaseForJava10OrLater extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { - if (!LangUtil.is10VMOrGreater()) { + public void setUp() throws Exception { + if (!LangUtil.is10VMOrGreater()) throw new IllegalStateException("These tests should be run on Java 10 or later"); - } - super.runTest(title); + super.setUp(); } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java index 18181d60e..1bfcdd580 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java @@ -21,11 +21,10 @@ import org.aspectj.util.LangUtil; public abstract class XMLBasedAjcTestCaseForJava11OrLater extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { - if (!LangUtil.is11VMOrGreater()) { + public void setUp() throws Exception { + if (!LangUtil.is11VMOrGreater()) throw new IllegalStateException("These tests should be run on Java 11 or later"); - } - super.runTest(title); + super.setUp(); } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java index c3242a36b..e1a847f4e 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java @@ -21,11 +21,10 @@ import org.aspectj.util.LangUtil; public abstract class XMLBasedAjcTestCaseForJava12OrLater extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { - if (!LangUtil.is12VMOrGreater()) { + public void setUp() throws Exception { + if (!LangUtil.is12VMOrGreater()) throw new IllegalStateException("These tests should be run on Java 12 or later"); - } - super.runTest(title); + super.setUp(); } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java index 92193f540..2ce1ee80e 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java @@ -21,11 +21,10 @@ import org.aspectj.util.LangUtil; public abstract class XMLBasedAjcTestCaseForJava13OrLater extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { - if (!LangUtil.is13VMOrGreater()) { + public void setUp() throws Exception { + if (!LangUtil.is13VMOrGreater()) throw new IllegalStateException("These tests should be run on Java 13 or later"); - } - super.runTest(title); + super.setUp(); } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java index 5a25c9a73..8e90ead3a 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java @@ -8,8 +8,6 @@ * ******************************************************************/ package org.aspectj.testing; -import org.aspectj.util.LangUtil; - /** * Makes sure tests are running on the right level of JDK. * @@ -18,7 +16,7 @@ import org.aspectj.util.LangUtil; public abstract class XMLBasedAjcTestCaseForJava14Only extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { + public void setUp() throws Exception { throw new IllegalStateException( "These tests need a Java 14 level AspectJ compiler " + "(e.g. because they use version-specific preview features). " + @@ -31,7 +29,7 @@ public abstract class XMLBasedAjcTestCaseForJava14Only extends XMLBasedAjcTestCa "(e.g. because they use version-specific preview features)" ); } - super.runTest(title); + super.setUp(); */ } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14OrLater.java index 15c1ac568..73df02f4a 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14OrLater.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14OrLater.java @@ -18,11 +18,10 @@ import org.aspectj.util.LangUtil; public abstract class XMLBasedAjcTestCaseForJava14OrLater extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { - if (!LangUtil.is14VMOrGreater()) { + public void setUp() throws Exception { + if (!LangUtil.is14VMOrGreater()) throw new IllegalStateException("These tests should be run on Java 14 or later"); - } - super.runTest(title); + super.setUp(); } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java index 82fe4045c..0e9f43d83 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java @@ -8,8 +8,6 @@ * ******************************************************************/ package org.aspectj.testing; -import org.aspectj.util.LangUtil; - /** * Makes sure tests are running on the right level of JDK. * @@ -18,22 +16,21 @@ import org.aspectj.util.LangUtil; public abstract class XMLBasedAjcTestCaseForJava15Only extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { - // Activate this block after upgrading to JDT Core Java 16 - /* + public void setUp() throws Exception { throw new IllegalStateException( "These tests need a Java 15 level AspectJ compiler " + "(e.g. because they use version-specific preview features). " + "This compiler does not support preview features of a previous version anymore." ); - */ + /* if (!LangUtil.is15VMOrGreater() || LangUtil.is16VMOrGreater()) { throw new IllegalStateException( "These tests should be run on Java 15 only " + "(e.g. because they use version-specific preview features)" ); } - super.runTest(title); + super.setUp(); + */ } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15OrLater.java index 90b7feda1..72033daf5 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15OrLater.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15OrLater.java @@ -1,5 +1,5 @@ /* ******************************************************************* - * Copyright (c) 2020 Contributors + * Copyright (c) 2021 Contributors * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 @@ -13,16 +13,15 @@ import org.aspectj.util.LangUtil; /** * Makes sure tests are running on the right level of JDK. * - * @author Andy Clement + * @author Alexander Kriegisch */ public abstract class XMLBasedAjcTestCaseForJava15OrLater extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { - if (!LangUtil.is15VMOrGreater()) { + public void setUp() throws Exception { + if (!LangUtil.is15VMOrGreater()) throw new IllegalStateException("These tests should be run on Java 15 or later"); - } - super.runTest(title); + super.setUp(); } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java new file mode 100644 index 000000000..dc51db8ca --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java @@ -0,0 +1,39 @@ +/* ******************************************************************* + * Copyright (c) 2021 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * ******************************************************************/ +package org.aspectj.testing; + +import org.aspectj.util.LangUtil; + +/** + * Makes sure tests are running on the right level of JDK. + * + * @author Alexander Kriegisch + */ +public abstract class XMLBasedAjcTestCaseForJava16Only extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + // Activate this block after upgrading to JDT Core Java 17 + /* + throw new IllegalStateException( + "These tests need a Java 16 level AspectJ compiler " + + "(e.g. because they use version-specific preview features). " + + "This compiler does not support preview features of a previous version anymore." + ); + */ + if (!LangUtil.is16VMOrGreater() || LangUtil.is17VMOrGreater()) { + throw new IllegalStateException( + "These tests should be run on Java 16 only " + + "(e.g. because they use version-specific preview features)" + ); + } + super.setUp(); + } + +} diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16OrLater.java new file mode 100644 index 000000000..6fd29c8d3 --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16OrLater.java @@ -0,0 +1,27 @@ +/* ******************************************************************* + * Copyright (c) 2021 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * ******************************************************************/ +package org.aspectj.testing; + +import org.aspectj.util.LangUtil; + +/** + * Makes sure tests are running on the right level of JDK. + * + * @author Alexander Kriegisch + */ +public abstract class XMLBasedAjcTestCaseForJava16OrLater extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + if (!LangUtil.is16VMOrGreater()) + throw new IllegalStateException("These tests should be run on Java 16 or later"); + super.setUp(); + } + +} diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java index 19e80c474..0be3424ef 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java @@ -21,12 +21,10 @@ import org.aspectj.util.LangUtil; public abstract class XMLBasedAjcTestCaseForJava9OrLater extends XMLBasedAjcTestCase { @Override - public void runTest(String title) { - // Check we are on Java9 or later - if (!LangUtil.is9VMOrGreater()) { + public void setUp() throws Exception { + if (!LangUtil.is9VMOrGreater()) throw new IllegalStateException("These tests should be run on Java 9 or later"); - } - super.runTest(title); + super.setUp(); } } |