aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test/java/org/aspectj
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2024-03-22 20:53:10 +0100
committerAlexander Kriegisch <Alexander@Kriegisch.name>2024-03-22 20:53:10 +0100
commit9279adc198abe155e2973a78690b50eadd69bc2c (patch)
tree5b7900a3f70cd037fa0b2f60b346cd8839b2dccf /tests/src/test/java/org/aspectj
parent08fc5f7cc74815861f9f1dc8cac7a0c06d6efa68 (diff)
downloadaspectj-9279adc198abe155e2973a78690b50eadd69bc2c.tar.gz
aspectj-9279adc198abe155e2973a78690b50eadd69bc2c.zip
Switch to Java 22 + add basic test suite
The tests from Java 21 were copied to 22. Inactive ones were activated after their features under test were fixed/implemented. Preview ones were promotes to final ones for unnamed variables and patterns. TODO: Add tests for new Java 22 features and maybe adjust or amend existing feature tests, if preview or final characteristics have changed since Java 21. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/src/test/java/org/aspectj')
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/AllTests19.java4
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java12
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java6
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc1922/Ajc1922TestsJava.java55
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc1922/AllTestsAspectJ1922.java50
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc1922/Bugs1922Tests.java31
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc1922/Java22PreviewFeaturesTests.java57
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc1922/SanityTestsJava22.java92
8 files changed, 288 insertions, 19 deletions
diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java
index 665569ec7..7d8b11c1e 100644
--- a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java
+++ b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java
@@ -13,6 +13,7 @@ import org.aspectj.systemtest.ajc1919.AllTestsAspectJ1919;
import org.aspectj.systemtest.ajc192.AllTestsAspectJ192;
import org.aspectj.systemtest.ajc1920.AllTestsAspectJ1920;
import org.aspectj.systemtest.ajc1921.AllTestsAspectJ1921;
+import org.aspectj.systemtest.ajc1922.AllTestsAspectJ1922;
import org.aspectj.systemtest.ajc193.AllTestsAspectJ193;
import org.aspectj.systemtest.ajc195.AllTestsAspectJ195;
import org.aspectj.systemtest.ajc196.AllTestsAspectJ196;
@@ -43,8 +44,9 @@ public class AllTests19 {
suite.addTest(AllTestsAspectJ199.suite());
suite.addTest(AllTestsAspectJ1919.suite());
suite.addTest(AllTestsAspectJ1920.suite());
- // AspectJ_JDK_Update
suite.addTest(AllTestsAspectJ1921.suite());
+ // AspectJ_JDK_Update
+ suite.addTest(AllTestsAspectJ1922.suite());
suite.addTest(AllTests18.suite());
// $JUnit-END$
return suite;
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java
index a8166995b..8fd5b4514 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java
@@ -12,18 +12,6 @@ import junit.framework.TestSuite;
import org.aspectj.tools.ant.taskdefs.AjcTask;
import org.aspectj.util.LangUtil;
-// AspectJ_JDK_Update
-// - Copy 'ajc*' package with all classes to a new package, incrementing the version number in the package
-// - Rename all classes, incrementing version numbers
-// - Add this class to the suite in class AllTests19
-// - Increment version numbers in strings, method calls and constants to the appropriate values, creating necessary
-// methods and constants classes providing them, if they do not exist yet
-// - Also increment references to 'ajc*.xml' and 'sanity-tests-*.xml' test definition, copying the previous
-// tests/src/test/resources/org/aspectj/systemtest/ajc* directory, incrementing all names and adjusting the XML
-// file contents appropriately
-// - Search for other 'AspectJ_JDK_Update' hints in the repository, also performing the necessary to-dos there
-// - Remove this comment from the previous class version after copying this one
-
/**
* @author Alexander Kriegisch
*/
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java
index 2fd5e8ef8..086c989ca 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java
@@ -32,8 +32,6 @@ public class Java21PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTe
/**
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/893">GitHub issue 893</a>.
- * <p>
- * TODO: Activate after JDT Core implementation and merge.
*/
public void testUnnamedPatterns() {
//runTest("unnamed patterns");
@@ -43,8 +41,6 @@ public class Java21PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTe
/**
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/893">GitHub issue 893</a>.
- * <p>
- * TODO: Activate after JDT Core implementation and merge.
*/
public void testUnnamedPatternsAspect() {
//runTest("unnamed patterns aspect");
@@ -73,8 +69,6 @@ public class Java21PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTe
/**
* Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
* see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106">GitHub issue 1106</a>.
- * <p>
- * TODO: Activate after JDT Core implementation and merge.
*/
public void testUnnamedClassWithSimpleMainMethod() {
//runTest("unnamed class with simple main method");
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1922/Ajc1922TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc1922/Ajc1922TestsJava.java
new file mode 100644
index 000000000..5130a1c38
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc1922/Ajc1922TestsJava.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2024 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.systemtest.ajc1922;
+
+import junit.framework.Test;
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.systemtest.ajc10x.Ajc10xTests;
+import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Ajc1922TestsJava extends JavaVersionSpecificXMLBasedAjcTestCase {
+
+ private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(22);
+
+ public Ajc1922TestsJava() {
+ super(22);
+ }
+
+ public void testUnnamedPatterns() {
+ runTest("unnamed patterns");
+ }
+
+ public void testUnnamedPatternsAspect() {
+ runTest("unnamed patterns aspect");
+ }
+
+ /**
+ * Same as {@link Ajc10xTests#test052()}, but compiled to target 22 instead of 1.4
+ */
+ public void testUnderscoreInPointcutPattern1() {
+ runTest("underscore can still be used in pointcut patterns on Java 21+ - 1");
+ }
+
+ public void testUnderscoreInPointcutPattern2() {
+ runTest("underscore can still be used in pointcut patterns on Java 21+ - 2");
+ }
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc1922TestsJava.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("ajc1922.xml");
+ }
+
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1922/AllTestsAspectJ1922.java b/tests/src/test/java/org/aspectj/systemtest/ajc1922/AllTestsAspectJ1922.java
new file mode 100644
index 000000000..b32e9edd2
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc1922/AllTestsAspectJ1922.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2024 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.systemtest.ajc1922;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.aspectj.tools.ant.taskdefs.AjcTask;
+import org.aspectj.util.LangUtil;
+
+// AspectJ_JDK_Update
+// - Copy 'ajc*' package with all classes to a new package, incrementing the version number in the package
+// - Rename all classes, incrementing version numbers
+// - Add this class to the suite in class AllTests19
+// - Increment version numbers in strings, method calls and constants to the appropriate values, creating necessary
+// methods and constants classes providing them, if they do not exist yet
+// - Also increment references to 'ajc*.xml' and 'sanity-tests-*.xml' test definition, copying the previous
+// tests/src/test/resources/org/aspectj/systemtest/ajc* directory, incrementing all names and adjusting the XML
+// file contents appropriately
+// - Search for other 'AspectJ_JDK_Update' hints in the repository, also performing the necessary to-dos there
+// - Remove this comment from the previous class version after copying this one
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class AllTestsAspectJ1922 {
+
+ private static final int JAVA_VERSION = 22;
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AspectJ 1.9.22 tests");
+ suite.addTest(Bugs1922Tests.suite());
+ if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION)) {
+ suite.addTest(SanityTestsJava22.suite());
+ suite.addTest(Ajc1922TestsJava.suite());
+ }
+
+ // Do not run tests using a previous compiler's preview features anymore. They would all fail.
+ if (AjcTask.JAVA_VERSION_MAX == JAVA_VERSION) {
+ if (LangUtil.isVMGreaterOrEqual(JAVA_VERSION) && LangUtil.isVMLessOrEqual(JAVA_VERSION)) {
+ suite.addTest(Java22PreviewFeaturesTests.suite());
+ }
+ }
+ return suite;
+ }
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1922/Bugs1922Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1922/Bugs1922Tests.java
new file mode 100644
index 000000000..06211a179
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc1922/Bugs1922Tests.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2024 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.systemtest.ajc1922;
+
+import junit.framework.Test;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Bugs1922Tests extends XMLBasedAjcTestCase {
+
+ public void testDummy() {
+ //runTest("dummy");
+ }
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Bugs1922Tests.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("ajc1922.xml");
+ }
+
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1922/Java22PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1922/Java22PreviewFeaturesTests.java
new file mode 100644
index 000000000..0116f8821
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc1922/Java22PreviewFeaturesTests.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2024 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.systemtest.ajc1922;
+
+import junit.framework.Test;
+import org.aspectj.systemtest.ajc10x.Ajc10xTests;
+import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Java22PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
+
+ public Java22PreviewFeaturesTests() {
+ super(22, 22);
+ }
+
+ public void testStringPatterns() {
+ runTest("string patterns");
+ }
+
+ public void testStringPatternsAspect() {
+ runTest("string patterns aspect");
+ }
+
+ public void testNamedClassWithSimpleMainMethod() {
+ runTest("named class with simple main method");
+ }
+
+ public void testNamedAspectWithSimpleMainMethod() {
+ runTest("named aspect with simple main method");
+ }
+
+ /**
+ * Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
+ * see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106">GitHub issue 1106</a>.
+ */
+ public void testUnnamedClassWithSimpleMainMethod() {
+ runTest("unnamed class with simple main method");
+ }
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Java22PreviewFeaturesTests.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("ajc1922.xml");
+ }
+
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1922/SanityTestsJava22.java b/tests/src/test/java/org/aspectj/systemtest/ajc1922/SanityTestsJava22.java
new file mode 100644
index 000000000..30cea09f5
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc1922/SanityTestsJava22.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2024 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.systemtest.ajc1922;
+
+import junit.framework.Test;
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/*
+ * Some very trivial tests that help verify things are OK.
+ * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -22 option
+ * to check code generation and modification with that version specified.
+ *
+ * @author Alexander Kriegisch
+ */
+public class SanityTestsJava22 extends JavaVersionSpecificXMLBasedAjcTestCase {
+
+ public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(22).MAJOR;
+
+ public SanityTestsJava22() {
+ super(22);
+ }
+
+ // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
+ public void testSimpleJava_A() {
+ runTest("simple - a");
+ }
+
+ public void testSimpleJava_B() {
+ runTest("simple - b");
+ }
+
+ public void testSimpleCode_C() {
+ runTest("simple - c");
+ }
+
+ public void testSimpleCode_D() {
+ runTest("simple - d");
+ }
+
+ public void testSimpleCode_E() {
+ runTest("simple - e");
+ }
+
+ public void testSimpleCode_F() {
+ runTest("simple - f");
+ }
+
+ public void testSimpleCode_G() {
+ runTest("simple - g");
+ }
+
+ public void testSimpleCode_H() {
+ runTest("simple - h", true);
+ }
+
+ public void testSimpleCode_I() {
+ runTest("simple - i");
+ }
+
+ public void testVersionCorrect1() {
+ runTest("simple - j");
+ checkVersion("A", bytecode_version_for_JDK_level, 0);
+ }
+
+ public void testVersionCorrect2() {
+ runTest("simple - k");
+ checkVersion("A", bytecode_version_for_JDK_level, 0);
+ }
+
+ public void testVersionCorrect4() {
+ runTest("simple - m");
+ // Must be 49.0 when -1.5 is specified
+ checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
+ }
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(SanityTestsJava22.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("sanity-tests-22.xml");
+ }
+
+}