[jboss-cvs] JBossAS SVN: r88399 - in projects/aop/trunk/aop/src: resources/test/arguments and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 8 01:30:32 EDT 2009


Author: flavia.rainone at jboss.com
Date: 2009-05-08 01:30:32 -0400 (Fri, 08 May 2009)
New Revision: 88399

Added:
   projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/SortedCFlowInterceptor.java
Modified:
   projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/CFlowInterceptor.java
   projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/PrecedenceSorter.java
   projects/aop/trunk/aop/src/resources/test/arguments/jboss-aop.xml
   projects/aop/trunk/aop/src/resources/test/precedence/jboss-aop.xml
   projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/precedence/POJO.java
   projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/precedence/PrecedenceTester.java
Log:
[JBAOP-728] Created the SortedCFlowInterceptor class, that holds all cflow expressions and interceptors belonging to a chain, making sure the interceptors are invoked in the precedence-sorted order.
Added tests that reproduce the bug to precedence package and uncommented the precedence declaration for the arguments tests.

Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/CFlowInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/CFlowInterceptor.java	2009-05-08 04:51:19 UTC (rev 88398)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/CFlowInterceptor.java	2009-05-08 05:30:32 UTC (rev 88399)
@@ -48,7 +48,17 @@
    {
       return "CFlowInterceptor";
    }
+   
+   Interceptor[] getChain()
+   {
+      return this.chain;
+   }
 
+   ASTCFlowExpression getExpr()
+   {
+      return this.expr;
+   }
+   
    public String getCFlowString()
    {
       return cflowString;

Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/PrecedenceSorter.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/PrecedenceSorter.java	2009-05-08 04:51:19 UTC (rev 88398)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/PrecedenceSorter.java	2009-05-08 05:30:32 UTC (rev 88399)
@@ -29,6 +29,7 @@
 import java.util.Map;
 
 import org.jboss.aop.AspectManager;
+import org.jboss.aop.pointcut.ast.ASTCFlowExpression;
 import org.jboss.aop.util.logging.AOPLogger;
 
 /**
@@ -54,6 +55,7 @@
    static class InterceptorEntry
    {
       Interceptor interceptor;
+      ASTCFlowExpression cflow;
       GeneratedAdvisorInterceptor factoryWrapper;
       int originalOrder;
       int precedenceOrder = -1;
@@ -131,6 +133,12 @@
             throw e;
          }
       }
+      
+      InterceptorEntry(Interceptor interceptor, ASTCFlowExpression cflow)
+      {
+         this(interceptor);
+         this.cflow = cflow;
+      }
 
       public String toString()
       {
@@ -235,28 +243,51 @@
       ArrayList<InterceptorEntry> all = new ArrayList<InterceptorEntry>(interceptors.length);
       ArrayList<InterceptorEntry> precedence = new ArrayList<InterceptorEntry>(interceptors.length);
       PrecedenceDefEntry[] precedenceEntries = manager.getSortedPrecedenceDefEntries();
-
+      boolean cflowFound = false;
       //Figure out what interceptors have precedence
       for (int i = 0 ; i < interceptors.length ; i++)
       {
-         InterceptorEntry interceptorEntry = new InterceptorEntry(interceptors[i]);
-         all.add(interceptorEntry);
-         for (int j = 0 ; j < precedenceEntries.length ; j++)
+         InterceptorEntry[] interceptorEntries;
+         ASTCFlowExpression cflow = null;
+         // Break cflow interceptor into separate interceptor units
+         if (interceptors[i] instanceof CFlowInterceptor)
          {
-            if (matches(interceptorEntry, precedenceEntries[j]))
+            cflowFound = true;
+            CFlowInterceptor cflowInterceptor = (CFlowInterceptor) interceptors[i];
+            cflow = cflowInterceptor.getExpr();
+            interceptorEntries = new InterceptorEntry[cflowInterceptor.getChain().length];
+            for (int j = 0; j < interceptorEntries.length; j++)
             {
-               //This interceptor is defined in the precedence
-               interceptorEntry.originalOrder = i;
-               interceptorEntry.precedenceOrder = j;
-               precedence.add(interceptorEntry);
-               break;
+               interceptorEntries[j] = new InterceptorEntry(cflowInterceptor.getChain()[j], cflow);
+               all.add(interceptorEntries[j]);
             }
          }
+         else
+         {
+            interceptorEntries = new InterceptorEntry[]{new InterceptorEntry(interceptors[i])};
+            all.add(interceptorEntries[0]);
+         }
+         for (int k = 0; k < interceptorEntries.length; k++)
+         {
+            InterceptorEntry interceptorEntry = interceptorEntries[k];
+            for (int j = 0 ; j < precedenceEntries.length ; j++)
+            {
+               if (matches(interceptorEntry, precedenceEntries[j]))
+               {
+                  //This interceptor is defined in the precedence
+                  interceptorEntry.originalOrder = all.size() - interceptorEntries.length + k;
+                  interceptorEntry.precedenceOrder = j;
+                  precedence.add(interceptorEntry);
+                  break;
+               }
+            }
+         }
       }
 
       //Sort the interceptors having precedence
       Collections.sort(precedence, interceptorComparator);
-      Interceptor[] sortedInterceptors = new Interceptor[interceptors.length];
+      Interceptor[] sortedInterceptors = new Interceptor[all.size()];
+      ASTCFlowExpression[] sortedCFlows = new ASTCFlowExpression[all.size()];
 
       //Build up new array of interceptors depending on their precedence
       int prec = 0;
@@ -272,8 +303,13 @@
             entry = precedence.get(prec++);
          }
          sortedInterceptors[i] = entry.interceptor;
+         sortedCFlows[i] = entry.cflow;
       }
-
+      if (cflowFound)
+      {
+         return new Interceptor[]{new SortedCFlowInterceptor(
+               sortedInterceptors, sortedCFlows)};
+      }
       return sortedInterceptors;
    }
 
@@ -324,7 +360,7 @@
       return sortedInterceptors;
    }
 
-/*  public static void main(String[] args)
+/* public static void main(String[] args)
    {
       System.out.println("Hello");
       AspectManager manager = new AspectManager();
@@ -352,7 +388,7 @@
       manager.addPrecedence(def);
       outputOverAll(manager);
 
-   } */
+   }
 
    private static void outputOverAll(AspectManager manager)
    {
@@ -363,7 +399,7 @@
       }
       System.out.println("==================================");
    }
-
+*/
 }
 
 class PrecedenceGraph

Added: projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/SortedCFlowInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/SortedCFlowInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/SortedCFlowInterceptor.java	2009-05-08 05:30:32 UTC (rev 88399)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.aop.advice;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.pointcut.CFlowMatcher;
+import org.jboss.aop.pointcut.ast.ASTCFlowExpression;
+
+/**
+ * This interceptor represents an interceptor chain bound with one or more cflow
+ * expressions. Such interceptor chain is kept in a precedence-sorted order. When
+ * this interceptor is invoked, it wraps the internal chain in the invocation.
+ * 
+ * Notice that, given that each interceptor can have a cflow expression associated
+ * with it, an interceptor will be invoked only if it has no cflow, or if it has a
+ * cflow expression that matches the current invocation.
+ * 
+ * The SortedCFlowInterceptor should belong always to unitary chains; otherwise, we
+ * cannot ensure the interceptor invocations will take place in the expected order.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $$Revision: 1.1 $$
+ * @see CFlowInterceptor
+ * @see PrecedenceSorter
+ */
+class SortedCFlowInterceptor implements Interceptor
+{
+   private Interceptor[] sortedInterceptors;
+   private CachedCFlow[] sortedCFlows;
+   private CachedCFlow[] cflows;
+   private Map<Integer, Interceptor[]> chains;
+   
+   /**
+    * Constructor.
+    * 
+    * @param sortedInterceptors a list of all interceptors in a precedence-sorted
+    *                           order.
+    * @param sortedCFlows       a list of the cflow expressions associated with each
+    *                           interceptor of the {@code sortedInterceptors} array
+    * @see PrecedenceSorter
+    */
+   public SortedCFlowInterceptor(Interceptor[] sortedInterceptors,
+         ASTCFlowExpression[] sortedCFlows)
+   {
+      this.sortedInterceptors = sortedInterceptors;
+      this.sortedCFlows = new CachedCFlow[sortedCFlows.length];
+      Collection<CachedCFlow> cflowSet = new HashSet<CachedCFlow>();
+      for (int i = 0; i < sortedCFlows.length; i++)
+      {
+         if (sortedCFlows[i] != null)
+         {
+            this.sortedCFlows[i] = new CachedCFlow(sortedCFlows[i]);
+            cflowSet.add(this.sortedCFlows[i]);
+         }
+      }
+      
+      this.chains = new LinkedHashMap<Integer, Interceptor[]>(2, 1, true){
+        @Override
+        protected boolean removeEldestEntry(Entry<Integer,Interceptor[]> eldest)
+        {
+           return size() > 5;
+        }
+      };
+      this.cflows = cflowSet.toArray(new CachedCFlow[cflowSet.size()]);
+   }
+   
+   public String getName()
+   {
+      return "SortedCFlowInterceptor";
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      // create a key identifying the overall cflow match status
+      int key = 0;
+      for (int i = 0; i < cflows.length; i++)
+      {
+         key = key + cflows[i].evaluate(invocation) << i;
+      }
+      Interceptor[] chain;
+      // if we have seen the same match status before, just reuse the chain
+      if (this.chains.containsKey(key))
+      {
+         chain = this.chains.get(key);
+      }
+      else
+      {
+         Collection<Interceptor> chainCollection = new ArrayList<Interceptor>();
+         for (int i = 0; i < this.sortedInterceptors.length; i++)
+         {
+            if (this.sortedCFlows[i] == null || this.sortedCFlows[i].matches())
+            {
+               chainCollection.add(this.sortedInterceptors[i]);
+            }
+         }
+         chain = chainCollection.toArray(new Interceptor[chainCollection.size()]);
+         // store the chain in the cache for reuse on subsequent invocations
+         this.chains.put(key, chain);
+      }
+      return invocation.getWrapper(chain).invokeNext();
+   }
+   
+   /**
+    * Wraps a cflow expression and caches its matching result during an joinpoint
+    * invocation.
+    */
+   private static class CachedCFlow
+   {
+      private ASTCFlowExpression cflow;
+      private boolean matches;
+      
+      public CachedCFlow(ASTCFlowExpression cflow)
+      {
+         this.cflow = cflow;
+         this.matches = false;
+      }
+      
+      public byte evaluate(Invocation invocation)
+      {
+         this.matches = new CFlowMatcher().matches(cflow, invocation);
+         return this.matches? (byte) 1: 0;
+      }
+      
+      public boolean matches()
+      {
+         return this.matches;
+      }
+   }
+}
\ No newline at end of file

Modified: projects/aop/trunk/aop/src/resources/test/arguments/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/arguments/jboss-aop.xml	2009-05-08 04:51:19 UTC (rev 88398)
+++ projects/aop/trunk/aop/src/resources/test/arguments/jboss-aop.xml	2009-05-08 05:30:32 UTC (rev 88399)
@@ -62,12 +62,12 @@
       <advice name="getAndChangeArgumentsAdvice" aspect="org.jboss.test.aop.arguments.ArgumentsAspect"/>
    </bind>
    
-   <!-- <precedence>
+   <precedence>
       <advice name="getArgumentsAdvice1" aspect="org.jboss.test.aop.arguments.ArgumentsAspect"/>
       <advice name="setArgumentsAdvice" aspect="org.jboss.test.aop.arguments.ArgumentsAspect"/>
       <advice name="getArgumentsAdvice2" aspect="org.jboss.test.aop.arguments.ArgumentsAspect"/>
       <advice name="getAndChangeArgumentsAdvice" aspect="org.jboss.test.aop.arguments.ArgumentsAspect"/>
-   </precedence> -->
+   </precedence>
    
    <aspect class="org.jboss.test.aop.arguments.NoPrecedenceArgumentsAspect" scope="PER_VM"/>
    

Modified: projects/aop/trunk/aop/src/resources/test/precedence/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/precedence/jboss-aop.xml	2009-05-08 04:51:19 UTC (rev 88398)
+++ projects/aop/trunk/aop/src/resources/test/precedence/jboss-aop.xml	2009-05-08 05:30:32 UTC (rev 88399)
@@ -86,8 +86,8 @@
        <interceptor-ref name="org.jboss.test.aop.precedence.FirstInterceptor"/>    
        <interceptor-ref name="org.jboss.test.aop.precedence.FirstInterceptor2"/>    
        <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice"/>
+       <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice3"/>
        <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice2"/>
-       <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice3"/>
        <advice aspect="org.jboss.test.aop.precedence.LastAspect" name="advice"/>
        <advice aspect="org.jboss.test.aop.precedence.LastAspect2" name="advice"/>
    </bind>
@@ -105,6 +105,39 @@
        <advice aspect="org.jboss.test.aop.precedence.LastAspect2" name="advice"/>
    </bind>
    
+   <cflow-stack name="test">
+      <called expr="* org.jboss.test.aop.precedence.PrecedenceTester->*(..)"/>
+   </cflow-stack>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.precedence.POJO->sixMethod())" cflow="test">
+       <interceptor-ref name="org.jboss.test.aop.precedence.FirstInterceptor"/>    
+       <interceptor-ref name="org.jboss.test.aop.precedence.FirstInterceptor2"/>    
+       <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice"/>
+       <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice3"/>
+       <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice2"/>
+       <advice aspect="org.jboss.test.aop.precedence.LastAspect" name="advice"/>
+       <advice aspect="org.jboss.test.aop.precedence.LastAspect2" name="advice"/>
+   </bind>
+   
+   <cflow-stack name="test2">
+      <called expr="* org.jboss.test.aop.precedence..->*(..)"/>
+   </cflow-stack>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.precedence.POJO->sevenMethod())" cflow="test">
+       <interceptor-ref name="org.jboss.test.aop.precedence.SimpleInterceptor3"/>
+       <interceptor-ref name="org.jboss.test.aop.precedence.SimpleInterceptor"/>
+   </bind>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.precedence.POJO->sevenMethod())">
+       <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice"/>
+       <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice3"/>
+       <advice aspect="org.jboss.test.aop.precedence.TestAspect" name="advice2"/>>
+   </bind>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.precedence.POJO->sevenMethod())" cflow="test2">
+       <interceptor-ref name="org.jboss.test.aop.precedence.SimpleInterceptor2"/>
+   </bind>
+   
    <!--  NO PRECEDENCE TESTS -->
    
    <interceptor class="org.jboss.test.aop.precedence.SimpleInterceptor4" scope="PER_VM"/>

Modified: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/precedence/POJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/precedence/POJO.java	2009-05-08 04:51:19 UTC (rev 88398)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/precedence/POJO.java	2009-05-08 05:30:32 UTC (rev 88399)
@@ -70,4 +70,14 @@
    {
       System.out.println("*** POJO fiveMethod");
    }
-}
+   
+   public void sixMethod()
+   {
+      System.out.println("*** POJO sixMethod");
+   }
+   
+   public void sevenMethod()
+   {
+      System.out.println("*** POJO sevenMethod");
+   }
+}
\ No newline at end of file

Modified: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/precedence/PrecedenceTester.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/precedence/PrecedenceTester.java	2009-05-08 04:51:19 UTC (rev 88398)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/precedence/PrecedenceTester.java	2009-05-08 05:30:32 UTC (rev 88399)
@@ -1,24 +1,24 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.test.aop.precedence;
 
 import junit.framework.Test;
@@ -39,47 +39,57 @@
 {
    //Don't list per_instance aspects for constructor
    final static String[] PRECEDENCE_ALL_CONSTRUCTOR = {
-         "FirstInterceptor",
-			"FirstInterceptor2",
-			"SimpleInterceptor2",
-			"SimpleInterceptor3",
-			"TestAspect.advice",
-			"TestAspect2.advice",
-			"LastAspect.advice",
-			"LastAspect2.advice"};
+      "FirstInterceptor",
+      "FirstInterceptor2",
+      "SimpleInterceptor2",
+      "SimpleInterceptor3",
+      "TestAspect.advice",
+      "TestAspect2.advice",
+      "LastAspect.advice",
+      "LastAspect2.advice"};
 
    final static String[] PRECEDENCE_ALL = {
-         "FirstInterceptor",
-			"FirstInterceptor2",
-			"SimpleInterceptor",
-			"SimpleInterceptor2",
-			"SimpleInterceptor3",
-			"TestAspect.advice",
-			"TestAspect2.advice",
-			"TestAspect3.advice",
-			"LastAspect.advice",
-			"LastAspect2.advice"};
+      "FirstInterceptor",
+      "FirstInterceptor2",
+      "SimpleInterceptor",
+      "SimpleInterceptor2",
+      "SimpleInterceptor3",
+      "TestAspect.advice",
+      "TestAspect2.advice",
+      "TestAspect3.advice",
+      "LastAspect.advice",
+      "LastAspect2.advice"};
 
    final static String[] PRECEDENCE_TWO = {
-         "FirstInterceptor",
-			"FirstInterceptor2",
-			"SimpleInterceptor",
-			"TestAspect.advice",
-			"TestAspect.advice2",
-			"TestAspect.advice3",
-			"TestAspect2.advice",
-			"LastAspect.advice",
-			"LastAspect2.advice"};
+      "FirstInterceptor",
+      "FirstInterceptor2",
+      "SimpleInterceptor",
+      "TestAspect.advice",
+      "TestAspect.advice2",
+      "TestAspect.advice3",
+      "TestAspect2.advice",
+      "LastAspect.advice",
+      "LastAspect2.advice"};
 
    final static String[] PRECEDENCE_THREE = {
-         "FirstInterceptor",
-			"FirstInterceptor2",
-			"TestAspect.advice",
-			"TestAspect.advice2",
-			"TestAspect.advice3",
-			"LastAspect.advice",
-			"LastAspect2.advice"};
+      "FirstInterceptor",
+      "FirstInterceptor2",
+      "TestAspect.advice",
+      "TestAspect.advice2",
+      "TestAspect.advice3",
+      "LastAspect.advice",
+      "LastAspect2.advice"};
 
+   final static String[] PRECEDENCE_SEVEN = {
+      "SimpleInterceptor",
+      "SimpleInterceptor2",
+      "SimpleInterceptor3",
+      "TestAspect.advice",
+      "TestAspect.advice2",
+      "TestAspect.advice3"};
+
+   private POJO pojo;
+
    public static Test suite()
    {
       TestSuite suite = new TestSuite("PrecedenceTester");
@@ -92,54 +102,97 @@
       super(name);
    }
 
-   public void testPrecedence() throws Exception
+   public void setUp() throws Exception
    {
+      super.setUp();
+      pojo = new POJO();
+      Interceptions.reset();
+   }
+
+   public void testConstructor() throws Exception
+   {
       System.out.println("*** Invoke constructor");
       Interceptions.reset();
-      POJO pojo = new POJO();
+      new POJO();
       checkInterceptions(PRECEDENCE_ALL_CONSTRUCTOR);
-      
+   }
+
+   @SuppressWarnings("all")
+   public void testVarRead()
+   {
       System.out.println("*** Invoke field read");
       Interceptions.reset();
       int i = pojo.var;
       checkInterceptions(PRECEDENCE_ALL);
-      
+   }
+
+   public void testVarWrite()
+   {
       System.out.println("*** Invoke field write");
       Interceptions.reset();
-      pojo.var = i + 1;
+      pojo.var = 1;
       checkInterceptions(PRECEDENCE_ALL);
-      
+   }
+
+   public void testOneMethod()
+   {
       System.out.println("*** Invoke oneMethod");
       Interceptions.reset();
       pojo.oneMethod();
       checkInterceptions(PRECEDENCE_ALL);
-      
+   }
+
+   public void testTwoMethod()
+   {
       Interceptions.reset();
       pojo.twoMethod();
       checkInterceptions(PRECEDENCE_TWO);
+   }
 
+   public void testThreeMethod()
+   {
       Interceptions.reset();
       pojo.threeMethod();
       checkInterceptions(PRECEDENCE_THREE);
-      
+   }
+
+   public void testFourMethod()
+   {
       Interceptions.reset();
       pojo.fourMethod();
       checkInterceptions(PRECEDENCE_TWO);
-      
+   }
+
+   public void testFiveMethod()
+   {
       Interceptions.reset();
       POJO.factoryMethod();
       checkInterceptions(PRECEDENCE_THREE);
    }
 
+   public void testSixMethod()
+   {
+      Interceptions.reset();
+      pojo.sixMethod();
+      checkInterceptions(PRECEDENCE_THREE);
+   }
+
+   public void testSevenMethod()
+   {
+      Interceptions.reset();
+      pojo.sevenMethod();
+      checkInterceptions(PRECEDENCE_SEVEN);
+   }
+
    private void checkInterceptions(String[] expected)
    {
       ArrayList intercepted = Interceptions.intercepted;
       assertEquals("Wrong number of interceptions", expected.length ,intercepted.size());
-      
+
       for (int i = 0 ; i < expected.length ; i++)
       {
          assertEquals("Wrong interception at index " + i, expected[i], (String)intercepted.get(i));
       }
    }
-   
-}
+
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list