From 78ee9cebd81f1496d69bd0c933e3ee16fa02a96f Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 5 Oct 2023 08:09:24 +0700 Subject: Add test infrastructure for Java 21 (WIP) The tests and their XML definitions are still copy & paste and need to be cleaned up. Separate Java 21 feature tests do not exist yet. Signed-off-by: Alexander Kriegisch --- .../testing/XMLBasedAjcTestCaseForJava20Only.java | 4 +-- .../testing/XMLBasedAjcTestCaseForJava21Only.java | 40 ++++++++++++++++++++++ .../XMLBasedAjcTestCaseForJava21OrLater.java | 27 +++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java create mode 100644 testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java (limited to 'testing') diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java index aeb1152fd..4e0567d0d 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java @@ -20,14 +20,13 @@ public abstract class XMLBasedAjcTestCaseForJava20Only extends XMLBasedAjcTestCa @Override public void setUp() throws Exception { // Activate this block after upgrading to JDT Core Java 21 - /* throw new IllegalStateException( "These tests need a Java 20 level AspectJ compiler " + "(e.g. because they use version-specific preview features). " + "This compiler does not support preview features of a previous version anymore." ); - */ // Activate this block before upgrading to JDT Core Java 21 + /* if (!LangUtil.is20VMOrGreater() || LangUtil.is21VMOrGreater()) { throw new IllegalStateException( "These tests should be run on Java 20 only " + @@ -35,6 +34,7 @@ public abstract class XMLBasedAjcTestCaseForJava20Only extends XMLBasedAjcTestCa ); } super.setUp(); + */ } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java new file mode 100644 index 000000000..fb6795b3d --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java @@ -0,0 +1,40 @@ +/* ******************************************************************* + * Copyright (c) 2023 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * ******************************************************************/ +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 XMLBasedAjcTestCaseForJava21Only extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + // Activate this block after upgrading to JDT Core Java 22 + /* + throw new IllegalStateException( + "These tests need a Java 21 level AspectJ compiler " + + "(e.g. because they use version-specific preview features). " + + "This compiler does not support preview features of a previous version anymore." + ); + */ + // Activate this block before upgrading to JDT Core Java 22 + if (!LangUtil.is21VMOrGreater() || LangUtil.is22VMOrGreater()) { + throw new IllegalStateException( + "These tests should be run on Java 21 only " + + "(e.g. because they use version-specific preview features)" + ); + } + super.setUp(); + } + +} diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java new file mode 100644 index 000000000..4c1d59d15 --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java @@ -0,0 +1,27 @@ +/* ******************************************************************* + * Copyright (c) 2023 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * ******************************************************************/ +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 XMLBasedAjcTestCaseForJava21OrLater extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + if (!LangUtil.is21VMOrGreater()) + throw new IllegalStateException("These tests should be run on Java 21 or later"); + super.setUp(); + } + +} -- cgit v1.2.3