[jboss-cvs] JBossAS SVN: r69308 - projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 24 14:50:17 EST 2008


Author: kabir.khan at jboss.com
Date: 2008-01-24 14:50:17 -0500 (Thu, 24 Jan 2008)
New Revision: 69308

Added:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesDelegate.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesInVmTestCase.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesOutOfVmTestCase.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesTest.java
Modified:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreatorDelegate.java
Log:
[JBAOP-467] Test that interceptors and aspects of all scopes can be marshalled when applied to a joinpoint that has not been called yet at the time of marshalling


Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreatorDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreatorDelegate.java	2008-01-24 19:46:54 UTC (rev 69307)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyFileCreatorDelegate.java	2008-01-24 19:50:17 UTC (rev 69308)
@@ -112,8 +112,6 @@
       InterceptorFactory[] interceptors = {advice};
       AdviceBinding binding = new AdviceBinding("binding" + index, pc, null, null, interceptors);
 
-      System.out.println("-----> Adding: " + aspectClass);
-      
       manager.addAspectDefinition(def);
       manager.addInterceptorFactory(advice.getName(), advice);
       manager.addPointcut(pc);

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesDelegate.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesDelegate.java	2008-01-24 19:50:17 UTC (rev 69308)
@@ -0,0 +1,147 @@
+/*
+* 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.aop.proxy;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.Scope;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryMixin;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SerializeContainerProxyWithNonInitialisedAdvicesDelegate extends ProxyFileCreatorDelegate
+{
+   public static void main (String[] args)
+   {
+      SerializeContainerProxyWithNonInitialisedAdvicesDelegate delegate = new SerializeContainerProxyWithNonInitialisedAdvicesDelegate();
+      delegate.createAndSerializeProxy(args);
+   }
+   
+   public void createAndSerializeProxy(File file) throws Exception
+   {
+      AspectManager manager = AspectManager.instance();
+      addInterceptorBinding(manager, 
+            1, 
+            Scope.PER_VM, 
+            TestInterceptor.class.getName(),
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+      addInterceptorBinding(manager, 
+            2, 
+            Scope.PER_CLASS, 
+            TestInterceptor2.class.getName(),
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+      addInterceptorBinding(manager, 
+            3, 
+            Scope.PER_CLASS_JOINPOINT, 
+            TestInterceptor3.class.getName(),
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+    
+      addInterceptorBinding(manager, 
+            4, 
+            Scope.PER_INSTANCE, 
+            TestInterceptor4.class.getName(),
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+      addInterceptorBinding(manager, 
+            5, 
+            Scope.PER_JOINPOINT, 
+            TestInterceptor5.class.getName(),
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+      addAspectBinding(manager, 
+            6, 
+            Scope.PER_VM, 
+            TestAspect.class.getName(),
+            "advice",
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+      addAspectBinding(manager, 
+            7, 
+            Scope.PER_CLASS, 
+            TestAspect2.class.getName(),
+            "advice",
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+      addAspectBinding(manager, 
+            8, 
+            Scope.PER_CLASS_JOINPOINT, 
+            TestAspect3.class.getName(),
+            "advice",
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+    
+      addAspectBinding(manager, 
+            9, 
+            Scope.PER_INSTANCE, 
+            TestAspect4.class.getName(),
+            "advice",
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+
+      addAspectBinding(manager, 
+            10, 
+            Scope.PER_JOINPOINT, 
+            TestAspect5.class.getName(),
+            "advice",
+            "execution(* $instanceof{" + SomeInterface.class.getName() + "}->helloWorld(..))");
+      
+      AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+      params.setInterfaces(new Class[] {SomeInterface.class});
+      params.setMixins(new AOPProxyFactoryMixin[] {
+            new AOPProxyFactoryMixin(OtherMixin.class, new Class[] {OtherMixinInterface.class, OtherMixinInterface2.class}, "20")
+      });
+      
+      params.setTarget(new SerializablePOJO());
+      AOPProxyFactory factory = new GeneratedAOPProxyFactory();
+      SomeInterface si = (SomeInterface)factory.createAdvisedProxy(params);
+      
+      //DO NOT CALL THE PROXY HERE!!! (The intention of this test is to make sure that the per_instance and per_joinpoint aspects
+      //and interceptors will still work although we have never made a call)
+      
+      
+      ObjectOutputStream out = null;
+      try
+      {
+         out = new ObjectOutputStream(new FileOutputStream(file));
+         out.writeObject(si);
+      }
+      finally
+      {
+         try
+         {
+            out.close();
+         }
+         catch(Exception e)
+         {
+         }
+      }
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesInVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesInVmTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesInVmTestCase.java	2008-01-24 19:50:17 UTC (rev 69308)
@@ -0,0 +1,51 @@
+/*
+  * 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.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class SerializeContainerProxyWithNonInitialisedAdvicesInVmTestCase extends SerializeContainerProxyWithNonInitialisedAdvicesTest
+{
+
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("SerializeContainerProxyWithNonInitialisedAdvicesInVmTestCase");
+      suite.addTestSuite(SerializeContainerProxyWithNonInitialisedAdvicesInVmTestCase.class);
+      return suite;
+   }
+
+   public SerializeContainerProxyWithNonInitialisedAdvicesInVmTestCase(String name)
+   {
+      super(name, new InProcessProxyFileCreator(new SerializeContainerProxyWithNonInitialisedAdvicesDelegate()));
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesOutOfVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesOutOfVmTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesOutOfVmTestCase.java	2008-01-24 19:50:17 UTC (rev 69308)
@@ -0,0 +1,52 @@
+/*
+  * 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.proxy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public class SerializeContainerProxyWithNonInitialisedAdvicesOutOfVmTestCase extends SerializeContainerProxyWithNonInitialisedAdvicesTest
+{
+
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("SerializeContainerProxyWithNonInitialisedAdvicesOutOfVmTestCase");
+      suite.addTestSuite(SerializeContainerProxyWithNonInitialisedAdvicesOutOfVmTestCase.class);
+      return suite;
+   }
+
+   public SerializeContainerProxyWithNonInitialisedAdvicesOutOfVmTestCase(String name)
+   {
+      super(name, new OutOfProcessProxyFileCreator(SerializeContainerProxyWithNonInitialisedAdvicesDelegate.class.getName()));
+   }
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesTest.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesTest.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithNonInitialisedAdvicesTest.java	2008-01-24 19:50:17 UTC (rev 69308)
@@ -0,0 +1,69 @@
+/*
+  * 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.proxy;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public abstract class SerializeContainerProxyWithNonInitialisedAdvicesTest extends AbstractSerializeContainerTest
+{
+   public SerializeContainerProxyWithNonInitialisedAdvicesTest(String name, ProxyFileCreator creator)
+   {
+      super(name, creator);
+   }
+
+   public void testContainerProxy() throws Exception
+   {
+      try
+      {
+         SomeInterface si = getSerializedProxy();
+         
+         TestInterceptor.invoked = false;
+         TestInterceptor2.invoked = false;
+         TestInterceptor3.invoked = false;
+         TestInterceptor4.invoked = false;
+         TestInterceptor5.invoked = false;
+         TestAspect.invoked = false;
+         TestAspect2.invoked = false;
+         TestAspect3.invoked = false;
+         TestAspect4.invoked = false;
+         TestAspect5.invoked = false;
+         si.helloWorld();
+         assertTrue(TestInterceptor.invoked);
+         assertTrue(TestInterceptor2.invoked);
+         assertTrue(TestInterceptor3.invoked);
+         assertTrue(TestInterceptor4.invoked);
+         assertTrue(TestInterceptor5.invoked);
+         assertTrue(TestAspect.invoked);
+         assertTrue(TestAspect2.invoked);
+         assertTrue(TestAspect3.invoked);
+         assertTrue(TestAspect4.invoked);
+         assertTrue(TestAspect5.invoked);
+      }
+      catch(Exception e)
+      {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list