* PARC initial implementation
* ******************************************************************/
-
package org.aspectj.weaver.bcel;
import java.io.File;
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 {
* PARC initial implementation
* ******************************************************************/
-
package org.aspectj.weaver.bcel;
import java.io.IOException;
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 }));
+ }
}