]> source.dussan.org Git - aspectj.git/commitdiff
89009: joinpoint ids
authoraclement <aclement>
Tue, 24 Mar 2009 22:06:08 +0000 (22:06 +0000)
committeraclement <aclement>
Tue, 24 Mar 2009 22:06:08 +0000 (22:06 +0000)
tests/features164/joinpointid/Driver.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc164/AllTestsAspectJ164.java
tests/src/org/aspectj/systemtest/ajc164/JointpointIdTests.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc164/joinpointid.xml [new file with mode: 0644]

diff --git a/tests/features164/joinpointid/Driver.java b/tests/features164/joinpointid/Driver.java
new file mode 100644 (file)
index 0000000..998087a
--- /dev/null
@@ -0,0 +1,26 @@
+public class Driver {
+  public static void main(String[]argv) {
+    new A().mone();
+    new A().mtwo();
+    new A().mone();
+    new A().mtwo();
+    new A().mone();
+    new A().mtwo();
+  }
+} 
+
+class A {
+  public void mone() {}
+  public void mtwo() {}
+}
+
+aspect X pertypewithin(*) {
+
+  int[] state = new int[5];
+
+  before(): execution(* A.*(..)) {
+    int id = thisJoinPointStaticPart.getId();
+    System.out.println("At "+thisJoinPoint.getSignature()+" id="+id+" state="+state[id]);
+    state[id]++;
+  }
+}
index 51f0a5c468f65811a7cab956d141b97a78699f23..1cd45e428140cdeb643ba466bb7cce5438c29164 100644 (file)
@@ -20,6 +20,7 @@ public class AllTestsAspectJ164 {
                // $JUnit-BEGIN$
                suite.addTest(Ajc164Tests.suite());
                suite.addTest(DeclareMixinTests.suite());
+               suite.addTest(JointpointIdTests.suite());
                // $JUnit-END$
                return suite;
        }
diff --git a/tests/src/org/aspectj/systemtest/ajc164/JointpointIdTests.java b/tests/src/org/aspectj/systemtest/ajc164/JointpointIdTests.java
new file mode 100644 (file)
index 0000000..32716e6
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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.ajc164;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * 
+ * @author Andy Clement
+ */
+public class JointpointIdTests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+       public void testCaseA() {
+               runTest("casea");
+       }
+
+       // --
+
+       public static Test suite() {
+               return XMLBasedAjcTestCase.loadSuite(JointpointIdTests.class);
+       }
+
+       protected File getSpecFile() {
+               return new File("../tests/src/org/aspectj/systemtest/ajc164/joinpointid.xml");
+       }
+
+}
\ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/ajc164/joinpointid.xml b/tests/src/org/aspectj/systemtest/ajc164/joinpointid.xml
new file mode 100644 (file)
index 0000000..6f2bdc7
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+   
+   <ajc-test dir="features164/joinpointid" title="casea">
+     <compile files="Driver.java" options="-1.5"/>
+     <run class="Driver">
+       <stdout>
+         <line text="At void A.mone() id=0 state=0"/>
+         <line text="At void A.mtwo() id=1 state=0"/>
+         <line text="At void A.mone() id=0 state=1"/>
+         <line text="At void A.mtwo() id=1 state=1"/>
+         <line text="At void A.mone() id=0 state=2"/>
+         <line text="At void A.mtwo() id=1 state=2"/>
+       </stdout>
+     </run>
+   </ajc-test>
+   
+</suite>
\ No newline at end of file