[jboss-cvs] JBossAS SVN: r79721 - in projects/aop/trunk/aop/src: main/org/jboss/aop/instrument and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Oct 19 21:43:29 EDT 2008


Author: flavia.rainone at jboss.com
Date: 2008-10-19 21:43:29 -0400 (Sun, 19 Oct 2008)
New Revision: 79721

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AnnotatedParameterAdviceInfo.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRule.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
   projects/aop/trunk/aop/src/resources/test/annotatedAdviceParams/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownAspect.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownPOJO.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownTestCase.java
Log:
[JBAOP-388]Added support to different types of exceptions on @Thrown-annotated advice parameters for after-throwing
advice.

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AnnotatedParameterAdviceInfo.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AnnotatedParameterAdviceInfo.java	2008-10-20 00:51:15 UTC (rev 79720)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AnnotatedParameterAdviceInfo.java	2008-10-20 01:43:29 UTC (rev 79721)
@@ -428,6 +428,7 @@
    class SingleParameterType extends ParameterAnnotationType
    {
       int index;
+      Type assignableFrom;
       
       public SingleParameterType(ParameterAnnotationRule rule)
       {
@@ -455,20 +456,79 @@
       
       public final boolean internalValidate(AdviceMethodProperties properties)
       {
-         if (index != -1 && !AssignabilityAlgorithm.VARIABLE_TARGET.isAssignable(
-               method.getGenericParameterTypes()[index],
-               (Type)rule.getAssignableFrom(properties), hierarchy))
+         if (index == -1)
          {
+            return true;
+         }
+         Type parameterType = method.getGenericParameterTypes()[index];
+         Object assignableFrom = rule.getAssignableFrom(properties);
+         Class<?> superType = rule.getSuperType();
+         System.out.println(rule + " supertype: " + superType);
+         if (assignableFrom instanceof Type)
+         {
+            if(AssignabilityAlgorithm.VARIABLE_TARGET.isAssignable(parameterType,
+               (Type) assignableFrom, hierarchy))
+            {
+               this.assignableFrom = (Type) assignableFrom;
+               return true;
+            }
+            if (superType != null && superType.isAssignableFrom(
+                  method.getParameterTypes()[index]))
+            {
+               System.out.println("SUPER TYPE " + superType  + " is ASSIGNABLE FROM " + parameterType);
+               this.assignableFrom = null;
+               return true;
+            }
+            else
+            {
+               System.out.println("SUPER TYPE: " + superType);
+            }
             AdviceMethodFactory.appendNewMatchingMessage(method, rule);
             AdviceMethodFactory.appendMatchingMessage("-annotated parameter is not assignable from expected type ");
-            AdviceMethodFactory.appendMatchingMessage(((Type) rule.getAssignableFrom(properties)));
+            AdviceMethodFactory.appendMatchingMessage(assignableFrom);
+            if (superType != null)
+            {
+               AdviceMethodFactory.appendMatchingMessage(" nor it is a subtype of ");
+               AdviceMethodFactory.appendMatchingMessage(superType);
+            }
             return false;
          }
-         return  true;
+         for (Type type: (Type[]) assignableFrom)
+         {
+            if (AssignabilityAlgorithm.VARIABLE_TARGET.isAssignable(parameterType,
+                  type, hierarchy))
+            {
+               this.assignableFrom = type;
+               return true;
+            }
+         }
+         if (superType != null &&
+               superType.isAssignableFrom(method.getParameterTypes()[index]))
+         {
+            this.assignableFrom = null;
+            return true;
+         }
+         AdviceMethodFactory.appendNewMatchingMessage(method, rule);
+         AdviceMethodFactory.appendMatchingMessage("-annotated parameter is not assignable from any of expected types [");
+         AdviceMethodFactory.appendMatchingMessage(rule.getAssignableFrom(properties));
+         for (Type type: (Type[]) assignableFrom)
+         {
+            AdviceMethodFactory.appendMatchingMessage(", ");
+            AdviceMethodFactory.appendMatchingMessage(type);
+         }
+         AdviceMethodFactory.appendMatchingMessage(']');
+         if (superType != null)
+         {
+            AdviceMethodFactory.appendMatchingMessage(" nor it is a subtype of ");
+            AdviceMethodFactory.appendMatchingMessage(superType);
+         }
+         return false;
       }
 
-      // this class doesn't set any field during validation
-      public final void resetValidation() { }
+      public final void resetValidation()
+      {
+         this.assignableFrom = null;
+      }
 
       public final short getAssignabilityDegree(AdviceMethodProperties properties)
       {
@@ -476,9 +536,12 @@
          {
             return -1;
          }
+         if (assignableFrom == null)
+         {
+            return 1000;
+         }
          return DEGREE.getAssignabilityDegree(
-               method.getGenericParameterTypes()[this.index],
-               (Type) rule.getAssignableFrom(properties));
+               method.getGenericParameterTypes()[this.index], assignableFrom);
       }
       
       public final void assignParameterInfo(int[] args)

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRule.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRule.java	2008-10-20 00:51:15 UTC (rev 79720)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRule.java	2008-10-20 01:43:29 UTC (rev 79721)
@@ -1,6 +1,7 @@
 package org.jboss.aop.advice.annotation;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 
 import org.jboss.aop.advice.AdviceMethodProperties;
 import org.jboss.aop.joinpoint.FieldReadInvocation;
@@ -19,8 +20,8 @@
     * Rule for parameter annotation {@link JoinPoint}.
     */
    JOIN_POINT (
-         JoinPoint.class, JoinPointBean.class, AdviceMethodProperties.JOINPOINT_ARG,
-         700, false, true)
+         JoinPoint.class, JoinPointBean.class, null,
+         AdviceMethodProperties.JOINPOINT_ARG, 700, false, true)
    {
       public Object getAssignableFrom(AdviceMethodProperties properties)
       {
@@ -32,8 +33,8 @@
     * Rule for parameter annotation {@link Invocation}.
     */
    INVOCATION (
-         JoinPoint.class, Invocation.class, AdviceMethodProperties.INVOCATION_ARG,
-         700, false, true)
+         JoinPoint.class, Invocation.class, null,
+         AdviceMethodProperties.INVOCATION_ARG, 700, false, true)
    {
       public Object getAssignableFrom(AdviceMethodProperties properties)
       {
@@ -45,7 +46,7 @@
     * Rule for parameter annotation {@link Target}.
     */
    TARGET (
-         Target.class, null, AdviceMethodProperties.TARGET_ARG, 300, false, true)
+         Target.class, null, null, AdviceMethodProperties.TARGET_ARG, 300, false, true)
    {
       public Object getAssignableFrom(AdviceMethodProperties properties)
       {
@@ -62,7 +63,7 @@
     * Rule for parameter annotation {@link Caller}.
     */
    CALLER (
-         Caller.class, null, AdviceMethodProperties.CALLER_ARG, 150, false, true)
+         Caller.class, null, null, AdviceMethodProperties.CALLER_ARG, 150, false, true)
    {
       public Object getAssignableFrom(AdviceMethodProperties properties)
       {
@@ -79,7 +80,7 @@
     * Rule for parameter annotation {@link Return}.
     */
    RETURN (
-         Return.class, null, AdviceMethodProperties.RETURN_ARG, 50, false, true)
+         Return.class, null, null, AdviceMethodProperties.RETURN_ARG, 50, false, true)
    {
       public Object getAssignableFrom(AdviceMethodProperties properties)
       {
@@ -91,21 +92,32 @@
     * Rule for parameter annotation {@link Thrown}.
     */
    OPTIONAL_THROWN (
-         Thrown.class, Throwable.class, AdviceMethodProperties.THROWABLE_ARG, 50,
-         false, true),
+         Thrown.class, Throwable.class, null, AdviceMethodProperties.THROWABLE_ARG,
+         50, false, true),
    
    /**
     * Rule for parameter annotation {@link Thrown}.
     */
    MANDATORY_THROWN (
-         Thrown.class, Throwable.class, AdviceMethodProperties.THROWABLE_ARG, 50,
-         true, true),
+         Thrown.class, Throwable.class, RuntimeException.class,
+         AdviceMethodProperties.THROWABLE_ARG, 50, true, true)
+   {
+      public Object getAssignableFrom(AdviceMethodProperties properties)
+      {
+         Type[] joinpointExceptions = properties.getJoinpointExceptions();
+         if (joinpointExceptions == null || joinpointExceptions.length == 0)
+         {
+            return super.getAssignableFrom(properties);
+         }
+         return joinpointExceptions;
+      }   
+   },
       
    /**
     * Rule for parameter annotation {@link Arg}.
     */
    ARG (
-         Arg.class, null, AdviceMethodProperties.ARG_ARG, 2, false, false)
+         Arg.class, null, null, AdviceMethodProperties.ARG_ARG, 2, false, false)
    {
       public Object getAssignableFrom(AdviceMethodProperties properties)
       {
@@ -117,7 +129,7 @@
     * Rule for parameter annotation {@link Args}.
     */
    ARGS (
-         Args.class, Object[].class, AdviceMethodProperties.ARGS_ARG, 1, false, true)
+         Args.class, Object[].class, null, AdviceMethodProperties.ARGS_ARG, 1, false, true)
    {
       public boolean lowerRankGrade(AdviceMethodProperties properties)
       {
@@ -127,6 +139,7 @@
    
    private Class<? extends Annotation> annotation;
    private Class<?> assignableFrom;
+   private Class<?> superType;
    private int rankGrade;
    private boolean mandatory;
    private boolean singleEnforced;
@@ -148,11 +161,13 @@
     *                        annotation</code> in the advice method parameters is
     *                        forbidden
     */
-   private ParameterAnnotationRule(Class<? extends Annotation> annotation, Class<?> assignableFrom, int property,
+   private ParameterAnnotationRule(Class<? extends Annotation> annotation,
+         Class<?> assignableFrom, Class<?> superType, int property,
          int rankGrade, boolean mandatory, boolean singleEnforced)
    {
       this.annotation = annotation;
       this.assignableFrom = assignableFrom;
+      this.superType = superType;
       this.property = property;
       this.rankGrade = rankGrade;
       this.mandatory = mandatory;
@@ -174,9 +189,10 @@
     * @param properties describes the queried advice method
     * 
     * @return the type or types from which the annotated parameter must be assignable.
-    *         If this rule {@link #isSingleEnforced() is single enforced}, the return
-    *         type is <code>java.lang.reflect.Type</code>; otherwise, it is
-    *         <code>java.lang.reflect.Type[]</code>.
+    *         The return type can be <code>java.lang.reflect.Type</code> or
+    *         <code>java.lang.reflect.Type[]</code>. If this rule
+    *         {@link #isSingleEnforced() is not single enforced}, the return type
+    *         must be <code>java.lang.reflect.Type[]</code>.
     */
    public Object getAssignableFrom(AdviceMethodProperties properties)
    {
@@ -184,6 +200,20 @@
    }
    
    /**
+    * Returns the type that can be the super type of the annotated parameter type.
+    * This is an optional rule, and can be applied only if the annotated parameter
+    * type is not assignable from the type(s) defined by {@link
+    * #getAssignableFrom(AdviceMethodProperties)}.
+    * 
+    * @return the type that can be the super type of the annotated parameter type.
+    *         Can be {@code null}.
+    */
+   public Class<?> getSuperType()
+   {
+      return superType;
+   }
+   
+   /**
     * Returns the property identifying the annotated parameter type.
     * 
     * @return one of the constant values defined in {@link AdviceMethodProperties}

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java	2008-10-20 00:51:15 UTC (rev 79720)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java	2008-10-20 01:43:29 UTC (rev 79721)
@@ -682,6 +682,7 @@
          AdviceSetups setups, CtClass[] declaredExceptions, CtClass[] parameterTypes, JoinPointInfo info)throws NotFoundException
    {
       AdviceCallStrategy defaultCall = DefaultAdviceCallStrategy.getInstance();
+      AdviceCallStrategy afterThrowingCall = AfterThrowingAdviceCallStrategy.getInstance();
       AdviceCallStrategy afterCall = AfterAdviceCallStrategy.getInstance();
       
       StringBuffer code = new StringBuffer();
@@ -729,7 +730,7 @@
       afterCode.append("   {");
       // store throwable in THROWABLE variable
       afterCode.append(THROWABLE).append(" = ").append("throwable;");
-      argsFoundAfter = defaultCall.addInvokeCode(this,
+      argsFoundAfter = afterThrowingCall.addInvokeCode(this,
             setups.getByType(AdviceType.THROWING), afterCode, info) || argsFoundAfter;
       afterCode.append("throw t;");
       //addHandleExceptionCode(afterCode, declaredExceptions);
@@ -1755,6 +1756,7 @@
       }
       
       protected abstract String generateKey(JoinPointGenerator generator);
+      
       /**
        * 
        * @param setup represents an advice that should be invoked (i.e.,
@@ -1826,6 +1828,7 @@
             call.append(RETURN_VALUE);
             break;
          case AdviceMethodProperties.THROWABLE_ARG:
+            call.append('(').append(adviceParam.getName()).append(')');
             call.append(THROWABLE);
             break;
          case AdviceMethodProperties.TARGET_ARG:
@@ -1861,9 +1864,9 @@
             
             // make typed argument consistent, if that is the case
             Set<Integer> inconsistentTypeArgs = generator.inconsistentTypeArgs.get();
-            int argIndex = arg + generator.parameters.getFirstArgIndex();
             if (inconsistentTypeArgs.contains(arg))
             {
+               int argIndex = arg + generator.parameters.getFirstArgIndex();
                beforeCall.append("$").append(argIndex).append(" = ");
                beforeCall.append(ReflectToJavassist.castInvocationValueToTypeString(
                properties.getJoinpointParameterClassTypes()[arg], ARGUMENTS + '[' + arg + ']'));
@@ -2051,7 +2054,51 @@
          return super.appendAdviceCall(setup, beforeCall, call, generator);
       }
    }
+   
+   private static class AfterThrowingAdviceCallStrategy extends AdviceCallStrategy
+   {
+      private static AfterThrowingAdviceCallStrategy INSTANCE = new AfterThrowingAdviceCallStrategy();
+      
+      public static final AfterThrowingAdviceCallStrategy getInstance()
+      {
+         return INSTANCE;
+      }
+      
+      public boolean appendAdviceCall(AdviceSetup setup, String key,
+            StringBuffer beforeCall, StringBuffer call, JoinPointGenerator generator, JoinPointInfo info)
+      {
+         int[] args = setup.getAdviceMethodProperties().getArgs();
+         int throwableIndex = -1;
+         for (int i = 0; i < args.length; i++)
+         {
+            if (args[i] == AdviceMethodProperties.THROWABLE_ARG)
+            {
+               throwableIndex = i;
+            }
+         }
+         if (throwableIndex != -1)
+         {
+            Class<?> throwableType = setup.getAdviceMethodProperties().
+               getAdviceMethod().getParameterTypes()[throwableIndex];
+            if (throwableType != Throwable.class)
+            {
+               call.append("if (").append(THROWABLE).append(" instanceof ");
+               call.append(throwableType.getName()).append(") {");
+               boolean result = super.appendAdviceCall(setup, beforeCall, call, generator);
+               call.append("}");
+               return result;
+            }
+         }
+         return super.appendAdviceCall(setup, beforeCall, call, generator);
+      }
 
+      @Override
+      protected String generateKey(JoinPointGenerator generator)
+      {
+         return null;
+      }
+   }
+
    // TODO replace by enum
    protected static class JoinPointParameters {
       public static final JoinPointParameters ONLY_ARGS = new JoinPointParameters(false, -1, false, -1, 0, null);

Modified: projects/aop/trunk/aop/src/resources/test/annotatedAdviceParams/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/annotatedAdviceParams/jboss-aop.xml	2008-10-20 00:51:15 UTC (rev 79720)
+++ projects/aop/trunk/aop/src/resources/test/annotatedAdviceParams/jboss-aop.xml	2008-10-20 01:43:29 UTC (rev 79721)
@@ -1434,10 +1434,13 @@
 	</bind>
 
 	<bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownPOJO->method3(..))">
+      <throwing name="throwing3" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
+      <throwing name="throwing10" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
+      <throwing name="throwing11" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
 	</bind>
 
    <bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownInvalidPOJO->method3Throwing3(..))">
-		<throwing name="throwing3" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
+		<throwing name="throwing9" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
 	</bind>
 
    <bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownInvalidPOJO->method3Finally3(..))">
@@ -1445,11 +1448,12 @@
 	</bind>
 
 	<bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownPOJO->method4(..))">
+      <throwing name="throwing4" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
       <finally name="finally4" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
 	</bind>
 
    <bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownInvalidPOJO->method4Throwing4(..))">
-		<throwing name="throwing4" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
+		<throwing name="throwing9" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
 	</bind>
 
 	<bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownPOJO->method5(..))">
@@ -1471,6 +1475,18 @@
 	<bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownInvalidPOJO->method7Throwing8(..))">
 		<throwing name="throwing8" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
 	</bind>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownPOJO->method8(..))">
+      <throwing name="throwing10" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
+	</bind>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownPOJO->method9(..))">
+      <throwing name="throwing6" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
+	</bind>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.annotatedAdviceParams.ThrownPOJO->method10(..))">
+      <throwing name="throwing11" aspect="org.jboss.test.aop.annotatedAdviceParams.ThrownAspect"/>
+	</bind>
 
    <!-- overloaded advices test -->
 

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownAspect.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownAspect.java	2008-10-20 00:51:15 UTC (rev 79720)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownAspect.java	2008-10-20 01:43:29 UTC (rev 79721)
@@ -21,6 +21,9 @@
  */
 package org.jboss.test.aop.annotatedAdviceParams;
 
+import java.io.IOException;
+import java.rmi.AccessException;
+
 import junit.framework.Assert;
 
 import org.jboss.aop.advice.annotation.Arg;
@@ -81,15 +84,15 @@
       throwingThrown = pojoException;
    }
    
-   public void throwing5(@Thrown RuntimeException runtimeException)
+   public void throwing5(@Thrown IOException runtimeException)
    {
       Assert.fail("This advice should never be executed");
    }
    
    public void throwing6(@Thrown Throwable throwable)
    {
-      // exception isn't thrown by joinpoint
-      Assert.fail("This advice should never be executed");
+      throwingAdvice = "throwing6";
+      throwingThrown = throwable;
    }
    
    public void throwing8(@Arg int i)
@@ -97,6 +100,23 @@
       Assert.fail("This advice should never be executed");
    }
    
+   public void throwing9(@Thrown AccessException throwable)
+   {
+      Assert.fail("This advice should never be executed");
+   }
+   
+   public void throwing10(@Thrown RuntimeException throwable)
+   {
+      throwingAdvice = "throwing10";
+      throwingThrown = throwable;
+   }
+   
+   public void throwing11(@Thrown NullPointerException throwable)
+   {
+      throwingAdvice = "throwing11";
+      throwingThrown = throwable;
+   }
+   
    public void finally1(@Thrown Throwable throwable)
    {
       finallyAdvice = "finally1";

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownPOJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownPOJO.java	2008-10-20 00:51:15 UTC (rev 79720)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownPOJO.java	2008-10-20 01:43:29 UTC (rev 79721)
@@ -62,4 +62,20 @@
    {
       throw new POJOException(6);
    }
+   
+   public void method8() throws POJOException
+   {
+      throw new RuntimeException();
+   }
+   
+   public void method9()
+   {
+      throw new RuntimeException();
+   }
+   
+   public void method10()
+   {
+      Object nullObject = null;
+      System.out.println(nullObject.toString());
+   }
 }
\ No newline at end of file

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownTestCase.java	2008-10-20 00:51:15 UTC (rev 79720)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotatedAdviceParams/ThrownTestCase.java	2008-10-20 01:43:29 UTC (rev 79721)
@@ -122,12 +122,9 @@
          thrown = true;
          assertEquals(37, pojoException.number);
          
-         assertNull(ThrownAspect.throwingAdvice);
-         assertNull(ThrownAspect.throwingThrown);
-         assertEquals(0, ThrownAspect.throwingNumber);
-         /*assertEquals("throwing3", ThrownAspect.advice);
-         assertSame(pojoException, ThrownAspect.thrown);
-         assertEquals(37, ThrownAspect.thrownNumber);*/
+         assertEquals("throwing3", ThrownAspect.throwingAdvice);
+         assertSame(pojoException, ThrownAspect.throwingThrown);
+         assertEquals(37, ThrownAspect.throwingNumber);
          
          assertNull(ThrownAspect.finallyAdvice);
          assertNull(ThrownAspect.finallyThrown);
@@ -148,14 +145,9 @@
          thrown = true;
          assertEquals(43, pojoException.number);
          
-         assertNull(ThrownAspect.throwingAdvice);
-         assertNull(ThrownAspect.throwingThrown);
-         assertEquals(0, ThrownAspect.throwingNumber);
-         /*assertEquals("throwing4", ThrownAspect.advice);
-         assertSame(pojoException, ThrownAspect.thrown);
-         assertEquals(43, ThrownAspect.thrownNumber);*/
-         
-
+         assertEquals("throwing4", ThrownAspect.throwingAdvice);
+         assertSame(pojoException, ThrownAspect.throwingThrown);
+         assertEquals(43, ThrownAspect.throwingNumber);
       }
       assertTrue(thrown);
    }
@@ -226,4 +218,67 @@
       }
       assertTrue(thrown);
    }
+   
+   public void test8() throws POJOException
+   {
+      boolean thrown = false;
+      try
+      {
+         pojo.method8();
+      }
+      catch(RuntimeException exception)
+      {
+         thrown = true;
+         assertEquals("throwing10", ThrownAspect.throwingAdvice);
+         assertSame(exception, ThrownAspect.throwingThrown);
+         assertEquals(0, ThrownAspect.throwingNumber);
+         
+         assertNull(ThrownAspect.finallyAdvice);
+         assertNull(ThrownAspect.finallyThrown);
+         assertEquals(0, ThrownAspect.finallyNumber);
+      }
+      assertTrue(thrown);
+   }
+   
+   public void test9() throws POJOException
+   {
+      boolean thrown = false;
+      try
+      {
+         pojo.method9();
+      }
+      catch(RuntimeException exception)
+      {
+         thrown = true;
+         assertEquals("throwing6", ThrownAspect.throwingAdvice);
+         assertSame(exception, ThrownAspect.throwingThrown);
+         assertEquals(0, ThrownAspect.throwingNumber);
+         
+         assertNull(ThrownAspect.finallyAdvice);
+         assertNull(ThrownAspect.finallyThrown);
+         assertEquals(0, ThrownAspect.finallyNumber);
+      }
+      assertTrue(thrown);
+   }
+   
+   public void test10() throws POJOException
+   {
+      boolean thrown = false;
+      try
+      {
+         pojo.method10();
+      }
+      catch(RuntimeException exception)
+      {
+         thrown = true;
+         assertEquals("throwing11", ThrownAspect.throwingAdvice);
+         assertSame(exception, ThrownAspect.throwingThrown);
+         assertEquals(0, ThrownAspect.throwingNumber);
+         
+         assertNull(ThrownAspect.finallyAdvice);
+         assertNull(ThrownAspect.finallyThrown);
+         assertEquals(0, ThrownAspect.finallyNumber);
+      }
+      assertTrue(thrown);
+   }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list