[jboss-cvs] JBossAS SVN: r69761 - in projects/aop/trunk/aop/src: resources/test/duplicatemethod and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Feb 10 18:32:25 EST 2008


Author: stalep
Date: 2008-02-10 18:32:25 -0500 (Sun, 10 Feb 2008)
New Revision: 69761

Added:
   projects/aop/trunk/aop/src/resources/test/duplicatemethod/
   projects/aop/trunk/aop/src/resources/test/duplicatemethod/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/DuplicateMethodTestCase.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/TestDupe.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/TestDupeInterceptor.java
Log:
Simple testcase to recreate the duplicate method error when creating a proxy of
a method thats already pointcuted.


Added: projects/aop/trunk/aop/src/resources/test/duplicatemethod/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/duplicatemethod/jboss-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/src/resources/test/duplicatemethod/jboss-aop.xml	2008-02-10 23:32:25 UTC (rev 69761)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+  <bind pointcut="execution(* TestDupe*->foo())">
+    <interceptor class="TestDupeInterceptor"/>
+  </bind>
+</aop>
\ No newline at end of file

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/DuplicateMethodTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/DuplicateMethodTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/DuplicateMethodTestCase.java	2008-02-10 23:32:25 UTC (rev 69761)
@@ -0,0 +1,117 @@
+/*
+  * 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.duplicatemethod;
+
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import javassist.util.proxy.MethodFilter;
+import javassist.util.proxy.ProxyFactory;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.aop.AOPTestWithSetup;
+
+/**
+ * A DuplicateMethodTestCase.
+ * 
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class DuplicateMethodTestCase extends AOPTestWithSetup
+{
+
+   public DuplicateMethodTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("DuplicateMethodTestCase");
+      suite.addTestSuite(DuplicateMethodTestCase.class);
+      return suite;
+   }
+   
+   public void testDupe()
+   {
+      
+      if(System.getSecurityManager() != null)
+      {
+         try 
+         {
+            AccessController.doPrivileged(new PrivilegedExceptionAction()
+            {
+               public Object run()
+               {
+                  generateProxy();
+                  return null;
+               }
+            });
+         }
+         catch (PrivilegedActionException e)
+         {
+            Exception ex = e.getException();
+            if (ex instanceof RuntimeException)
+            {
+               throw (RuntimeException)ex;
+            }
+            throw new RuntimeException(ex);
+         }
+
+      }
+      else
+         System.out.println("SystemManager == NULL");
+   }
+   
+   public void generateProxy()
+   {
+      System.out.println("Generating proxy");
+      ProxyFactory f = new ProxyFactory();
+      f.setSuperclass(TestDupe.class);
+      f.setFilter(new MethodFilter() {
+         public boolean isHandled(Method m) {
+            // ignore finalize()
+            return !m.getName().equals("finalize");
+         }
+      });
+      Class c = f.createClass();
+
+      try
+      {
+         TestDupe td = (TestDupe) c.newInstance();
+         td.foo();
+      }
+      catch (InstantiationException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+      catch (IllegalAccessException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/TestDupe.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/TestDupe.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/TestDupe.java	2008-02-10 23:32:25 UTC (rev 69761)
@@ -0,0 +1,37 @@
+/*
+  * 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.duplicatemethod;
+
+/**
+ * A TestDupe.
+ * 
+ * @author <a href="stalep at gmail.com">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestDupe
+{
+
+   public void foo()
+   {
+      
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/TestDupeInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/TestDupeInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/duplicatemethod/TestDupeInterceptor.java	2008-02-10 23:32:25 UTC (rev 69761)
@@ -0,0 +1,47 @@
+/*
+  * 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.duplicatemethod;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * A TestDupeInterceptor.
+ * 
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestDupeInterceptor implements Interceptor
+{
+
+   public String getName()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      return invocation.invokeNext();
+   }
+
+}




More information about the jboss-cvs-commits mailing list