diff options
author | mkersten <mkersten> | 2003-08-14 17:18:34 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-08-14 17:18:34 +0000 |
commit | 56d4d719ba6e1ff20efe3f1003aa8eec8d5b88a2 (patch) | |
tree | 98aed82a88fcdef2d0aaf660ce44f9ec8bb8896d /ajde/testsrc | |
parent | b5d8b449c79cbedc82e03381cc459ae8c8ae9718 (diff) | |
download | aspectj-56d4d719ba6e1ff20efe3f1003aa8eec8d5b88a2.tar.gz aspectj-56d4d719ba6e1ff20efe3f1003aa8eec8d5b88a2.zip |
Improved declare relationships. Implemented batch-build relationship clearing policy.
Diffstat (limited to 'ajde/testsrc')
-rw-r--r-- | ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java index db82a96cf..85df30d08 100644 --- a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java +++ b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java @@ -11,10 +11,9 @@ package org.aspectj.ajde; -import java.util.List; +import java.util.Iterator; import org.aspectj.asm.*; -import org.aspectj.asm.internal.ProgramElement; // TODO: check for return types public class AsmRelationshipsTest extends AjdeTestCase { @@ -27,29 +26,40 @@ public class AsmRelationshipsTest extends AjdeTestCase { } public void testInterTypeDeclarations() { -// checkMapping("InterTypeDecCoverage", "Point", "Point.xxx", "xxx", "declared on", "aspect declarations"); -// checkMapping("InterTypeDecCoverage", "Point", "Point.check(int, Line)", "Point", "declared on", "aspect declarations"); - + checkInterTypeMapping("InterTypeDecCoverage", "Point", "Point.xxx", "Point", + "declared on", "aspect declarations", IProgramElement.Kind.INTER_TYPE_FIELD); + checkInterTypeMapping("InterTypeDecCoverage", "Point", "Point.check(int, Line)", + "Point", "declared on", "aspect declarations", IProgramElement.Kind.INTER_TYPE_METHOD); } public void testAdvice() { - checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..", "setX(int)", "advises", "advised by"); - checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): getP..", "field-get(int Point.x)", "advises"); - checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): setP..", "field-set(int Point.xxx)", "advises"); + checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..", + "setX(int)", "advises", "advised by"); + checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): getP..", + "field-get(int Point.x)", "advises"); + checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): setP..", + "field-set(int Point.x)", "advises"); } - private void checkUniDirectionalMapping(String fromType, String toType, String from, String to, String relName) { + private void checkUniDirectionalMapping(String fromType, String toType, String from, + String to, String relName) { + IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType); assertNotNull(aspect); String beforeExec = from; IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec); assertNotNull(beforeExecNode); IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, relName); - String handle = (String)rel.getTargets().get(0); - assertEquals(manager.getHierarchy().findElementForHandle(handle).toLabelString(), to); + for (Iterator it = rel.getTargets().iterator(); it.hasNext(); ) { + String currHandle = (String)it.next(); + if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(to)) return; + } + fail(); // didn't find it } - private void checkMapping(String fromType, String toType, String from, String to, String forwardRelName, String backRelName) { + private void checkMapping(String fromType, String toType, String from, String to, + String forwardRelName, String backRelName) { + IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType); assertNotNull(aspect); String beforeExec = from; @@ -69,6 +79,30 @@ public class AsmRelationshipsTest extends AjdeTestCase { assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from); } + private void checkInterTypeMapping(String fromType, String toType, String from, + String to, String forwardRelName, String backRelName, IProgramElement.Kind declareKind) { + + IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType); + assertNotNull(aspect); + String beforeExec = from; + IProgramElement fromNode = manager.getHierarchy().findElementForLabel(aspect, declareKind, beforeExec); + assertNotNull(fromNode); + IRelationship rel = manager.getRelationshipMap().get(fromNode, IRelationship.Kind.DECLARE_INTER_TYPE, forwardRelName); + String handle = (String)rel.getTargets().get(0); + assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to); + + IProgramElement clazz = AsmManager.getDefault().getHierarchy().findElementForType(null, toType); + assertNotNull(clazz); + String set = to; + IRelationship rel2 = manager.getRelationshipMap().get(clazz, IRelationship.Kind.DECLARE_INTER_TYPE, backRelName); + String handle2 = (String)rel2.getTargets().get(0); + for (Iterator it = rel2.getTargets().iterator(); it.hasNext(); ) { + String currHandle = (String)it.next(); + if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(from)) return; + } + fail(); // didn't find it + } + protected void setUp() throws Exception { super.setUp("examples"); assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH)); |