[jboss-cvs] JBossAS SVN: r72718 - in projects/jboss-aspects/trunk/current-invocation: src/test/java/org/jboss/aspects and 13 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 25 04:37:20 EDT 2008


Author: wolfc
Date: 2008-04-25 04:37:20 -0400 (Fri, 25 Apr 2008)
New Revision: 72718

Added:
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/CheckCurrentInvocationInterceptor.java
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/Company.java
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/Worker.java
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/unit/
   projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/unit/SubInvocationTestCase.java
   projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/
   projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/
   projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/
   projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/currentinvocation/
   projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/currentinvocation/test/
   projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/currentinvocation/test/subinvocation/
   projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/currentinvocation/test/subinvocation/unit/
   projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/currentinvocation/test/subinvocation/unit/SubInvocationTestCase-aop.xml
Modified:
   projects/jboss-aspects/trunk/current-invocation/pom.xml
Log:
JBASPECT-8: unit test

Modified: projects/jboss-aspects/trunk/current-invocation/pom.xml
===================================================================
--- projects/jboss-aspects/trunk/current-invocation/pom.xml	2008-04-25 08:35:46 UTC (rev 72717)
+++ projects/jboss-aspects/trunk/current-invocation/pom.xml	2008-04-25 08:37:20 UTC (rev 72718)
@@ -118,6 +118,13 @@
     </dependency>
     
     <dependency>
+      <groupId>org.jboss.aspects</groupId>
+      <artifactId>jboss-aspects-test</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
       <groupId>org.jboss.microcontainer</groupId>
       <artifactId>jboss-kernel</artifactId>
       <scope>test</scope>

Added: projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/CheckCurrentInvocationInterceptor.java
===================================================================
--- projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/CheckCurrentInvocationInterceptor.java	                        (rev 0)
+++ projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/CheckCurrentInvocationInterceptor.java	2008-04-25 08:37:20 UTC (rev 72718)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.aspects.currentinvocation.test.subinvocation;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aspects.currentinvocation.CurrentInvocation;
+import org.junit.Assert;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CheckCurrentInvocationInterceptor implements Interceptor
+{
+   public String getName()
+   {
+      return getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      Assert.assertNotNull(CurrentInvocation.getCurrentInvocation());
+      Object result = invocation.invokeNext();
+      Assert.assertNotNull(CurrentInvocation.getCurrentInvocation());
+      return result;
+   }
+
+}

Added: projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/Company.java
===================================================================
--- projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/Company.java	                        (rev 0)
+++ projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/Company.java	2008-04-25 08:37:20 UTC (rev 72718)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.aspects.currentinvocation.test.subinvocation.beans;
+
+import org.jboss.aspects.currentinvocation.CurrentInvocation;
+import org.junit.Assert;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Company
+{
+   private Worker worker = new Worker();
+   
+   public void deliverProduct()
+   {
+      Assert.assertNotNull(CurrentInvocation.getCurrentInvocation());
+      Assert.assertEquals(this, CurrentInvocation.getCurrentInvocation().getTargetObject());
+      worker.buildProduct();
+      Assert.assertNotNull("Current invocation is null, while still in method", CurrentInvocation.getCurrentInvocation());
+      Assert.assertEquals(this, CurrentInvocation.getCurrentInvocation().getTargetObject());
+   }
+}

Added: projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/Worker.java
===================================================================
--- projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/Worker.java	                        (rev 0)
+++ projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/beans/Worker.java	2008-04-25 08:37:20 UTC (rev 72718)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.aspects.currentinvocation.test.subinvocation.beans;
+
+import org.jboss.aspects.currentinvocation.CurrentInvocation;
+import org.junit.Assert;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Worker
+{
+   public void buildProduct()
+   {
+      Assert.assertNotNull(CurrentInvocation.getCurrentInvocation());
+      Assert.assertEquals(this, CurrentInvocation.getCurrentInvocation().getTargetObject());
+   }
+}

Added: projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/unit/SubInvocationTestCase.java
===================================================================
--- projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/unit/SubInvocationTestCase.java	                        (rev 0)
+++ projects/jboss-aspects/trunk/current-invocation/src/test/java/org/jboss/aspects/currentinvocation/test/subinvocation/unit/SubInvocationTestCase.java	2008-04-25 08:37:20 UTC (rev 72718)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.aspects.currentinvocation.test.subinvocation.unit;
+
+import org.jboss.aspects.currentinvocation.test.subinvocation.beans.Company;
+import org.jboss.aspects.test.AbstractAspectTestCase;
+
+/**
+ * Run with: -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SubInvocationTestCase extends AbstractAspectTestCase
+{
+   public SubInvocationTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testRecursive()
+   {
+      Company company = new Company();
+      company.deliverProduct();
+   }
+}

Added: projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/currentinvocation/test/subinvocation/unit/SubInvocationTestCase-aop.xml
===================================================================
--- projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/currentinvocation/test/subinvocation/unit/SubInvocationTestCase-aop.xml	                        (rev 0)
+++ projects/jboss-aspects/trunk/current-invocation/src/test/resources/org/jboss/aspects/currentinvocation/test/subinvocation/unit/SubInvocationTestCase-aop.xml	2008-04-25 08:37:20 UTC (rev 72718)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+   <interceptor class="org.jboss.aspects.currentinvocation.test.subinvocation.CheckCurrentInvocationInterceptor" scope="PER_VM"/>
+   
+   <bind pointcut="execution(public * org.jboss.aspects.currentinvocation.test.subinvocation.beans.*->*(..))">
+      <interceptor class="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
+      <interceptor-ref name="org.jboss.aspects.currentinvocation.test.subinvocation.CheckCurrentInvocationInterceptor"/>
+   </bind>
+</aop>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list