From: aclement Date: Tue, 3 Mar 2009 19:12:58 +0000 (+0000) Subject: fb X-Git-Tag: pre268419~49 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7c7a3c616e3d41049750737c817587e6c8eb6a71;p=aspectj.git fb --- diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/MegaZipTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/MegaZipTestCase.java index d21ab6b78..ce1b07348 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/MegaZipTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/MegaZipTestCase.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.bcel; import java.io.File; @@ -28,98 +27,75 @@ import org.aspectj.weaver.UnresolvedType; public class MegaZipTestCase extends WeaveTestCase { - private File outDir; + private File outDir; public MegaZipTestCase(String arg0) { super(arg0); } - public void setUp() { - outDir = BcweaverTests.getOutdir(); - } - - public void tearDown() { - BcweaverTests.removeOutDir(); - outDir = null; - } - - - private BcelAdvice makeAroundMunger(final boolean matchOnlyPrintln) { - // BcelWorld world = new BcelWorld(); - final Member sig = - MemberImpl.method( - UnresolvedType.forName("fluffy.Aspect"), - Modifier.STATIC, - "aroundFun", - "(Lorg/aspectj/runtime/internal/AroundClosure;)Ljava/lang/Object;"); - - return new BcelAdvice( - AdviceKind.stringToKind("around"), - matchOnlyPrintln ? makePointcutPrintln() : makePointcutAll(), - sig, 0, -1, -1, null, null) - { - public void specializeOn(Shadow s) { - super.specializeOn(s); - ((BcelShadow) s).initializeForAroundClosure(); - } - }; - } + public void setUp() throws Exception { + super.setUp(); + outDir = BcweaverTests.getOutdir(); + } + + public void tearDown() throws Exception { + super.tearDown(); + BcweaverTests.removeOutDir(); + outDir = null; + } + + private BcelAdvice makeAroundMunger(final boolean matchOnlyPrintln) { + // BcelWorld world = new BcelWorld(); + final Member sig = MemberImpl.method(UnresolvedType.forName("fluffy.Aspect"), Modifier.STATIC, "aroundFun", + "(Lorg/aspectj/runtime/internal/AroundClosure;)Ljava/lang/Object;"); + + return new BcelAdvice(AdviceKind.stringToKind("around"), matchOnlyPrintln ? makePointcutPrintln() : makePointcutAll(), sig, + 0, -1, -1, null, null) { + public void specializeOn(Shadow s) { + super.specializeOn(s); + ((BcelShadow) s).initializeForAroundClosure(); + } + }; + } public List getShadowMungers() { - List ret = new ArrayList(); - ret.add( - makeConcreteAdvice( - "before" - + "(): call(* *.println(..)) -> static void fluffy.Aspect.before_method_call()")); - ret.add( - makeConcreteAdvice( - "afterReturning" - + "(): call(* *.println(..)) -> static void fluffy.Aspect.afterReturning_method_call()")); - - ret.add( - makeConcreteAdvice( - "before" - + "(): execution(* *.*(..)) -> static void fluffy.Aspect.ignoreMe()")); - - ret.add( - makeConcreteAdvice( - "afterReturning" - + "(): execution(* *.*(..)) -> static void fluffy.Aspect.ignoreMe()")); - - ret.add( - makeConcreteAdvice( - "afterThrowing" - + "(): execution(* *.*(..)) -> static void fluffy.Aspect.afterThrowing_method_execution(java.lang.Throwable)", - 1)); - ret.add( - makeConcreteAdvice( - "after" - + "(): execution(* *.*(..)) -> static void fluffy.Aspect.ignoreMe()")); - - - ret.add(makeAroundMunger(true)); + List ret = new ArrayList(); + ret.add(makeConcreteAdvice("before" + "(): call(* *.println(..)) -> static void fluffy.Aspect.before_method_call()")); + ret.add(makeConcreteAdvice("afterReturning" + + "(): call(* *.println(..)) -> static void fluffy.Aspect.afterReturning_method_call()")); + + ret.add(makeConcreteAdvice("before" + "(): execution(* *.*(..)) -> static void fluffy.Aspect.ignoreMe()")); + + ret.add(makeConcreteAdvice("afterReturning" + "(): execution(* *.*(..)) -> static void fluffy.Aspect.ignoreMe()")); + + ret.add(makeConcreteAdvice("afterThrowing" + + "(): execution(* *.*(..)) -> static void fluffy.Aspect.afterThrowing_method_execution(java.lang.Throwable)", 1)); + ret.add(makeConcreteAdvice("after" + "(): execution(* *.*(..)) -> static void fluffy.Aspect.ignoreMe()")); + + ret.add(makeAroundMunger(true)); return ret; } - public void zipTest(String fileName) throws IOException { long startTime = System.currentTimeMillis(); File inFile = new File(BcweaverTests.TESTDATA_PATH, fileName); File outFile = new File(outDir, fileName); outFile.delete(); - + world = new BcelWorld("c:/apps/java-1.3.1_04/lib/tools.jar"); BcelWeaver weaver1 = new BcelWeaver(world); - ZipFileWeaver weaver = new ZipFileWeaver(inFile); weaver1.setShadowMungers(getShadowMungers()); weaver.weave(weaver1, outFile); assertTrue(outFile.lastModified() > startTime); - } - public void testEmptyForAntJUnit(){} + } + + public void testEmptyForAntJUnit() { + } + // this is something we test every now and again. // to try, rename as testBig and put aspectjtools.jar in testdata public void trytestBig() throws IOException { diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java index 36a09605e..4e5ff2363 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.bcel; import java.io.IOException; @@ -30,81 +29,70 @@ public class TjpWeaveTestCase extends WeaveTestCase { public TjpWeaveTestCase(String name) { super(name); } - - public void setUp() { + + public void setUp() throws Exception { super.setUp(); - behave15=true; + behave15 = true; } public void tearDown() throws Exception { super.tearDown(); - behave15=false; + behave15 = false; } - - - public void testStaticTjp() throws IOException { - BcelAdvice munger = new BcelAdvice( - AdviceKind.stringToKind("before"), - makePointcutAll(), - TestUtils.methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint$StaticPart)"), - Advice.ThisJoinPointStaticPart, -1, -1, null, null); - - weaveTest("HelloWorld", "StaticTjpBeforeHelloWorld", munger); - } - - - public void testEnclosingStaticTjp() throws IOException { - BcelAdvice munger = new BcelAdvice( - AdviceKind.stringToKind("before"), - makePointcutAll(), - TestUtils.methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint$StaticPart)"), - Advice.ThisEnclosingJoinPointStaticPart, -1, -1, null, null); - - weaveTest("HelloWorld", "StaticEnclosingTjpBeforeHelloWorld", munger); - } - - - public void testTjp() throws IOException { - BcelAdvice munger = new BcelAdvice( - AdviceKind.stringToKind("before"), - makePointcutAll(), - TestUtils.methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint)"), - Advice.ThisJoinPoint, -1, -1, null, null); - - weaveTest("HelloWorld", "TjpBeforeHelloWorld", munger); - } - - public void testAroundTjp() throws IOException { - BcelAdvice munger = new BcelAdvice( - AdviceKind.stringToKind("around"), - makePointcutAll(), - TestUtils.methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"), - Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, null); - - weaveTest("HelloWorld", "TjpAroundHelloWorld", munger); - } - - public void testAround2Tjp() throws IOException { - ResolvedType rtx = world.resolve(UnresolvedType.forName("Aspect"),true); - assertTrue("Couldnt find type Aspect",!rtx.isMissing()); - BcelAdvice munger1 = new BcelAdvice( - AdviceKind.stringToKind("around"), - makePointcutAll(), - TestUtils.methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"), - Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, - rtx); - - BcelAdvice munger2 = new BcelAdvice( - AdviceKind.stringToKind("around"), - makePointcutAll(), - TestUtils.methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"), - Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, - rtx); - - weaveTest("HelloWorld", "TjpAround2HelloWorld", Arrays.asList(new BcelAdvice[] {munger1, munger2})); - } + public void testStaticTjp() throws IOException { + BcelAdvice munger = new BcelAdvice(AdviceKind.stringToKind("before"), makePointcutAll(), TestUtils + .methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint$StaticPart)"), + Advice.ThisJoinPointStaticPart, -1, -1, null, null); + + weaveTest("HelloWorld", "StaticTjpBeforeHelloWorld", munger); + } + + public void testEnclosingStaticTjp() throws IOException { + BcelAdvice munger = new BcelAdvice(AdviceKind.stringToKind("before"), makePointcutAll(), TestUtils + .methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint$StaticPart)"), + Advice.ThisEnclosingJoinPointStaticPart, -1, -1, null, null); + + weaveTest("HelloWorld", "StaticEnclosingTjpBeforeHelloWorld", munger); + } + public void testTjp() throws IOException { + BcelAdvice munger = new BcelAdvice(AdviceKind.stringToKind("before"), makePointcutAll(), TestUtils + .methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint)"), Advice.ThisJoinPoint, -1, -1, null, + null); + weaveTest("HelloWorld", "TjpBeforeHelloWorld", munger); + } + + public void testAroundTjp() throws IOException { + BcelAdvice munger = new BcelAdvice( + AdviceKind.stringToKind("around"), + makePointcutAll(), + TestUtils + .methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"), + Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, null); + + weaveTest("HelloWorld", "TjpAroundHelloWorld", munger); + } + + public void testAround2Tjp() throws IOException { + ResolvedType rtx = world.resolve(UnresolvedType.forName("Aspect"), true); + assertTrue("Couldnt find type Aspect", !rtx.isMissing()); + BcelAdvice munger1 = new BcelAdvice( + AdviceKind.stringToKind("around"), + makePointcutAll(), + TestUtils + .methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"), + Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, rtx); + + BcelAdvice munger2 = new BcelAdvice( + AdviceKind.stringToKind("around"), + makePointcutAll(), + TestUtils + .methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"), + Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, rtx); + + weaveTest("HelloWorld", "TjpAround2HelloWorld", Arrays.asList(new BcelAdvice[] { munger1, munger2 })); + } } diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java index 656020656..8b02d4a2a 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java @@ -60,7 +60,7 @@ public abstract class WeaveTestCase extends TestCase { super(name); } - public void setUp() { + public void setUp() throws Exception { outDir = BcweaverTests.getOutdir(); outDirPath = outDir.getAbsolutePath(); }