diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-06-26 16:16:18 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-06-26 16:51:19 +0700 |
commit | 9de03c3ea52f78678d8c47296395d5f01d031a48 (patch) | |
tree | 748d092412c09670f2781c38cea1ebe9b86c689d /tests | |
parent | dfcf1d77a65344934f0e642907819f16b5a3af0a (diff) | |
download | aspectj-9de03c3ea52f78678d8c47296395d5f01d031a48.tar.gz aspectj-9de03c3ea52f78678d8c47296395d5f01d031a48.zip |
Add AspectJ 1.9.7 and Java 17 test skeletons
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests')
7 files changed, 335 insertions, 0 deletions
diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java index 4a52e8fe4..7223aff59 100644 --- a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java @@ -17,6 +17,7 @@ import org.aspectj.systemtest.ajc196.AllTestsAspectJ196; import junit.framework.Test; import junit.framework.TestSuite; import org.aspectj.systemtest.ajc197.AllTestsAspectJ197; +import org.aspectj.systemtest.ajc198.AllTestsAspectJ198; /** * @author Andy Clement @@ -34,6 +35,7 @@ public class AllTests19 { suite.addTest(AllTestsAspectJ195.suite()); suite.addTest(AllTestsAspectJ196.suite()); suite.addTest(AllTestsAspectJ197.suite()); + suite.addTest(AllTestsAspectJ198.suite()); suite.addTest(AllTests18.suite()); // $JUnit-END$ return suite; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java new file mode 100644 index 000000000..172d6e14e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc198; + +import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater; + +/** + * @author Alexander Kriegisch + */ +public class Ajc198TestsJava extends XMLBasedAjcTestCaseForJava17OrLater { + + public void testHiddenClass() { + runTest("hidden class"); + checkVersion("HiddenClassDemo", Constants.MAJOR_17, Constants.MINOR_17); + } + + public void testTextBlock1() { + runTest("textblock 1"); + checkVersion("Code", Constants.MAJOR_17, Constants.MINOR_17); + } + + public void testTextBlock2() { + runTest("textblock 2"); + checkVersion("Code2", Constants.MAJOR_17, Constants.MINOR_17); + } + + public void testRecords() { + runTest("simple record"); + checkVersion("Person", Constants.MAJOR_17, Constants.MINOR_17); + } + + public void testRecords2() { + runTest("using a record"); + checkVersion("UsingPersonRecord", Constants.MAJOR_17, Constants.MINOR_17); + } + + public void testAdvisingRecords() { + runTest("advising records"); + checkVersion("TraceRecordComponents", Constants.MAJOR_17, Constants.MINOR_17); + } + + public void testInstanceofPatterns() { + runTest("instanceof patterns"); + checkVersion("Jep305", Constants.MAJOR_17, Constants.MINOR_17); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc198TestsJava.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc198.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java new file mode 100644 index 000000000..26d749222 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc198; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.aspectj.util.LangUtil; + +/** + * @author Alexander Kriegisch + */ +public class AllTestsAspectJ198 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.8 tests"); + if (LangUtil.is17VMOrGreater()) { + suite.addTest(SanityTestsJava17.suite()); + suite.addTest(Ajc198TestsJava.suite()); + } + if (LangUtil.is17VMOrGreater() && !LangUtil.is18VMOrGreater()) { + suite.addTest(Java17PreviewFeaturesTests.suite()); + } + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java new file mode 100644 index 000000000..fab787724 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc198; + +import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava17Only; + +/** + * @author Alexander Kriegisch + */ +public class Java17PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava17Only { + +/* + public void testSealedClassWithLegalSubclasses() { + runTest("sealed class with legal subclasses"); + checkVersion("Employee", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Manager", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSealedClassWithIllegalSubclass() { + runTest("sealed class with illegal subclass"); + checkVersion("Person", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); + } + + public void testWeaveSealedClass() { + runTest("weave sealed class"); + checkVersion("PersonAspect", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); + } +*/ + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Java17PreviewFeaturesTests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc198.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java new file mode 100644 index 000000000..4fac5f375 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc198; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater; + +/* + * 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 -10 option + * to check code generation and modification with that version specified. + * + * @author Alexander Kriegisch + */ +public class SanityTestsJava17 extends XMLBasedAjcTestCaseForJava17OrLater { + + public static final int bytecode_version_for_JDK_level = 61; + + // 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", 49, 0); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTestsJava17.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("sanity-tests-17.xml"); + } + +} diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml new file mode 100644 index 000000000..e2dc9fe5d --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml @@ -0,0 +1,35 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + + +<suite> + + <!-- Java ?? final, Java 16, 15 preview --> +<!-- + <ajc-test dir="features197/java15" vm="17" title="sealed class with legal subclasses"> + <compile files="Person.java Employee.java Manager.java" options="--enable-preview -16" /> + </ajc-test> +--> + + <!-- Java ?? final, Java 16, 15 preview --> +<!-- + <ajc-test dir="features197/java15" vm="17" title="sealed class with illegal subclass"> + <compile files="Person.java Employee.java Manager.java PersonaNonGrata.java" options="--enable-preview -16"> + <message kind="error" file="PersonaNonGrata.java" text="should be a permitted subtype of Person"/> + </compile> + </ajc-test> +--> + + <!-- Java ?? final, Java 16, 15 preview --> +<!-- + <ajc-test dir="features197/java15" vm="17" title="weave sealed class"> + <compile files="Person.java Employee.java Manager.java TopManager.java PersonAspect.aj" options="--enable-preview -16" /> + <run class="TopManager" vmargs="--enable-preview"> + <stdout> + <line text="Hello Sir John" /> + <line text="CEO" /> + </stdout> + </run> + </ajc-test> +--> + +</suite> diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml new file mode 100644 index 000000000..70f52fafa --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml @@ -0,0 +1,70 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + <!-- empty class --> + <ajc-test dir="bugs160/simplejava" title="simple - a"> + <compile files="SimpleA.java" options="-17"/> + </ajc-test> + + <!-- class with one method --> + <ajc-test dir="bugs160/simplejava" title="simple - b"> + <compile files="SimpleB.java" options="-17"/> + <run class="SimpleB"/> + </ajc-test> + + <!-- empty aspect --> + <ajc-test dir="bugs160/simplejava" title="simple - c"> + <compile files="SimpleC.java" options="-17"/> + </ajc-test> + + <!-- simple before --> + <ajc-test dir="bugs160/simplejava" title="simple - d"> + <compile files="SimpleD.java" options="-17"/> + </ajc-test> + + <!-- simple itd field --> + <ajc-test dir="bugs160/simplejava" title="simple - e"> + <compile files="SimpleE.java" options="-17"/> + </ajc-test> + + <!-- aspect with main calling a static method --> + <ajc-test dir="bugs160/simplejava" title="simple - f"> + <compile files="SimpleF.java" options="-17"/> + </ajc-test> + + <!-- pertarget --> + <ajc-test dir="bugs160/simplejava" title="simple - g"> + <compile files="SimpleG.java" options="-17"/> + </ajc-test> + + <!-- generic ctor itds --> + <ajc-test dir="bugs160/simplejava" title="simple - h"> + <compile files="SimpleH.java" options="-17"/> + </ajc-test> + + <!-- overriding generic itd methods --> + <ajc-test dir="bugs160/simplejava" title="simple - i"> + <compile files="SimpleI.java" options="-17"/> + </ajc-test> + + <!-- check class file version is 60.0 (Java 16) --> + <ajc-test dir="bugs160/simplejava" title="simple - j"> + <compile files="SimpleJ.java" options="-17"/> + </ajc-test> + + <!-- check class file version is 60.0 (Java 16) --> + <ajc-test dir="bugs160/simplejava" title="simple - k"> + <compile files="SimpleJ.java" options="-source 16"/> + </ajc-test> + + <!-- check class file version is 49.0 --> + <ajc-test dir="bugs160/simplejava" title="simple - m"> + <compile files="SimpleJ.java" options="-1.5"/> + </ajc-test> + + <ajc-test dir="bugs160/simplejava" title="simple - n"> + <compile files="SimpleN.java" options="-17"/> + </ajc-test> + +</suite> |