]> source.dussan.org Git - aspectj.git/commitdiff
create copy of 1.6 sanity tests for use at 1.9
authorAndy Clement <aclement@pivotal.io>
Mon, 25 Jul 2016 14:35:29 +0000 (07:35 -0700)
committerAndy Clement <aclement@pivotal.io>
Mon, 25 Jul 2016 14:35:29 +0000 (07:35 -0700)
tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java
tests/src/org/aspectj/systemtest/ajc190/SanityTests19.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc190/sanity-tests.xml [new file with mode: 0644]

index 36b767f1c734e3d17510b47781e146999cae0ea9..70dc872b59fb9241ae5eda48026ffc7deb9f1ff2 100644 (file)
@@ -12,15 +12,14 @@ package org.aspectj.systemtest.ajc190;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import org.aspectj.systemtest.apt.AptTests;
 
 public class AllTestsAspectJ190 {
 
        public static Test suite() {
-               TestSuite suite = new TestSuite("AspectJ 1.8.5 tests");
+               TestSuite suite = new TestSuite("AspectJ 1.9.0 tests");
                // $JUnit-BEGIN$
                suite.addTest(Ajc190Tests.suite());
-               suite.addTest(AptTests.suite());
+               suite.addTest(SanityTests19.suite());
                // $JUnit-END$
                return suite;
        }
diff --git a/tests/src/org/aspectj/systemtest/ajc190/SanityTests19.java b/tests/src/org/aspectj/systemtest/ajc190/SanityTests19.java
new file mode 100644 (file)
index 0000000..3569693
--- /dev/null
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM 
+ * 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.ajc190;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.apache.bcel.classfile.Attribute;
+import org.aspectj.apache.bcel.classfile.Code;
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.Method;
+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 -1.9 option
+ * to check code generation and modification with that version specified.
+ */
+public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+       // 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");
+       }
+
+       // Check the version number in the classfiles is correct when Java6 options specified
+       public void testVersionCorrect1() throws ClassNotFoundException {
+               runTest("simple - j");
+               checkVersion("A", 53, 0);
+       }
+
+       public void testVersionCorrect2() throws ClassNotFoundException {
+               runTest("simple - k");
+               checkVersion("A", 53, 0);
+       }
+
+       public void testVersionCorrect3() throws ClassNotFoundException {
+               runTest("simple - l");
+               checkVersion("A", 53, 0);
+       }
+
+       public void testVersionCorrect4() throws ClassNotFoundException {// check it is 49.0 when -1.5 is specified
+               runTest("simple - m");
+               checkVersion("A", 49, 0);
+       }
+
+       // Check the stackmap stuff appears for methods in a Java6 file
+       // public void testStackMapAttributesAppear() throws ClassNotFoundException {
+       // runTest("simple - n");
+       // checkStackMapExistence("A","<init>_<clinit>");
+       // checkStackMapExistence("X","<init>_<clinit>_ajc$pointcut$$complicatedPointcut$1fe");
+       // }
+
+       /* For the specified class, check that each method has a stackmap attribute */
+       private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException {
+               toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_";
+               JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
+               Method[] methods = jc.getMethods();
+               for (int i = 0; i < methods.length; i++) {
+                       Method method = methods[i];
+                       if (toIgnore.contains("_" + method.getName() + "_")) {
+                               continue;
+                       }
+                       boolean hasStackMapAttribute = findAttribute(method.getAttributes(), "StackMapTable");
+                       if (!hasStackMapAttribute) {
+                               fail("Could not find StackMap attribute for method " + method.getName());
+                       }
+               }
+       }
+
+       private boolean findAttribute(Attribute[] attrs, String attributeName) {
+               if (attrs == null) {
+                       return false;
+               }
+               for (int i = 0; i < attrs.length; i++) {
+                       Attribute attribute = attrs[i];
+                       if (attribute.getName().equals(attributeName)) {
+                               return true;
+                       }
+                       // System.out.println(attribute.getName());
+                       if (attribute.getName().equals("Code")) {
+                               Code c = (Code) attribute;
+                               Attribute[] codeAttributes = c.getAttributes();
+                               for (int j = 0; j < codeAttributes.length; j++) {
+                                       Attribute codeAttribute = codeAttributes[j];
+                                       if (codeAttribute.getName().equals(attributeName)) {
+                                               return true;
+                                               // System.out.println(codeAttribute.getName());
+                                       }
+                               }
+                       }
+               }
+               return false;
+       }
+
+       private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
+               JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
+               if (jc.getMajor() != major) {
+                       fail("Expected major version to be " + major + " but was " + jc.getMajor());
+               }
+               if (jc.getMinor() != minor) {
+                       fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
+               }
+       }
+
+       // Check the stackmap stuff is removed when a method gets woven (for now...)
+       // public void testStackMapAttributesDeletedInWovenCode() {
+       // fail("Not implemented");
+       // }
+
+       // ///////////////////////////////////////
+       public static Test suite() {
+               return XMLBasedAjcTestCase.loadSuite(SanityTests19.class);
+       }
+
+       protected File getSpecFile() {
+               return getClassResource("sanity-tests.xml");
+       }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc190/sanity-tests.xml b/tests/src/org/aspectj/systemtest/ajc190/sanity-tests.xml
new file mode 100644 (file)
index 0000000..ca9b71e
--- /dev/null
@@ -0,0 +1,75 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<!-- AspectJ v1.6.0 Tests -->
+<suite>
+
+    <!-- empty class -->
+    <ajc-test dir="bugs160/simplejava" title="simple - a">
+      <compile files="SimpleA.java" options="-1.9"/>
+    </ajc-test>
+
+    <!-- class with one method -->
+    <ajc-test dir="bugs160/simplejava" title="simple - b">
+      <compile files="SimpleB.java" options="-1.9"/>
+      <run class="SimpleB"/>
+    </ajc-test>
+    
+    <!-- empty aspect -->
+    <ajc-test dir="bugs160/simplejava" title="simple - c">
+      <compile files="SimpleC.java" options="-1.9"/>
+    </ajc-test>
+    
+    <!-- simple before -->
+    <ajc-test dir="bugs160/simplejava" title="simple - d">
+      <compile files="SimpleD.java" options="-1.9"/>
+    </ajc-test>
+    
+    <!-- simple itd field -->
+    <ajc-test dir="bugs160/simplejava" title="simple - e">
+      <compile files="SimpleE.java" options="-1.9"/>
+    </ajc-test>
+    
+    <!-- aspect with main calling a static method -->
+    <ajc-test dir="bugs160/simplejava" title="simple - f">
+      <compile files="SimpleF.java" options="-1.9"/>
+    </ajc-test>
+    
+    <!-- pertarget -->
+    <ajc-test dir="bugs160/simplejava" title="simple - g">
+      <compile files="SimpleG.java" options="-1.9"/>
+    </ajc-test>
+    
+    <!-- generic ctor itds -->
+    <ajc-test dir="bugs160/simplejava" title="simple - h">
+      <compile files="SimpleH.java" options="-1.9"/>
+    </ajc-test>
+    
+    <!-- overriding generic itd methods -->
+    <ajc-test dir="bugs160/simplejava" title="simple - i">
+      <compile files="SimpleI.java" options="-1.9"/>
+    </ajc-test>
+    
+    <!-- check class file version is 53.0 -->
+    <ajc-test dir="bugs160/simplejava" title="simple - j">
+      <compile files="SimpleJ.java" options="-1.9"/>
+    </ajc-test>
+
+    <!-- check class file version is 53.0 -->
+    <ajc-test dir="bugs160/simplejava" title="simple - k">
+      <compile files="SimpleJ.java" options="-1.9"/>
+    </ajc-test>
+
+    <!-- check class file version is 53.0 -->
+    <ajc-test dir="bugs160/simplejava" title="simple - l">
+      <compile files="SimpleJ.java" options="-1.9"/>
+    </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="-1.9"/>
+    </ajc-test>
+</suite>