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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jan 13 06:24:53 EST 2008


Author: stalep
Date: 2008-01-13 06:24:52 -0500 (Sun, 13 Jan 2008)
New Revision: 68926

Added:
   projects/aop/trunk/aop/src/resources/test/rebuildcallerchain/
   projects/aop/trunk/aop/src/resources/test/rebuildcallerchain/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/Caller1.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/Caller2.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/RebuildCallerChainInterceptor.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/RebuildCallerChainTestCase.java
Log:
[JBAOP-433] initial testcase

Added: projects/aop/trunk/aop/src/resources/test/rebuildcallerchain/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/rebuildcallerchain/jboss-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/src/resources/test/rebuildcallerchain/jboss-aop.xml	2008-01-13 11:24:52 UTC (rev 68926)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+  <prepare expr="execution(* org.jboss.test.aop.rebuildcallerchain.*->*())" />
+</aop>

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/Caller1.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/Caller1.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/Caller1.java	2008-01-13 11:24:52 UTC (rev 68926)
@@ -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.rebuildcallerchain;
+
+/**
+ * A Caller1.
+ * 
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class Caller1
+{
+
+   public void execute() throws Exception
+   {
+      throw new Exception("This method should not have been called!");
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/Caller2.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/Caller2.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/Caller2.java	2008-01-13 11:24:52 UTC (rev 68926)
@@ -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.rebuildcallerchain;
+
+/**
+ * A Caller2.
+ * 
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class Caller2
+{
+
+   public void execute() throws Exception
+   {
+      throw new Exception("This method should not have been called!");
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/RebuildCallerChainInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/RebuildCallerChainInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/RebuildCallerChainInterceptor.java	2008-01-13 11:24:52 UTC (rev 68926)
@@ -0,0 +1,59 @@
+/*
+  * 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.rebuildcallerchain;
+
+import org.jboss.aop.joinpoint.Invocation;
+
+import org.jboss.aop.advice.Interceptor;
+
+/**
+ * A RebuilCallInterceptor.
+ * 
+ * @author <a href="RebuildCallInterceptorle W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class RebuildCallerChainInterceptor implements Interceptor
+{
+   //@Override
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   //@Override
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      try
+      {
+         System.out.println("Interceptor ignoring call...");
+         return null;
+      }
+      catch(Exception e)
+      {
+         throw e;
+      }
+      finally
+      {
+         
+      }
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/RebuildCallerChainTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/RebuildCallerChainTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildcallerchain/RebuildCallerChainTestCase.java	2008-01-13 11:24:52 UTC (rev 68926)
@@ -0,0 +1,80 @@
+/*
+ * 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.rebuildcallerchain;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AdviceBinding;
+import org.jboss.test.aop.AOPTestWithSetup;
+import org.jboss.test.aop.rebuildingchain.RebuildingChainTestCase;
+
+/**
+ * A RebuildCallerChainTestCase.
+ * 
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class RebuildCallerChainTestCase extends AOPTestWithSetup
+{
+
+   public RebuildCallerChainTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("RebuildCallerChainTestCase");
+      suite.addTestSuite(RebuildCallerChainTestCase.class);
+      return suite;
+   }
+
+   public void testRebuildCallerChain() throws Exception
+   {
+      try
+      {
+         new Caller1().execute();
+
+         // Tests with corresponding prepare statements in jboss-aop.xml. 
+         // Results are the same with <prepare expr="all(testCaseAOP.*)" /> 
+         // 2- Works only on classes that have not been already loaded 
+         // (Caller1) 
+         AdviceBinding bindingCall = new AdviceBinding( 
+               "call(* org.jboss.test.aop.rebuildcallerchain.*->*(..))", null); 
+         bindingCall.addInterceptor(RebuildCallerChainInterceptor.class); 
+
+         AspectManager.instance().addBinding(bindingCall); 
+
+//         new Caller1().execute(); // loaded before addBinding => not ok 
+         new Caller2().execute(); // loaded after addBindingok => ok 
+
+         assertTrue("Rebuilded chain", true);
+      } 
+      catch (Exception e) 
+      {
+         assertFalse("Failed to rebuild chain....", true);
+      }
+}
+
+}




More information about the jboss-cvs-commits mailing list