[jboss-cvs] JBossAS SVN: r103692 - in projects/kernel/trunk/aop-mc-int/src: test/java/org/jboss/test/microcontainer/beans and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 8 07:01:07 EDT 2010


Author: kabir.khan at jboss.com
Date: 2010-04-08 07:01:06 -0400 (Thu, 08 Apr 2010)
New Revision: 103692

Added:
   projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/LightweightAspectPOJO.java
   projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectAopTestCase.java
   projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectTest.java
   projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectAopTestCase.xml
Modified:
   projects/kernel/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/beans/InterceptorEntry.java
Log:
[JBKERNEL-117] Test that lightweight aspect work

Modified: projects/kernel/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/beans/InterceptorEntry.java
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/beans/InterceptorEntry.java	2010-04-08 10:37:08 UTC (rev 103691)
+++ projects/kernel/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/beans/InterceptorEntry.java	2010-04-08 11:01:06 UTC (rev 103692)
@@ -100,7 +100,7 @@
          throw new IllegalArgumentException("Null aspect");
       }
       interceptorFactory = (aspectMethod == null) ? 
-            new ScopedInterceptorFactory(aspect.getDefinition()) : new AdviceFactory(aspect.getDefinition(), aspectMethod);
+            new ScopedInterceptorFactory(aspect.getDefinition()) : new AdviceFactory(aspect.getDefinition(), aspectMethod, type);
             
       manager.addInterceptorFactory(name, interceptorFactory);
       if (binding != null)
@@ -126,6 +126,9 @@
       entry.binding = binding;
       entry.aspect = aspect;
       entry.aspectMethod = aspectMethod;
+      entry.forStack = forStack;
+      entry.type = type;
+      
       return entry;
    }
 }

Added: projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/LightweightAspectPOJO.java
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/LightweightAspectPOJO.java	                        (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/LightweightAspectPOJO.java	2010-04-08 11:01:06 UTC (rev 103692)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.microcontainer.beans;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LightweightAspectPOJO
+{
+   public void method(boolean error)
+   {
+      if (error)
+         throw new RuntimeException();
+   }
+}

Added: projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectAopTestCase.java
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectAopTestCase.java	                        (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectAopTestCase.java	2010-04-08 11:01:06 UTC (rev 103692)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.microcontainer.beans.woven.test;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LightweightAspectAopTestCase extends LightweightAspectTest
+{
+   public LightweightAspectAopTestCase(String name)
+   {
+      super(name);
+   }
+
+}

Added: projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectTest.java
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectTest.java	                        (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectTest.java	2010-04-08 11:01:06 UTC (rev 103692)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.microcontainer.beans.woven.test;
+
+import org.jboss.test.aop.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans.Interceptions;
+import org.jboss.test.microcontainer.beans.LightweightAspectPOJO;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LightweightAspectTest extends AOPMicrocontainerTest
+{
+   public LightweightAspectTest(String name)
+   {
+      super(name);
+   }
+
+   public void testLightweightAspect() throws Throwable
+   {
+      LightweightAspectPOJO pojo = new LightweightAspectPOJO();
+      
+      Interceptions.reset();
+      pojo.method(false);
+      assertEquals(3, Interceptions.interceptions().size());
+      assertEquals("BEFORE", Interceptions.interceptions().get(0));
+      assertEquals("AFTER", Interceptions.interceptions().get(1));
+      assertEquals("FINALLY", Interceptions.interceptions().get(2));
+      
+      Interceptions.reset();
+      try
+      {
+         pojo.method(true);
+      }
+      catch (Exception expected)
+      {
+      }
+      assertEquals(3, Interceptions.interceptions().size());
+      assertEquals("BEFORE", Interceptions.interceptions().get(0));
+      assertEquals("THROWING", Interceptions.interceptions().get(1));
+      assertEquals("FINALLY", Interceptions.interceptions().get(2));
+      
+   }
+}

Added: projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectAopTestCase.xml
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectAopTestCase.xml	                        (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/woven/test/LightweightAspectAopTestCase.xml	2010-04-08 11:01:06 UTC (rev 103692)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop xmlns="urn:jboss:aop-beans:1.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+
+   <aspect class="org.jboss.test.microcontainer.beans.LightweightAspect"/>
+
+   <bind pointcut="execution(* org.jboss.test.microcontainer.beans.LightweightAspectPOJO->method(..))">
+      <before aspect="org.jboss.test.microcontainer.beans.LightweightAspect" name="before"/>
+      <after aspect="org.jboss.test.microcontainer.beans.LightweightAspect" name="after"/>
+      <throwing aspect="org.jboss.test.microcontainer.beans.LightweightAspect" name="throwing"/>
+      <finally aspect="org.jboss.test.microcontainer.beans.LightweightAspect" name="finaly"/>
+   </bind>"
+</aop>




More information about the jboss-cvs-commits mailing list