From 2b24e7377da7c849fe7f9f4fa06a701664f9d27d Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Wed, 30 Jan 2019 16:55:38 -0800 Subject: mavenizing tests - wip --- .../org/aspectj/systemtest/ajc163/Ajc163Tests.java | 320 +++++++++++++++++++ .../systemtest/ajc163/AllTestsAspectJ163.java | 25 ++ .../java/org/aspectj/systemtest/ajc163/ajc163.xml | 354 +++++++++++++++++++++ 3 files changed, 699 insertions(+) create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc163/Ajc163Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc163/AllTestsAspectJ163.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc163/ajc163.xml (limited to 'tests/src/test/java/org/aspectj/systemtest/ajc163') diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc163/Ajc163Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc163/Ajc163Tests.java new file mode 100644 index 000000000..15abc8921 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc163/Ajc163Tests.java @@ -0,0 +1,320 @@ +/******************************************************************************* + * Copyright (c) 2008 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc163; + +import java.io.File; +import java.util.List; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.LocalVariable; +import org.aspectj.apache.bcel.classfile.LocalVariableTable; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.testing.Utils; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testGenericMethodBridging_pr251326() { + runTest("itd anonymous inner class in wrong package"); + } + + public void testOrderingRepetitive_pr259279() { + runTest("ordering repetitive method"); + } + + public void testOrderingRepetitive_pr259279_2() { + runTest("ordering repetitive method - 2"); + } + + public void testExtendingASI_pr252722() { + runTest("extending AbstractSecurityInterceptor"); + } + + public void testExtendingASI_pr252722_2() { + runTest("extending AbstractSecurityInterceptor - 2"); + } + + public void testExtendingASI_pr252722_3() { + runTest("extending AbstractSecurityInterceptor - 3"); + } + + public void testExtendingASI_pr252722_4() { + runTest("extending AbstractSecurityInterceptor - 4"); + } + + public void testGetNode_pr258653() { + runTest("getNode"); + } + + public void testAtTargetPlus_pr255856() { + runTest("attarget with plus"); + } + + public void testNonNullAtArgs_pr257833() { + runTest("param annos and at args"); + } + + public void testIncorrectArgOrdering_pr219419() { + runTest("incorrect arg ordering anno style"); + } + + public void testIncorrectArgOrdering_pr219419_2() { + runTest("incorrect arg ordering anno style - 2"); + } + + public void testIncorrectArgOrdering_pr219419_3() { + runTest("incorrect arg ordering anno style - 3"); + } + + // similar to 3 but parameters other way round + public void testIncorrectArgOrdering_pr219419_4() { + runTest("incorrect arg ordering anno style - 4"); + } + + // similar to 3 but also JoinPoint passed into advice + public void testIncorrectArgOrdering_pr219419_5() { + runTest("incorrect arg ordering anno style - 5"); + } + + public void testDecpAnnoStyle_pr257754() { + runTest("decp anno style"); + } + + public void testDecpAnnoStyle_pr257754_2() { + runTest("decp anno style - 2"); + } + + public void testPoorAtAjIfMessage_pr256458() { + runTest("poor ataj if message - 1"); + } + + public void testPoorAtAjIfMessage_pr256458_2() { + runTest("poor ataj if message - 2"); + } + + /* + * public void testInheritedAnnotations_pr128664() { runTest("inherited annotations"); } + * + * public void testInheritedAnnotations_pr128664_2() { runTest("inherited annotations - 2"); } + */ + public void testGetMethodNull_pr154427() { + runTest("getMethod returning null"); + } + + public void testItdOnAnonInner_pr171042() { + runTest("itd on anonymous inner"); + } + + public void testMixedStyles_pr213751() { + runTest("mixed styles"); + } + + public void testHandles_pr249216c24() { + runTest("handles - escaped square brackets"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement ipe = null; + ipe = findElementAtLine(top.getRoot(), 4);// public java.util.List Ship.i(List[][] u) + assertEquals("<{Handles.java'Handles)Ship.i)\\[\\[QList\\;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 7);// public java.util.List Ship.i(Set[][] u) + assertEquals("<{Handles.java'Handles)Ship.i)\\[\\[QSet\\;", ipe.getHandleIdentifier()); + + // public java.util.Set i(java.util.Set[][] u) + ipe = findElementAtLine(top.getRoot(), 10); + assertEquals("<{Handles.java'Handles~i~\\[\\[Qjava.util.Set\\;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 13);// public java.util.Set i(java.util.Set[][] u,int i) { + assertEquals("<{Handles.java'Handles~i~\\[\\[Qjava.util.Set\\;~I", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 16);// public java.util.Set i2(java.util.Set>[][] u) { + assertEquals("<{Handles.java'Handles~i2~\\[\\[Qjava.util.Set\\<+QCollection\\;>;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 19);// public java.util.Set i3(java.util.Set>[][] u) + assertEquals("<{Handles.java'Handles~i3~\\[\\[Qjava.util.Set\\<+QCollection\\<\\[QString;>;>;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 22); + assertEquals("<{Handles.java'Handles~i4~Qjava.util.Set\\<+QCollection\\;>;", ipe.getHandleIdentifier()); + + ipe = findElementAtLine(top.getRoot(), 25); + assertEquals("<{Handles.java'Handles~i5~Qjava.util.Set\\<*>;", ipe.getHandleIdentifier()); + + } + + public void testFQType_pr256937() { + runTest("fully qualified return type"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement itd = findElementAtLine(top.getRoot(), 10); + String type = itd.getCorrespondingType(true); + assertEquals("java.util.List", type); + + itd = findElementAtLine(top.getRoot(), 16); + type = itd.getCorrespondingType(true); + assertEquals("java.util.List", type); + } + + private IProgramElement findElementAtLine(IProgramElement whereToLook, int line) { + if (whereToLook == null) { + return null; + } + if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) { + return whereToLook; + } + List kids = whereToLook.getChildren(); + for (IProgramElement object: kids) { + if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) { + return object; + } + IProgramElement gotSomething = findElementAtLine(object, line); + if (gotSomething != null) { + return gotSomething; + } + } + return null; + } + + public void testParameterAnnotationsOnITDs_pr256669() { // regular itd + runTest("parameter annotations on ITDs"); + } + + public void testParameterAnnotationsOnITDs_pr256669_2() { // static itd + runTest("parameter annotations on ITDs - 2"); + } + + public void testParameterAnnotationsOnITDs_pr256669_3() { // multiple parameters + runTest("parameter annotations on ITDs - 3"); + } + + public void testParameterAnnotationsOnITDs_pr256669_4() { // itd on interface + runTest("parameter annotations on ITDs - 4"); + } + + public void testOrderingIssue_1() { + runTest("ordering issue"); + } + + public void testOrderingIssue_2() { + runTest("ordering issue - 2"); + } + + // public void testGenericPointcuts_5() { + // runTest("generic pointcuts - 5"); + // } + + public void testGenericPointcuts_1() { + runTest("generic pointcuts - 1"); + } + + public void testGenericPointcuts_2() { + runTest("generic pointcuts - 2"); + } + + public void testGenericPointcuts_3() { + runTest("generic pointcuts - 3"); + } + + public void testGenericPointcuts_4() { + runTest("generic pointcuts - 4"); + } + + public void testDontAddMethodBodiesToInterface_pr163005() { + runTest("do not add method bodies to an interface"); + } + + public void testDontAddMethodBodiesToInterface_pr163005_2() { + runTest("do not add method bodies to an interface - 2"); + } + + public void testDontAddMethodBodiesToInterface_pr163005_3() { + runTest("do not add method bodies to an interface - 3"); + } + + public void testMissingLocalVariableTableEntriesOnAroundAdvice_pr173978() throws Exception { + runTest("missing local variable table on around advice"); + JavaClass jc = Utils.getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(), "Test"); + Method[] ms = jc.getMethods(); + Method m = null; + for (int i = 0; i < ms.length; i++) { + if (ms[i].getName().equals("sayHello")) { + m = ms[i]; + } + } + if (m.getLocalVariableTable() == null) { + fail("Local variable table should not be null"); + } + assertEquals(2, m.getLocalVariableTable().getLocalVariableTable().length); + // LocalVariableTable: + // Start Length Slot Name Signature + // 0 12 0 this LTest; + // 0 12 1 message Ljava/lang/String; + LocalVariable lv = m.getLocalVariableTable().getLocalVariable(0); + assertNotNull(lv); + assertEquals("this", lv.getName()); + assertEquals(0, lv.getStartPC(), 0); + assertEquals(12, lv.getLength(), 12); + assertEquals("LTest;", lv.getSignature()); + lv = m.getLocalVariableTable().getLocalVariable(1); + assertNotNull(lv); + assertEquals("message", lv.getName()); + assertEquals(0, lv.getStartPC(), 0); + assertEquals(12, lv.getLength(), 12); + assertEquals("Ljava/lang/String;", lv.getSignature()); + // print(m.getLocalVariableTable()); + } + + public void testTerminateAfterCompilation_pr249710() { + runTest("terminateAfterCompilation"); + } + + public void testItdCCE_pr250091() { + runTest("itd cce"); + } + + public void testBreakingRecovery_pr226163() { + runTest("breaking recovery"); + } + + public void testGenericMethodConversions_pr250632() { + runTest("type conversion in generic itd"); + } + + public void testGenericMethodBridging_pr250493() { + runTest("bridge methods for generic itds"); + } + + public void testGenericFieldBridging_pr252285() { + runTest("bridge methods for generic itd fields"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc163Tests.class); + } + + protected File getSpecFile() { + return getClassResource("ajc163.xml"); + } + + // --- + + private void print(LocalVariableTable localVariableTable) { + LocalVariable[] lvs = localVariableTable.getLocalVariableTable(); + for (int i = 0; i < lvs.length; i++) { + LocalVariable localVariable = lvs[i]; + System.out.println(localVariable); + } + } + +} \ No newline at end of file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc163/AllTestsAspectJ163.java b/tests/src/test/java/org/aspectj/systemtest/ajc163/AllTestsAspectJ163.java new file mode 100644 index 000000000..f0fbbeaf6 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc163/AllTestsAspectJ163.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc163; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ163 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.6.3 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc163Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc163/ajc163.xml b/tests/src/test/java/org/aspectj/systemtest/ajc163/ajc163.xml new file mode 100644 index 000000000..c26204aa5 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc163/ajc163.xml @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3