]> source.dussan.org Git - aspectj.git/commitdiff
fb
authoraclement <aclement>
Tue, 3 Mar 2009 19:12:58 +0000 (19:12 +0000)
committeraclement <aclement>
Tue, 3 Mar 2009 19:12:58 +0000 (19:12 +0000)
weaver/testsrc/org/aspectj/weaver/bcel/MegaZipTestCase.java
weaver/testsrc/org/aspectj/weaver/bcel/TjpWeaveTestCase.java
weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java

index d21ab6b7821124df2decebb850636a4affeb78d6..ce1b073489f771cd3c83a11c0b25129939ff5513 100644 (file)
@@ -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 {
index 36a09605e13eec895f5745a03f0903100f8e6282..4e5ff23635cff2d7004843e69cae3217960c8430 100644 (file)
@@ -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 }));
+       }
 
 }
index 6560206561f1cc6b55345ab44451d8441947c786..8b02d4a2a3faf6a24148ea45e2ee4169967360c6 100644 (file)
@@ -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();
        }