[jboss-cvs] JBossAS SVN: r58252 - in trunk/testsuite: imports/sections src/main/org/jboss/test/aop/mcjmx src/main/org/jboss/test/aop/test src/resources/aop/mcjmx/META-INF

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 10 13:18:04 EST 2006


Author: kabir.khan at jboss.com
Date: 2006-11-10 13:17:55 -0500 (Fri, 10 Nov 2006)
New Revision: 58252

Added:
   trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/BeanWithDependency.java
   trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/Dependency.java
   trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/InterceptorWithDependency.java
   trunk/testsuite/src/resources/aop/mcjmx/META-INF/dependency-beans.xml
   trunk/testsuite/src/resources/aop/mcjmx/META-INF/has-dependency-beans.xml
Modified:
   trunk/testsuite/imports/sections/aop.xml
   trunk/testsuite/src/main/org/jboss/test/aop/test/MicrocontainerJMXUnitTestCase.java
Log:
[JBAOP-304] Tests for interceptors with dependencies

Modified: trunk/testsuite/imports/sections/aop.xml
===================================================================
--- trunk/testsuite/imports/sections/aop.xml	2006-11-10 18:03:57 UTC (rev 58251)
+++ trunk/testsuite/imports/sections/aop.xml	2006-11-10 18:17:55 UTC (rev 58252)
@@ -215,15 +215,33 @@
 			</fileset>
 		</jar>
 
-		<!-- Create jar for the aop-mc-integration test-->
+		<!-- Create jars for the aop-mc-integration test-->
 		<jar destfile="${build.lib}/aop-mc-jmxtest.jar">
 			<fileset dir="${build.classes}">
 				<include name="org/jboss/test/aop/mcjmx/*.class"/>
+				<exclude name="org/jboss/test/aop/mcjmx/*Dependency.class"/>
 			</fileset>
          <fileset dir="${build.resources}/aop/mcjmx">
 				<include name="META-INF/jboss-beans.xml"/>
 			</fileset>
 		</jar>
+		<jar destfile="${build.lib}/aop-mc-jmxtest-has-dependency.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/aop/mcjmx/BeanWithDependency.class"/>
+				<include name="org/jboss/test/aop/mcjmx/InterceptorWithDependency.class"/>
+			</fileset>
+         <fileset dir="${build.resources}/aop/mcjmx">
+				<include name="META-INF/has-dependency-beans.xml"/>
+			</fileset>
+		</jar>
+		<jar destfile="${build.lib}/aop-mc-jmxtest-dependency.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/aop/mcjmx/Dependency.class"/>
+			</fileset>
+         <fileset dir="${build.resources}/aop/mcjmx">
+				<include name="META-INF/dependency-beans.xml"/>
+			</fileset>
+		</jar>
 
       <!-- jars for scoped test -->
       <jar destfile="${build.lib}/aop-scopedtest1.aop">

Added: trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/BeanWithDependency.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/BeanWithDependency.java	2006-11-10 18:03:57 UTC (rev 58251)
+++ trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/BeanWithDependency.java	2006-11-10 18:17:55 UTC (rev 58252)
@@ -0,0 +1,52 @@
+/*
+* 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.mcjmx;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at JMX(exposedInterface=BeanInterface.class, name="jboss.aop:name=BeanWithDependency")
+public class BeanWithDependency implements BeanInterface
+{
+   int property;
+   
+   public int getProperty()
+   {
+      return property;
+   }
+
+   public void setProperty(int i)
+   {
+      property = i;
+   }
+
+   public String someAction()
+   {
+      System.out.println("someAction");
+      return InterceptorWithDependency.invoked;
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/Dependency.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/Dependency.java	2006-11-10 18:03:57 UTC (rev 58251)
+++ trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/Dependency.java	2006-11-10 18:17:55 UTC (rev 58252)
@@ -0,0 +1,31 @@
+/*
+* 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.mcjmx;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Dependency
+{
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/InterceptorWithDependency.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/InterceptorWithDependency.java	2006-11-10 18:03:57 UTC (rev 58251)
+++ trunk/testsuite/src/main/org/jboss/test/aop/mcjmx/InterceptorWithDependency.java	2006-11-10 18:17:55 UTC (rev 58252)
@@ -0,0 +1,57 @@
+/*
+* 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.mcjmx;
+
+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 InterceptorWithDependency implements Interceptor
+{
+   static String invoked;
+   Dependency dependency;
+
+   public Dependency getDependency()
+   {
+      return dependency;
+   }
+
+   public void setDependency(Dependency dependency)
+   {
+      this.dependency = dependency;
+   }
+
+   public String getName()
+   {
+      return getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      invoked = "true";
+      return invocation.invokeNext();
+   }
+}

Modified: trunk/testsuite/src/main/org/jboss/test/aop/test/MicrocontainerJMXUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/test/MicrocontainerJMXUnitTestCase.java	2006-11-10 18:03:57 UTC (rev 58251)
+++ trunk/testsuite/src/main/org/jboss/test/aop/test/MicrocontainerJMXUnitTestCase.java	2006-11-10 18:17:55 UTC (rev 58252)
@@ -22,6 +22,7 @@
 package org.jboss.test.aop.test;
 
 import javax.management.Attribute;
+import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 
@@ -61,6 +62,63 @@
       testBean(testerName);
    }
 
+   public void testBeanWithDependencyFromAspect() throws Exception
+   {
+      //Do this twice since there was a problem with redeployment
+      doTestDeployDependencies();
+   }
+   
+   public void testRedeployedBeanWithDependencyFromAspect() throws Exception
+   {
+      //Do this twice since there was a problem with redeployment
+      doTestDeployDependencies();
+   }
+   
+   private void doTestDeployDependencies() throws Exception
+   {
+      deploy("aop-mc-jmxtest-has-dependency.jar");
+      try
+      {
+         MBeanServerConnection server = getServer();
+         ObjectName testerName = new ObjectName("jboss.aop:name=BeanWithDependency");
+         try
+         {
+            server.getMBeanInfo(testerName);
+            fail(testerName + " should not have been found");
+         }
+         catch (InstanceNotFoundException expected)
+         {
+         }
+         
+         deploy("aop-mc-jmxtest-dependency.jar");
+         try
+         {
+            server.setAttribute(testerName, new Attribute("Property", 42));
+            assertEquals(42, server.getAttribute(testerName, "Property"));
+            String ret = (String)server.invoke(testerName, "someAction", new Object[0], new String[0]);
+            assertNotNull(ret);
+            assertEquals("true", ret);
+         }
+         finally
+         {
+            undeploy("aop-mc-jmxtest-dependency.jar");
+         }
+
+         try
+         {
+            server.getMBeanInfo(testerName);
+            fail(testerName + " should not have been found");
+         }
+         catch (InstanceNotFoundException expected)
+         {
+         }
+      }
+      finally
+      {
+         undeploy("aop-mc-jmxtest-has-dependency.jar");
+      }
+   }
+
    private void testBean(ObjectName on) throws Exception
    {
       MBeanServerConnection server = getServer();
@@ -71,6 +129,7 @@
       assertEquals("JMX42", ret);
    }
    
+   
    public static Test suite() throws Exception
    {
       TestSuite suite = new TestSuite();

Added: trunk/testsuite/src/resources/aop/mcjmx/META-INF/dependency-beans.xml
===================================================================
--- trunk/testsuite/src/resources/aop/mcjmx/META-INF/dependency-beans.xml	2006-11-10 18:03:57 UTC (rev 58251)
+++ trunk/testsuite/src/resources/aop/mcjmx/META-INF/dependency-beans.xml	2006-11-10 18:17:55 UTC (rev 58252)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="Dependency" class="org.jboss.test.aop.mcjmx.Dependency"/>
+</deployment>

Added: trunk/testsuite/src/resources/aop/mcjmx/META-INF/has-dependency-beans.xml
===================================================================
--- trunk/testsuite/src/resources/aop/mcjmx/META-INF/has-dependency-beans.xml	2006-11-10 18:03:57 UTC (rev 58251)
+++ trunk/testsuite/src/resources/aop/mcjmx/META-INF/has-dependency-beans.xml	2006-11-10 18:17:55 UTC (rev 58252)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- TODO This is horrible and a pain to enter, replace with aop:aspect once that is working in jboss 5 -->
+   <beanfactory name="DependencyAdvice" class="org.jboss.test.aop.mcjmx.InterceptorWithDependency">
+      <property name="dependency"><inject bean="Dependency"/></property>
+      <install bean="DependencyAdvice$Aspect" method="install">
+      	<parameter><this/></parameter>
+      </install>
+      <uninstall bean="DependencyAdvice$Aspect" method="uninstall"/>
+      <install bean="DependencyAdvice$AspectBinding" method="rebind">
+      	<parameter><inject bean="DependencyAdvice$Aspect" property="definition"/></parameter>
+      </install>
+   </beanfactory>
+   <bean name="DependencyAdvice$Aspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+      <property name="adviceBean">DependencyAdvice</property>
+      <property name="manager"><inject bean="AspectManager" property="aspectManager"/></property>
+   </bean>
+   <bean name="DependencyAdvice$AspectBinding" class="org.jboss.aop.microcontainer.beans.AspectBinding">
+      <property name="pointcut">execution(* org.jboss.test.aop.mcjmx.BeanWithDependency->someAction(..))</property>
+      <property name="aspect"><inject bean="DependencyAdvice$Aspect" property="definition"/></property>
+      <property name="manager"><inject bean="AspectManager" property="aspectManager"/></property>
+   </bean>
+   
+   <bean name="BeanWithDependency" class="org.jboss.test.aop.mcjmx.BeanWithDependency"/>
+   
+</deployment>




More information about the jboss-cvs-commits mailing list