[jboss-cvs] JBossAS SVN: r59707 - in branches/Branch_AOP_1_5/aop/src: resources/test/dispatcher and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 17 13:52:00 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-01-17 13:52:00 -0500 (Wed, 17 Jan 2007)
New Revision: 59707

Added:
   branches/Branch_AOP_1_5/aop/src/resources/test/dispatcher/
   branches/Branch_AOP_1_5/aop/src/resources/test/dispatcher/jboss-aop.xml
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/CheckInterceptor.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/ContainerPOJO.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/DispatcherInterceptor.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/DispatcherTestCase.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/TargetInterceptor.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/WovenPOJO.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/WovenPOJOClient.java
Log:
Add some tests to try to reproduce Tim Fox's problem

Added: branches/Branch_AOP_1_5/aop/src/resources/test/dispatcher/jboss-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/dispatcher/jboss-aop.xml	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/dispatcher/jboss-aop.xml	2007-01-17 18:52:00 UTC (rev 59707)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+   <interceptor class="org.jboss.test.aop.dispatcher.DispatcherInterceptor"/>
+   <interceptor class="org.jboss.test.aop.dispatcher.CheckInterceptor"/>
+   <interceptor class="org.jboss.test.aop.dispatcher.TargetInterceptor"/>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.dispatcher.WovenPOJOClient->*(..))">
+	   <interceptor-ref name="org.jboss.test.aop.dispatcher.DispatcherInterceptor"/>
+   </bind>
+   <bind pointcut="execution(* org.jboss.test.aop.dispatcher.WovenPOJO->advised(..))">
+	   <interceptor-ref name="org.jboss.test.aop.dispatcher.CheckInterceptor"/>
+   </bind>
+   
+   <domain name="ClassContainerDomain">
+      <bind pointcut="execution(* *->*(..))">
+		   <interceptor-ref name="org.jboss.test.aop.dispatcher.TargetInterceptor"/>
+      </bind>
+      <bind pointcut="execution(* *->advised(..))">
+		   <interceptor-ref name="org.jboss.test.aop.dispatcher.CheckInterceptor"/>
+      </bind>
+   </domain>
+</aop>

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/CheckInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/CheckInterceptor.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/CheckInterceptor.java	2007-01-17 18:52:00 UTC (rev 59707)
@@ -0,0 +1,45 @@
+/*
+* 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.dispatcher;
+
+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 CheckInterceptor implements Interceptor
+{
+   static boolean intercepted = false;
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      intercepted = true;
+      return invocation.invokeNext();
+   }
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/ContainerPOJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/ContainerPOJO.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/ContainerPOJO.java	2007-01-17 18:52:00 UTC (rev 59707)
@@ -0,0 +1,38 @@
+/*
+* 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.dispatcher;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContainerPOJO
+{
+   public void advised(String name) 
+   {
+   }
+   
+   public void notAdvised(String name)
+   {
+   }
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/DispatcherInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/DispatcherInterceptor.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/DispatcherInterceptor.java	2007-01-17 18:52:00 UTC (rev 59707)
@@ -0,0 +1,50 @@
+/*
+* 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.dispatcher;
+
+import org.jboss.aop.Dispatcher;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DispatcherInterceptor implements Interceptor
+{
+   static boolean intercepted = false;
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      intercepted = true;
+      Object oid = ((MethodInvocation)invocation).getArguments()[0];
+      invocation.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, oid);
+      return Dispatcher.singleton.invoke(invocation);
+   }
+
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/DispatcherTestCase.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/DispatcherTestCase.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/DispatcherTestCase.java	2007-01-17 18:52:00 UTC (rev 59707)
@@ -0,0 +1,103 @@
+/*
+  * 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.dispatcher;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.ClassContainer;
+import org.jboss.aop.Dispatcher;
+import org.jboss.aop.DomainDefinition;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ *
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 37406 $
+ */
+public class DispatcherTestCase extends TestCase
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("DotInPointcutNameTester");
+      suite.addTestSuite(DispatcherTestCase.class);
+      return suite;
+   }
+
+   public DispatcherTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testWovenClassAsTarget()throws Exception
+   {
+      WovenPOJO pojo = new WovenPOJO();
+      Dispatcher.singleton.registerTarget("WovenPOJO", pojo);
+      
+      WovenPOJOClient client = new WovenPOJOClient();
+      DispatcherInterceptor.intercepted = false;
+      CheckInterceptor.intercepted = false;
+      client.advised("WovenPOJO");
+      assertTrue(DispatcherInterceptor.intercepted);
+      assertTrue(CheckInterceptor.intercepted);
+      
+      DispatcherInterceptor.intercepted = false;
+      CheckInterceptor.intercepted = false;
+      client.notAdvised("WovenPOJO");
+      assertTrue(DispatcherInterceptor.intercepted);
+      assertFalse(CheckInterceptor.intercepted);
+   }
+
+
+   public void testClassContainerAsTarget()throws Exception
+   {
+      DomainDefinition domainDef = AspectManager.instance().getContainer("ClassContainerDomain");
+      ClassContainer container = new ClassContainer("X", domainDef.getManager());
+      container.setClass(ContainerPOJO.class);
+      container.initializeClassContainer();
+      
+      ContainerPOJO pojo = new ContainerPOJO();
+      Dispatcher.singleton.registerTarget("ContainerPOJO", container);
+      
+      WovenPOJOClient client = new WovenPOJOClient();
+      DispatcherInterceptor.intercepted = false;
+      CheckInterceptor.intercepted = false;
+      TargetInterceptor.targetObject = pojo;
+      client.advised("ContainerPOJO");
+      assertTrue(DispatcherInterceptor.intercepted);
+      assertTrue(CheckInterceptor.intercepted);
+      
+      DispatcherInterceptor.intercepted = false;
+      CheckInterceptor.intercepted = false;
+      TargetInterceptor.targetObject = pojo;
+      client.notAdvised("ContainerPOJO");
+      assertTrue(DispatcherInterceptor.intercepted);
+      assertFalse(CheckInterceptor.intercepted);
+   }
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/TargetInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/TargetInterceptor.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/TargetInterceptor.java	2007-01-17 18:52:00 UTC (rev 59707)
@@ -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.dispatcher;
+
+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 TargetInterceptor implements Interceptor
+{
+   static Object targetObject;
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      if (invocation.getTargetObject() == null && targetObject != null)
+      {
+         invocation.setTargetObject(targetObject);
+         targetObject = null;
+      }
+      return invocation.invokeNext();
+   }
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/WovenPOJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/WovenPOJO.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/WovenPOJO.java	2007-01-17 18:52:00 UTC (rev 59707)
@@ -0,0 +1,38 @@
+/*
+* 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.dispatcher;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WovenPOJO
+{
+   public void advised(String name) 
+   {
+   }
+   
+   public void notAdvised(String name)
+   {
+   }
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/WovenPOJOClient.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/WovenPOJOClient.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/dispatcher/WovenPOJOClient.java	2007-01-17 18:52:00 UTC (rev 59707)
@@ -0,0 +1,38 @@
+/*
+* 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.dispatcher;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WovenPOJOClient
+{
+   public void advised(String name) 
+   {
+   }
+   
+   public void notAdvised(String name)
+   {
+   }
+}




More information about the jboss-cvs-commits mailing list