From: aclement Date: Tue, 8 Jun 2010 22:57:19 +0000 (+0000) Subject: generics and ITD inner class updates X-Git-Tag: V1_6_9RC2~35 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=80136da5b557b8deb4522710136d1f169a83ac73;p=aspectj.git generics and ITD inner class updates --- diff --git a/tests/src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java b/tests/src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java index 909c100a3..7c0d26d4c 100644 --- a/tests/src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java +++ b/tests/src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java @@ -28,66 +28,70 @@ import org.aspectj.weaver.CustomMungerFactory; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.ResolvedTypeMunger; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.ShadowMunger; import org.aspectj.weaver.World; import org.aspectj.weaver.patterns.DeclareErrorOrWarning; import org.aspectj.weaver.patterns.IfPointcut; import org.aspectj.weaver.patterns.Pointcut; public class CustomMungerExtensionTest extends AjdeInteractionTestbed { - - File oldSandBoxDir; - - protected void setUp() throws Exception { - super.setUp(); - oldSandBoxDir = sandboxDir; - sandboxDir = new File("../tests"); - } - - protected void tearDown() throws Exception { - super.tearDown(); - sandboxDir = oldSandBoxDir; - } - + + File oldSandBoxDir; + + protected void setUp() throws Exception { + super.setUp(); + oldSandBoxDir = sandboxDir; + sandboxDir = new File("../tests"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + sandboxDir = oldSandBoxDir; + } + public void testExtension() { String testFileDir = "bugs/pointcutdoctor-bug193065"; AjCompiler compiler = getCompilerForProjectWithName(testFileDir); compiler.setCustomMungerFactory(new DumbCustomMungerFactory()); doBuild(testFileDir); - - CustomMungerFactory factory = (CustomMungerFactory)compiler.getCustomMungerFactory(); - assertTrue(factory.getAllCreatedCustomShadowMungers().size()>0); - for (Iterator i = factory.getAllCreatedCustomShadowMungers().iterator(); i.hasNext();) - assertTrue(((DumbShadowMunger)i.next()).called); - - assertTrue(factory.getAllCreatedCustomTypeMungers().size()>0); - for (Iterator i = factory.getAllCreatedCustomTypeMungers().iterator(); i.hasNext();) - assertTrue(((DumbTypeMunger)i.next()).called); + + CustomMungerFactory factory = (CustomMungerFactory) compiler.getCustomMungerFactory(); + assertTrue(factory.getAllCreatedCustomShadowMungers().size() > 0); + for (Iterator i = factory.getAllCreatedCustomShadowMungers().iterator(); i.hasNext();) { + assertTrue(((DumbShadowMunger) i.next()).called); + } + + assertTrue(factory.getAllCreatedCustomTypeMungers().size() > 0); + for (Iterator i = factory.getAllCreatedCustomTypeMungers().iterator(); i.hasNext();) { + assertTrue(((DumbTypeMunger) i.next()).called); + } } - + class DumbCustomMungerFactory implements CustomMungerFactory { - Collection allShadowMungers = new ArrayList(); - Collection allTypeMungers = new ArrayList(); - public Collection createCustomShadowMungers(ResolvedType aspectType) { - List/* ShadowMunger */ mungers = new ArrayList/*ShadowMunger*/(); + Collection allShadowMungers = new ArrayList(); + Collection allTypeMungers = new ArrayList(); + + public Collection createCustomShadowMungers(ResolvedType aspectType) { + List mungers = new ArrayList(); Pointcut pointcut = new IfPointcut("abc"); mungers.add(new DumbShadowMunger(new DeclareErrorOrWarning(false, pointcut, ""))); allShadowMungers.addAll(mungers); return mungers; } - public Collection createCustomTypeMungers(ResolvedType aspectType) { - List/*ConcreteTypeMunger*/ mungers = new ArrayList/*ShadowMunger*/(); + public Collection createCustomTypeMungers(ResolvedType aspectType) { + List mungers = new ArrayList(); mungers.add(new DumbTypeMunger(null, aspectType)); allTypeMungers.addAll(mungers); return mungers; } - public Collection getAllCreatedCustomShadowMungers() { + public Collection getAllCreatedCustomShadowMungers() { return allShadowMungers; } - public Collection getAllCreatedCustomTypeMungers() { + public Collection getAllCreatedCustomTypeMungers() { return allTypeMungers; } } @@ -119,14 +123,13 @@ public class CustomMungerExtensionTest extends AjdeInteractionTestbed { public ConcreteTypeMunger parameterizedFor(ResolvedType targetType) { return null; } - + public boolean matches(ResolvedType onType) { called = true; return false; } - public ConcreteTypeMunger parameterizeWith(Map parameterizationMap, - World world) { + public ConcreteTypeMunger parameterizeWith(Map parameterizationMap, World world) { // TODO Auto-generated method stub return null; } diff --git a/tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java b/tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java index 6a002a782..4772d4b2b 100644 --- a/tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java +++ b/tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java @@ -7,13 +7,16 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc169; +import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.PrintWriter; import junit.framework.Test; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.util.ClassPath; import org.aspectj.apache.bcel.util.SyntheticRepository; +import org.aspectj.asm.AsmManager; import org.aspectj.testing.XMLBasedAjcTestCase; /** @@ -36,6 +39,33 @@ public class IntertypeTests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("choice"); } + public void testRooScenario2() throws Exception { + runTest("choice2"); + } + + public void testRooScenarioWeaveInfo() throws Exception { + runTest("choice - weaveinfo"); + } + + public void testModel() throws Exception { + runTest("choice - model"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintWriter pw = new PrintWriter(baos); + AsmManager.dumptree(pw, AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); + pw.write(AsmManager.lastActiveStructureModel.getRelationshipMap().toString()); + pw.flush(); + String model = baos.toString(); + assertTrue(model.indexOf("<{Choice.java[Choice=[aspect declarations], <{Choice.java}X[Keys=[declared on]") != -1); + } + + public void testGenerics1() throws Exception { + runTest("choice - generics 1"); + } + + public void testGenerics2() throws Exception { + runTest("choice - generics 2"); + } + // compiler limitation tests public void testNotAllowedOnInterface() throws Exception { runTest("on interface"); diff --git a/tests/src/org/aspectj/systemtest/ajc169/intertype.xml b/tests/src/org/aspectj/systemtest/ajc169/intertype.xml index bac60086a..2cbb61190 100644 --- a/tests/src/org/aspectj/systemtest/ajc169/intertype.xml +++ b/tests/src/org/aspectj/systemtest/ajc169/intertype.xml @@ -2,6 +2,16 @@ + + + + + + + + + + @@ -10,6 +20,24 @@ + + + + + + + + + + + + + + + + + +