aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.lib/src
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-02-01 12:38:49 -0800
committerAndy Clement <aclement@pivotal.io>2019-02-01 12:38:49 -0800
commit5eec03130695a6b918792ec7b87a2f69a20ed778 (patch)
tree1392ada7a59817400a6b38d5bcb3c3577a7fabfd /org.aspectj.lib/src
parent593e1c772c28577a414c05ae218574b6df88f3e3 (diff)
downloadaspectj-5eec03130695a6b918792ec7b87a2f69a20ed778.tar.gz
aspectj-5eec03130695a6b918792ec7b87a2f69a20ed778.zip
mavenizing org.aspectj.lib - wip
Diffstat (limited to 'org.aspectj.lib/src')
-rw-r--r--org.aspectj.lib/src/main/java/org/aspectj/lib/pointcuts/Pointcuts.java (renamed from org.aspectj.lib/src/org/aspectj/lib/pointcuts/Pointcuts.java)0
-rw-r--r--org.aspectj.lib/src/main/java/org/aspectj/lib/tracing/TraceJoinPoints.java (renamed from org.aspectj.lib/src/org/aspectj/lib/tracing/TraceJoinPoints.java)0
-rw-r--r--org.aspectj.lib/src/main/java/org/aspectj/lib/tracing/TraceJoinPointsBase.java (renamed from org.aspectj.lib/src/org/aspectj/lib/tracing/TraceJoinPointsBase.java)0
-rw-r--r--org.aspectj.lib/src/test/java/org/aspectj/lib/LibModuleTests.java29
-rw-r--r--org.aspectj.lib/src/test/java/org/aspectj/lib/pointcuts/PointcutsTest.java60
-rw-r--r--org.aspectj.lib/src/test/java/org/aspectj/lib/pointcuts/PointcutsTests.java31
-rw-r--r--org.aspectj.lib/src/test/java/org/aspectj/lib/tracing/TraceJoinPointsTest.java83
-rw-r--r--org.aspectj.lib/src/test/java/org/aspectj/lib/tracing/TracingTests.java29
8 files changed, 232 insertions, 0 deletions
diff --git a/org.aspectj.lib/src/org/aspectj/lib/pointcuts/Pointcuts.java b/org.aspectj.lib/src/main/java/org/aspectj/lib/pointcuts/Pointcuts.java
index fd96bf908..fd96bf908 100644
--- a/org.aspectj.lib/src/org/aspectj/lib/pointcuts/Pointcuts.java
+++ b/org.aspectj.lib/src/main/java/org/aspectj/lib/pointcuts/Pointcuts.java
diff --git a/org.aspectj.lib/src/org/aspectj/lib/tracing/TraceJoinPoints.java b/org.aspectj.lib/src/main/java/org/aspectj/lib/tracing/TraceJoinPoints.java
index 6d6f592df..6d6f592df 100644
--- a/org.aspectj.lib/src/org/aspectj/lib/tracing/TraceJoinPoints.java
+++ b/org.aspectj.lib/src/main/java/org/aspectj/lib/tracing/TraceJoinPoints.java
diff --git a/org.aspectj.lib/src/org/aspectj/lib/tracing/TraceJoinPointsBase.java b/org.aspectj.lib/src/main/java/org/aspectj/lib/tracing/TraceJoinPointsBase.java
index 989c298e7..989c298e7 100644
--- a/org.aspectj.lib/src/org/aspectj/lib/tracing/TraceJoinPointsBase.java
+++ b/org.aspectj.lib/src/main/java/org/aspectj/lib/tracing/TraceJoinPointsBase.java
diff --git a/org.aspectj.lib/src/test/java/org/aspectj/lib/LibModuleTests.java b/org.aspectj.lib/src/test/java/org/aspectj/lib/LibModuleTests.java
new file mode 100644
index 000000000..6a666b2c1
--- /dev/null
+++ b/org.aspectj.lib/src/test/java/org/aspectj/lib/LibModuleTests.java
@@ -0,0 +1,29 @@
+package org.aspectj.lib;
+/* *******************************************************************
+ * Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
+ * ******************************************************************/
+
+// default package
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class LibModuleTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(LibModuleTests.class.getName());
+ suite.addTest(org.aspectj.lib.pointcuts.PointcutsTests.suite());
+ suite.addTest(org.aspectj.lib.tracing.TracingTests.suite());
+ return suite;
+ }
+
+}
diff --git a/org.aspectj.lib/src/test/java/org/aspectj/lib/pointcuts/PointcutsTest.java b/org.aspectj.lib/src/test/java/org/aspectj/lib/pointcuts/PointcutsTest.java
new file mode 100644
index 000000000..7cc082a51
--- /dev/null
+++ b/org.aspectj.lib/src/test/java/org/aspectj/lib/pointcuts/PointcutsTest.java
@@ -0,0 +1,60 @@
+/* *******************************************************************
+ * Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
+ * ******************************************************************/
+
+package org.aspectj.lib.pointcuts;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class PointcutsTest extends TestCase {
+
+ public void test_anyPublicMethodExecution() {
+ try {
+ Test_anyPublicMethodExecution.error();
+ assertTrue("no exception thrown", false);
+ } catch (Error e) {
+ // ok, advice worked
+ }
+ }
+
+ private static aspect Test_anyPublicMethodExecution {
+ public static void error() {
+ throw new RuntimeException("wrong exception");
+ }
+
+ static void nonpublic() {}
+
+ before() :
+ execution(static void Test_anyPublicMethodExecution.error())
+ && Pointcuts.anyPublicMethodExecution() {
+ throw new Error("");
+ }
+
+ declare error :
+ execution(static void Test_anyPublicMethodExecution.nonpublic())
+ && Pointcuts.anyPublicMethodExecution()
+ : "anyPublicMethodExecution failed - not public";
+
+ }
+ private static aspect compileChecks {
+ /** balk if Pointcuts has code - s.b. only pointcuts */
+ declare error : within(Pointcuts) &&
+ (set(* *) || Pointcuts.anyMethodExecution() ||
+ (Pointcuts.anyConstructorExecution()
+ && !execution(private Pointcuts.new()))) :
+ "only pointcuts permitted in Pointcuts";
+
+
+ }
+}
diff --git a/org.aspectj.lib/src/test/java/org/aspectj/lib/pointcuts/PointcutsTests.java b/org.aspectj.lib/src/test/java/org/aspectj/lib/pointcuts/PointcutsTests.java
new file mode 100644
index 000000000..3844804fb
--- /dev/null
+++ b/org.aspectj.lib/src/test/java/org/aspectj/lib/pointcuts/PointcutsTests.java
@@ -0,0 +1,31 @@
+/* *******************************************************************
+ * Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
+ * ******************************************************************/
+
+package org.aspectj.lib.pointcuts;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class PointcutsTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(PointcutsTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(PointcutsTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+ public PointcutsTests(String name) { super(name); }
+
+}
diff --git a/org.aspectj.lib/src/test/java/org/aspectj/lib/tracing/TraceJoinPointsTest.java b/org.aspectj.lib/src/test/java/org/aspectj/lib/tracing/TraceJoinPointsTest.java
new file mode 100644
index 000000000..75b27d472
--- /dev/null
+++ b/org.aspectj.lib/src/test/java/org/aspectj/lib/tracing/TraceJoinPointsTest.java
@@ -0,0 +1,83 @@
+/* *******************************************************************
+ * Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.lib.tracing;
+
+import junit.framework.TestCase;
+
+import org.aspectj.lang.JoinPoint.StaticPart;
+
+/**
+ *
+ */
+public class TraceJoinPointsTest extends TestCase {
+
+ public void testTraceJoinPoints() {
+ checkTjp();
+ TestTJP aspect = TestTJP.aspectOf();
+ assertNotNull("aspect", aspect);
+ assertTrue("checked", aspect.checked);
+ }
+
+ static final int NUMJP = 1;
+
+ static void checkTjp() {
+ // NUMJP: only 1 join point
+ long l = System.currentTimeMillis();
+ }
+
+ /** poor design/test */
+ static aspect TestTJP extends TraceJoinPoints {
+
+ protected pointcut withinScope() : within(TraceJoinPointsTest)
+ && !within(TestTJP);
+ pointcut traceJoinPoints() :
+ execution(static void TraceJoinPointsTest.testTraceJoinPoints());
+
+ protected pointcut entry() :
+ execution(static void TraceJoinPointsTest.checkTjp());
+
+ boolean checked;
+ int logEnter = 10;
+ int logExit = 10;
+ int startLog = 10;
+ int completeLog = 10;
+ protected void logEnter(StaticPart jp) {
+ logEnter++;
+ }
+
+ protected void logExit(StaticPart jp) {
+ logExit++;
+ }
+
+ protected void startLog() {
+ startLog = 0;
+ completeLog = 0;
+ logEnter = 0;
+ logExit = 0;
+ startLog++;
+ }
+
+ protected void completeLog() {
+ completeLog++;
+ }
+ after() returning : entry() {
+ assertEquals("startLog", 1, startLog);
+ assertEquals("completeLog", 1, startLog);
+ assertEquals("logExit", NUMJP, startLog);
+ assertEquals("logEntry", NUMJP, startLog);
+ assertTrue(!checked);
+ checked = true;
+ }
+ }
+}
diff --git a/org.aspectj.lib/src/test/java/org/aspectj/lib/tracing/TracingTests.java b/org.aspectj.lib/src/test/java/org/aspectj/lib/tracing/TracingTests.java
new file mode 100644
index 000000000..9f4daafe0
--- /dev/null
+++ b/org.aspectj.lib/src/test/java/org/aspectj/lib/tracing/TracingTests.java
@@ -0,0 +1,29 @@
+/* *******************************************************************
+ * Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
+ * ******************************************************************/
+
+package org.aspectj.lib.tracing;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TracingTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(TracingTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TraceJoinPointsTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}