[jboss-cvs] JBossAS SVN: r69499 - 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 31 09:19:51 EST 2008


Author: kabir.khan at jboss.com
Date: 2008-01-31 09:19:50 -0500 (Thu, 31 Jan 2008)
New Revision: 69499

Added:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataDelegate.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataInVmTestCase.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataOutOfVmTestCase.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataTest.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SimpleMetaDataInterceptor.java
Log:
[JBAOP-467] Test SimpleMetaData


Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataDelegate.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataDelegate.java	2008-01-31 14:19:50 UTC (rev 69499)
@@ -0,0 +1,94 @@
+/*
+* 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.metadata.SimpleMetaData;
+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 SerializeContainerProxyWithSimpleMetaDataDelegate extends ProxyFileCreatorDelegate
+{
+   public static void main (String[] args)
+   {
+      SerializeContainerProxyWithSimpleMetaDataDelegate delegate = new SerializeContainerProxyWithSimpleMetaDataDelegate();
+      delegate.createAndSerializeProxy(args);
+   }
+   
+   public void createAndSerializeProxy(File file) throws Exception
+   {
+      AspectManager manager = AspectManager.instance();
+      addInterceptorBinding(manager, 
+            1, 
+            Scope.PER_VM, 
+            SimpleMetaDataInterceptor.class.getName(),
+            "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")
+      });
+      
+      SimpleMetaData data = new SimpleMetaData();
+      data.addMetaData("TEST", "value", "metadata");
+      params.setSimpleMetaData(data);
+      
+      params.setTarget(new SerializablePOJO());
+      AOPProxyFactory factory = new GeneratedAOPProxyFactory();
+      SomeInterface si = (SomeInterface)factory.createAdvisedProxy(params);
+      
+      SimpleMetaDataInterceptor.data = null;
+      si.helloWorld();
+      assertNotNull(SimpleMetaDataInterceptor.data);
+      assertEquals("metadata", SimpleMetaDataInterceptor.data);
+      
+      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/SerializeContainerProxyWithSimpleMetaDataInVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataInVmTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataInVmTestCase.java	2008-01-31 14:19:50 UTC (rev 69499)
@@ -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 SerializeContainerProxyWithSimpleMetaDataInVmTestCase extends SerializeContainerProxyWithSimpleMetaDataTest
+{
+
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("SerializeContainerProxyWithSimpleMetaDataInVmTestCase");
+      suite.addTestSuite(SerializeContainerProxyWithSimpleMetaDataInVmTestCase.class);
+      return suite;
+   }
+
+   public SerializeContainerProxyWithSimpleMetaDataInVmTestCase(String name)
+   {
+      super(name, new InProcessProxyFileCreator(new SerializeContainerProxyWithSimpleMetaDataDelegate()));
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataOutOfVmTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataOutOfVmTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataOutOfVmTestCase.java	2008-01-31 14:19:50 UTC (rev 69499)
@@ -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 SerializeContainerProxyWithSimpleMetaDataOutOfVmTestCase extends SerializeContainerProxyWithSimpleMetaDataTest
+{
+
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("SerializeContainerProxyWithSimpleMetaDataOutOfVmTestCase");
+      suite.addTestSuite(SerializeContainerProxyWithSimpleMetaDataOutOfVmTestCase.class);
+      return suite;
+   }
+
+   public SerializeContainerProxyWithSimpleMetaDataOutOfVmTestCase(String name)
+   {
+      super(name, new OutOfProcessProxyFileCreator(SerializeContainerProxyWithSimpleMetaDataDelegate.class.getName()));
+   }
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataTest.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataTest.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SerializeContainerProxyWithSimpleMetaDataTest.java	2008-01-31 14:19:50 UTC (rev 69499)
@@ -0,0 +1,54 @@
+/*
+  * 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 java.rmi.MarshalledObject;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 64431 $
+ */
+public abstract class SerializeContainerProxyWithSimpleMetaDataTest extends AbstractSerializeContainerTest
+{
+   public SerializeContainerProxyWithSimpleMetaDataTest(String name, ProxyFileCreator creator)
+   {
+      super(name, creator);
+   }
+
+   public void testContainerProxy() throws Exception
+   {
+      try
+      {
+         SomeInterface si = getSerializedProxy();
+         
+         SimpleMetaDataInterceptor.data = null;
+         si.helloWorld();
+         assertNotNull(SimpleMetaDataInterceptor.data);
+         assertEquals("metadata", SimpleMetaDataInterceptor.data);
+      }
+      catch(Exception e)
+      {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SimpleMetaDataInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SimpleMetaDataInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/SimpleMetaDataInterceptor.java	2008-01-31 14:19:50 UTC (rev 69499)
@@ -0,0 +1,49 @@
+/*
+* 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.Serializable;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleMetaDataInterceptor implements Interceptor, Serializable
+{
+   public static String data;
+   
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      data = (String)invocation.getMetaData("TEST", "value");
+      return invocation.invokeNext();
+   }
+
+}




More information about the jboss-cvs-commits mailing list