[Jboss-cvs] JBossAS SVN: r56842 - in trunk/testsuite/src: main/org/jboss/test/aop/scopedextender main/org/jboss/test/aop/test resources/aop/scopedextender/base/META-INF resources/aop/scopedextender/child/noparentdelegation/META-INF resources/aop/scopedextender/child/parentdelegation/META-INF

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 14 09:10:45 EDT 2006


Author: kabir.khan at jboss.com
Date: 2006-09-14 09:10:00 -0400 (Thu, 14 Sep 2006)
New Revision: 56842

Modified:
   trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseAspect.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseLoadedTester.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseParentAspect.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ChildAspect.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ScopedChildNoParentDelegationTester.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ScopedChildParentDelegationTester.java
   trunk/testsuite/src/main/org/jboss/test/aop/test/ScopedExtenderBaseTest.java
   trunk/testsuite/src/resources/aop/scopedextender/base/META-INF/jboss-aop.xml
   trunk/testsuite/src/resources/aop/scopedextender/child/noparentdelegation/META-INF/jboss-aop.xml
   trunk/testsuite/src/resources/aop/scopedextender/child/parentdelegation/META-INF/jboss-aop.xml
Log:
[JBAOP-257] Get constructor interception working for subclasses in a deployment using scoped classloaders extending classes deployed in the global classloading domain.


Modified: trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseAspect.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseAspect.java	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseAspect.java	2006-09-14 13:10:00 UTC (rev 56842)
@@ -23,6 +23,7 @@
 
 import java.util.ArrayList;
 
+import org.jboss.aop.joinpoint.ConstructorInvocation;
 import org.jboss.aop.joinpoint.FieldReadInvocation;
 import org.jboss.aop.joinpoint.FieldWriteInvocation;
 import org.jboss.aop.joinpoint.MethodInvocation;
@@ -53,4 +54,10 @@
       invoked.add(invocation.getField().getName());
       return invocation.invokeNext();
    }
+
+   public Object invoke(ConstructorInvocation invocation) throws Throwable
+   {
+      invoked.add(invocation.getConstructor().getDeclaringClass().getName());
+      return invocation.invokeNext();
+   }
 }

Modified: trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseLoadedTester.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseLoadedTester.java	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseLoadedTester.java	2006-09-14 13:10:00 UTC (rev 56842)
@@ -92,16 +92,32 @@
 
    public void testConstructor() throws Exception
    {
+      TestUtil testUtil = new TestUtil();
       try
       {
          System.out.println("=============== BaseLoadedTester - CTOR ================");
+         
+         BaseAspect.invoked.clear();
+         Base_Base base = new Base_Base();
+         testUtil.compare(base.getClass().getName(), "BaseAspect", new String[]{base.getClass().getName()}, BaseAspect.invoked);
+         
+         BaseAspect.invoked.clear();
+         Base_A1 a1 = new Base_A1();
+         testUtil.compare(a1.getClass().getName(), "BaseAspect", new String[]{a1.getClass().getName()}, BaseAspect.invoked);
       }
       catch (RuntimeException e)
       {
          // AutoGenerated
          throw new RuntimeException(e);
       }
-      throw new Exception("Not yet implemented");
+      if (testUtil.getErrors() != null)
+      {
+         throw new RuntimeException(testUtil.getErrors());
+      }
+      if(Advised.class.isAssignableFrom(BaseNotBaseWoven.class))
+      {
+         throw new RuntimeException("BaseNotBaseWoven should not be woven");
+      }
    }
 
    public void testField() throws Exception

Modified: trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseParentAspect.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseParentAspect.java	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/BaseParentAspect.java	2006-09-14 13:10:00 UTC (rev 56842)
@@ -23,6 +23,7 @@
 
 import java.util.ArrayList;
 
+import org.jboss.aop.joinpoint.ConstructorInvocation;
 import org.jboss.aop.joinpoint.FieldReadInvocation;
 import org.jboss.aop.joinpoint.FieldWriteInvocation;
 import org.jboss.aop.joinpoint.MethodInvocation;
@@ -54,4 +55,9 @@
       return invocation.invokeNext();
    }
    
+   public Object invoke(ConstructorInvocation invocation) throws Throwable
+   {
+      invoked.add(invocation.getConstructor().getDeclaringClass().getName());
+      return invocation.invokeNext();
+   }
 }

Modified: trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ChildAspect.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ChildAspect.java	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ChildAspect.java	2006-09-14 13:10:00 UTC (rev 56842)
@@ -23,6 +23,7 @@
 
 import java.util.ArrayList;
 
+import org.jboss.aop.joinpoint.ConstructorInvocation;
 import org.jboss.aop.joinpoint.FieldReadInvocation;
 import org.jboss.aop.joinpoint.FieldWriteInvocation;
 import org.jboss.aop.joinpoint.MethodInvocation;
@@ -54,4 +55,9 @@
       return invocation.invokeNext();
    }
    
+   public Object invoke(ConstructorInvocation invocation) throws Throwable
+   {
+      invoked.add(invocation.getConstructor().getDeclaringClass().getName());
+      return invocation.invokeNext();
+   }
 }

Modified: trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ScopedChildNoParentDelegationTester.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ScopedChildNoParentDelegationTester.java	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ScopedChildNoParentDelegationTester.java	2006-09-14 13:10:00 UTC (rev 56842)
@@ -183,16 +183,64 @@
 
    public void testConstructor() throws Exception
    {
-      try
+      TestUtil testUtil = new TestUtil();
+      System.out.println("=============== ScopedChildNoParentDelegationTester - CTOR ================");
+
+      clear();
+      Child_A3 a3 = new Child_A3();
+      testUtil.compare(a3.getClass().getName(), "ChildAspect", new String[]{a3.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(a3.getClass().getName(), "BaseAspect", new String[]{a3.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(a3.getClass().getName(), "BaseParentAspect", new String[]{a3.getClass().getName()}, BaseParentAspect.invoked);
+      
+      clear();
+      Child_A2 a2 = new Child_A2();
+      testUtil.compare(a2.getClass().getName(), "ChildAspect", new String[]{a2.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(a2.getClass().getName(), "BaseAspect", new String[]{a2.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(a2.getClass().getName(), "BaseParentAspect", new String[]{a2.getClass().getName()}, BaseParentAspect.invoked);
+      
+      //Base_Base overrides the version from parent/global ucl, so aspects deployed by us should apply to its methods
+      clear();
+      Base_Base base = new Base_Base();
+      testUtil.compare(base.getClass().getName(), "ChildAspect", new String[]{}, ChildAspect.invoked);
+      testUtil.compare(base.getClass().getName(), "BaseAspect", new String[]{base.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(base.getClass().getName(), "BaseParentAspect", new String[]{base.getClass().getName()}, BaseParentAspect.invoked);
+      
+    
+      //Base_A1 overrides the version from parent/global ucl, so aspects deployed by us should apply to its methods
+      clear();
+      Base_A1 a1 = new Base_A1();
+      testUtil.compare(a1.getClass().getName(), "ChildAspect", new String[]{}, ChildAspect.invoked);
+      testUtil.compare(a1.getClass().getName(), "BaseAspect", new String[]{a1.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(a1.getClass().getName(), "BaseParentAspect", new String[]{a1.getClass().getName()}, BaseParentAspect.invoked);
+      
+      clear();
+      Child_B1 b1 = new Child_B1();
+      testUtil.compare(b1.getClass().getName(), "ChildAspect", new String[]{b1.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(b1.getClass().getName(), "BaseAspect", new String[]{b1.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(b1.getClass().getName(), "BaseParentAspect", new String[]{b1.getClass().getName()}, BaseParentAspect.invoked);
+      
+      clear();
+      Child_B2 b2 = new Child_B2();
+      testUtil.compare(b2.getClass().getName(), "ChildAspect", new String[]{b2.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(b2.getClass().getName(), "BaseAspect", new String[]{b2.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(b2.getClass().getName(), "BaseParentAspect", new String[]{b2.getClass().getName()}, BaseParentAspect.invoked);
+      
+      clear();
+      Child_B3 b3 = new Child_B3();
+      testUtil.compare(b3.getClass().getName(), "ChildAspect", new String[]{b3.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(b3.getClass().getName(), "BaseAspect", new String[]{b3.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(b3.getClass().getName(), "BaseParentAspect", new String[]{b3.getClass().getName()}, BaseParentAspect.invoked);
+      
+      clear();
+      BaseNotBaseWoven bnbw = new BaseNotBaseWoven();
+      testUtil.compare(bnbw.getClass().getName(), "ChildAspect", new String[]{bnbw.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(bnbw.getClass().getName(), "BaseAspect", new String[]{}, BaseAspect.invoked);
+      testUtil.compare(bnbw.getClass().getName(), "BaseParentAspect", new String[]{bnbw.getClass().getName()}, BaseParentAspect.invoked);
+      
+      if (testUtil.getErrors() != null)
       {
-         System.out.println("=============== ScopedChildNoParentDelegationTester - CTOR ================");
+         throw new RuntimeException(testUtil.getErrors());
       }
-      catch (RuntimeException e)
-      {
-         // AutoGenerated
-         throw new RuntimeException(e);
-      }
-      throw new Exception("Not yet implemented");
    }
 
    public void testField() throws Exception

Modified: trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ScopedChildParentDelegationTester.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ScopedChildParentDelegationTester.java	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedextender/ScopedChildParentDelegationTester.java	2006-09-14 13:10:00 UTC (rev 56842)
@@ -182,16 +182,54 @@
 
    public void testConstructor() throws Exception
    {
-      try
-      {
-         System.out.println("=============== ScopedChildParentDelegationTester - CTOR ================");
-      }
-      catch (RuntimeException e)
-      {
-         // AutoGenerated
-         throw new RuntimeException(e);
-      }
-      throw new Exception("Not yet implemented");
+      TestUtil testUtil = new TestUtil();
+      System.out.println("=============== ScopedChildParentDelegationTester - CTOR ================");
+
+      clear();
+      Child_A3 a3 = new Child_A3();
+      testUtil.compare(a3.getClass().getName(), "ChildAspect", new String[]{a3.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(a3.getClass().getName(), "BaseAspect", new String[]{a3.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(a3.getClass().getName(), "BaseParentAspect", new String[]{a3.getClass().getName()}, BaseParentAspect.invoked);
+      
+      clear();
+      Child_A2 a2 = new Child_A2();
+      testUtil.compare(a2.getClass().getName(), "ChildAspect", new String[]{a2.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(a2.getClass().getName(), "BaseAspect", new String[]{a2.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(a2.getClass().getName(), "BaseParentAspect", new String[]{a2.getClass().getName()}, BaseParentAspect.invoked);
+      
+      //Base_A1 is from parent/global ucl, so aspects deployed by us should not apply to its ctors
+      clear();
+      Base_Base base = new Base_Base();
+      testUtil.compare(base.getClass().getName(), "ChildAspect", new String[]{}, ChildAspect.invoked);
+      testUtil.compare(base.getClass().getName(), "BaseAspect", new String[]{base.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(base.getClass().getName(), "BaseParentAspect", new String[]{}, BaseParentAspect.invoked);
+      
+    
+      //Base_A1 is from parent/global ucl, so aspects deployed by us should not apply to its ctors
+      clear();
+      Base_A1 a1 = new Base_A1();
+      testUtil.compare(a1.getClass().getName(), "ChildAspect", new String[]{}, ChildAspect.invoked);
+      testUtil.compare(a1.getClass().getName(), "BaseAspect", new String[]{a1.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(a1.getClass().getName(), "BaseParentAspect", new String[]{}, BaseParentAspect.invoked);
+      
+      clear();
+      Child_B1 b1 = new Child_B1();
+      testUtil.compare(b1.getClass().getName(), "ChildAspect", new String[]{b1.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(b1.getClass().getName(), "BaseAspect", new String[]{b1.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(b1.getClass().getName(), "BaseParentAspect", new String[]{b1.getClass().getName()}, BaseParentAspect.invoked);
+      
+      clear();
+      Child_B2 b2 = new Child_B2();
+      testUtil.compare(b2.getClass().getName(), "ChildAspect", new String[]{b2.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(b2.getClass().getName(), "BaseAspect", new String[]{b2.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(b2.getClass().getName(), "BaseParentAspect", new String[]{b2.getClass().getName()}, BaseParentAspect.invoked);
+      
+      clear();
+      Child_B3 b3 = new Child_B3();
+      testUtil.compare(b3.getClass().getName(), "ChildAspect", new String[]{b3.getClass().getName()}, ChildAspect.invoked);
+      testUtil.compare(b3.getClass().getName(), "BaseAspect", new String[]{b3.getClass().getName()}, BaseAspect.invoked);
+      testUtil.compare(b3.getClass().getName(), "BaseParentAspect", new String[]{b3.getClass().getName()}, BaseParentAspect.invoked);
+         
    }
 
    public void testField() throws Exception

Modified: trunk/testsuite/src/main/org/jboss/test/aop/test/ScopedExtenderBaseTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/test/ScopedExtenderBaseTest.java	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/main/org/jboss/test/aop/test/ScopedExtenderBaseTest.java	2006-09-14 13:10:00 UTC (rev 56842)
@@ -84,16 +84,16 @@
       invokeFieldTest(CHILD_NAME);
    }
    
-//   public void testBaseConstructor() throws Exception
-//   {
-//      invokeConstructorTest(BASE_NAME);
-//   }
-//   
-//   public void testChildConstructor() throws Exception
-//   {
-//      invokeConstructorTest(CHILD_NAME);
-//   }
-//   
+   public void testBaseConstructor() throws Exception
+   {
+      invokeConstructorTest(BASE_NAME);
+   }
+   
+   public void testChildConstructor() throws Exception
+   {
+      invokeConstructorTest(CHILD_NAME);
+   }
+   
    private void invokeMethodTest(String objName) throws Exception
    {
       invoke(objName, "testMethod");

Modified: trunk/testsuite/src/resources/aop/scopedextender/base/META-INF/jboss-aop.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scopedextender/base/META-INF/jboss-aop.xml	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/resources/aop/scopedextender/base/META-INF/jboss-aop.xml	2006-09-14 13:10:00 UTC (rev 56842)
@@ -13,5 +13,8 @@
    <bind pointcut="field(* $instanceof{org.jboss.test.aop.scopedextender.Base_Base}->*)">
       <advice aspect="org.jboss.test.aop.scopedextender.BaseAspect" name="invoke"/>
    </bind>
+   <bind pointcut="execution($instanceof{org.jboss.test.aop.scopedextender.Base_Base}->new(..))">
+      <advice aspect="org.jboss.test.aop.scopedextender.BaseAspect" name="invoke"/>
+   </bind>
    
 </aop>

Modified: trunk/testsuite/src/resources/aop/scopedextender/child/noparentdelegation/META-INF/jboss-aop.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scopedextender/child/noparentdelegation/META-INF/jboss-aop.xml	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/resources/aop/scopedextender/child/noparentdelegation/META-INF/jboss-aop.xml	2006-09-14 13:10:00 UTC (rev 56842)
@@ -34,4 +34,17 @@
       <advice aspect="org.jboss.test.aop.scopedextender.BaseParentAspect" name="invoke"/>
       <advice aspect="org.jboss.test.aop.scopedextender.ChildAspect" name="invoke"/>
    </bind>
+   <bind pointcut="execution($instanceof{org.jboss.test.aop.scopedextender.Child_A2}->new(..))">
+      <advice aspect="org.jboss.test.aop.scopedextender.ChildAspect" name="invoke"/>
+   </bind>
+   <bind pointcut="execution($instanceof{org.jboss.test.aop.scopedextender.Child_B1}->new(..))">
+      <advice aspect="org.jboss.test.aop.scopedextender.ChildAspect" name="invoke"/>
+   </bind>
+   <bind pointcut="execution($instanceof{org.jboss.test.aop.scopedextender.Base_Base}->new(..))">
+      <advice aspect="org.jboss.test.aop.scopedextender.BaseParentAspect" name="invoke"/>
+   </bind>   
+   <bind pointcut="execution($instanceof{org.jboss.test.aop.scopedextender.BaseNotBaseWoven}->new(..))">
+      <advice aspect="org.jboss.test.aop.scopedextender.BaseParentAspect" name="invoke"/>
+      <advice aspect="org.jboss.test.aop.scopedextender.ChildAspect" name="invoke"/>
+   </bind>
 </aop>

Modified: trunk/testsuite/src/resources/aop/scopedextender/child/parentdelegation/META-INF/jboss-aop.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scopedextender/child/parentdelegation/META-INF/jboss-aop.xml	2006-09-14 12:52:11 UTC (rev 56841)
+++ trunk/testsuite/src/resources/aop/scopedextender/child/parentdelegation/META-INF/jboss-aop.xml	2006-09-14 13:10:00 UTC (rev 56842)
@@ -26,5 +26,14 @@
    <bind pointcut="field(* $instanceof{org.jboss.test.aop.scopedextender.Base_Base}->*)">
       <advice aspect="org.jboss.test.aop.scopedextender.BaseParentAspect" name="invoke"/>
    </bind>
+   <bind pointcut="execution($instanceof{org.jboss.test.aop.scopedextender.Child_A2}->new(..))">
+      <advice aspect="org.jboss.test.aop.scopedextender.ChildAspect" name="invoke"/>
+   </bind>
+   <bind pointcut="execution($instanceof{org.jboss.test.aop.scopedextender.Child_B1}->new(..))">
+      <advice aspect="org.jboss.test.aop.scopedextender.ChildAspect" name="invoke"/>
+   </bind>
+   <bind pointcut="execution($instanceof{org.jboss.test.aop.scopedextender.Base_Base}->new(..))">
+      <advice aspect="org.jboss.test.aop.scopedextender.BaseParentAspect" name="invoke"/>
+   </bind>   
    
 </aop>




More information about the jboss-cvs-commits mailing list