diff options
author | avasseur <avasseur> | 2005-12-12 10:48:46 +0000 |
---|---|---|
committer | avasseur <avasseur> | 2005-12-12 10:48:46 +0000 |
commit | 979124d0fe6ac23df1dd5ee41838056bbaed6789 (patch) | |
tree | 6cd8cc92593f67ff29794a49bc35f68d9f25ffec /tests/java5 | |
parent | 0c8c0a3d21365eade6f53a0484bba71f24637a65 (diff) | |
download | aspectj-979124d0fe6ac23df1dd5ee41838056bbaed6789.tar.gz aspectj-979124d0fe6ac23df1dd5ee41838056bbaed6789.zip |
#120351 cflowbelow @AJ and binding
Diffstat (limited to 'tests/java5')
-rw-r--r-- | tests/java5/ataspectj/ataspectj/bugs/CflowBelowStackTest.java | 105 | ||||
-rw-r--r-- | tests/java5/ataspectj/ataspectj/bugs/aop-cflowbelowstacktest.xml | 7 |
2 files changed, 112 insertions, 0 deletions
diff --git a/tests/java5/ataspectj/ataspectj/bugs/CflowBelowStackTest.java b/tests/java5/ataspectj/ataspectj/bugs/CflowBelowStackTest.java new file mode 100644 index 000000000..36810f7cd --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/bugs/CflowBelowStackTest.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * 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: + * Alexandre Vasseur initial implementation + *******************************************************************************/ +package ataspectj.bugs; + +import ataspectj.TestHelper; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.HashMap; +import java.util.Map; + +/** + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +public class CflowBelowStackTest extends TestCase { + + public void testMe() { + assertTrue(true); + } + + public static void main(String[] args) { + TestHelper.runAndThrowOnFailure(suite()); + } + + public static Test suite() { + return new TestSuite(CflowBelowStackTest.class); + } + + + @Aspect + public static class TestAspect { + + @Pointcut("this(testCase) && execution(void test*())") + public void inTestClass(TestCase testCase) { + } + + private Map<String, Map<String, Integer>> coverage; + + @Before("cflowbelow(inTestClass(testCase)) && execution(* *(..))") + public void beforeMethodExecution(JoinPoint thisJoinPoint, TestCase testCase) { + String testname = testCase.getClass().getName(); + String methodSignature = thisJoinPoint.getStaticPart().getSignature().toString(); + Map<String, Integer> tests = coverage.get(methodSignature); + if (tests == null) { + tests = new HashMap<String, Integer>(); + coverage.put(methodSignature, tests); + } + Integer count = tests.get(testname); + if (count == null) { + count = 1; + } else { + count++; + } + tests.put(testname, count); + } + + @Before("inTestClass(testCase)") + public void beforeExecutingTestMethod(TestCase testCase) { + try { + File file = new File("results.ser"); + if (file.exists()) { + ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file)); + coverage = (Map<String, Map<String, Integer>>) ois.readObject(); + ois.close(); + } else { + coverage = new HashMap<String, Map<String, Integer>>(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @After("inTestClass(testCase)") + public void afterExecutingTestMethod(TestCase testCase) { + try { + File file = new File("results.ser"); + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file)); + oos.writeObject(coverage); + oos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} diff --git a/tests/java5/ataspectj/ataspectj/bugs/aop-cflowbelowstacktest.xml b/tests/java5/ataspectj/ataspectj/bugs/aop-cflowbelowstacktest.xml new file mode 100644 index 000000000..076124118 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/bugs/aop-cflowbelowstacktest.xml @@ -0,0 +1,7 @@ +<aspectj> + <weaver options="-1.5 -showWeaveInfo"> + </weaver> + <aspects> + <aspect name="ataspectj.bugs.CflowBelowStackTest.TestAspect"/> + </aspects> +</aspectj>
\ No newline at end of file |