[jboss-cvs] JBossAS SVN: r63898 - in projects/microcontainer/trunk/aop-mc-int/src: tests/org/jboss/test/microcontainer/support and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 6 23:36:03 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-07-06 23:36:03 -0400 (Fri, 06 Jul 2007)
New Revision: 63898
Added:
projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecorated-flawed.xml
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrant.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirect.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirectMBean.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantImpl.java
Modified:
projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecoratedTestCase.xml
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/JMXDecoratedTestCase.java
Log:
[JBMICROCONT-109] Test handling of @JMX.registerDirectly
Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecorated-flawed.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecorated-flawed.xml (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecorated-flawed.xml 2007-07-07 03:36:03 UTC (rev 63898)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- This bean will fail to deploy due to invalid @JMX config,
+ so we don't include it in the main deployment file that gets validated -->
+
+ <bean name="FlawedRegistrant" class="org.jboss.test.microcontainer.support.JmxRegistrantImpl">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="test:name=FlawedRegistrant", exposedInterface=org.jboss.test.microcontainer.support.JmxRegistrant.class,registerDirectly=true)</annotation>
+ </bean>
+</deployment>
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecorated-flawed.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecoratedTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecoratedTestCase.xml 2007-07-07 02:30:11 UTC (rev 63897)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXDecoratedTestCase.xml 2007-07-07 03:36:03 UTC (rev 63898)
@@ -63,4 +63,12 @@
<bean name="AnnotatedBean" class="org.jboss.test.microcontainer.support.SimpleBeanAnnotatedImpl"/>
<bean name="AnnotatedBean2" class="org.jboss.test.microcontainer.support.SimpleBeanAnnotatedImpl2"/>
+
+ <bean name="DirectRegistrant" class="org.jboss.test.microcontainer.support.JmxRegistrantDirect">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="test:name=DirectRegistrant", exposedInterface=org.jboss.test.microcontainer.support.JmxRegistrantDirectMBean.class,registerDirectly=true)</annotation>
+ </bean>
+
+ <bean name="NotDirectRegistrant" class="org.jboss.test.microcontainer.support.JmxRegistrantDirect">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="test:name=NotDirectRegistrant", exposedInterface=org.jboss.test.microcontainer.support.JmxRegistrantDirectMBean.class,registerDirectly=false)</annotation>
+ </bean>
</deployment>
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrant.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrant.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrant.java 2007-07-07 03:36:03 UTC (rev 63898)
@@ -0,0 +1,34 @@
+/*
+ * 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.microcontainer.support;
+
+/**
+ * A MBeanRegistrationListener.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface JmxRegistrant
+{
+ boolean isRegisteredInJmx();
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrant.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirect.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirect.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirect.java 2007-07-07 03:36:03 UTC (rev 63898)
@@ -0,0 +1,36 @@
+/*
+ * 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.microcontainer.support;
+
+/**
+ * StandardMBean version of JmxRegistrantImpl.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class JmxRegistrantDirect
+ extends JmxRegistrantImpl
+ implements JmxRegistrantDirectMBean
+{
+
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirect.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirectMBean.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirectMBean.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirectMBean.java 2007-07-07 03:36:03 UTC (rev 63898)
@@ -0,0 +1,34 @@
+/*
+ * 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.microcontainer.support;
+
+/**
+ * Interface for StandardMBean version of JmxRegistrantImpl.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public interface JmxRegistrantDirectMBean extends JmxRegistrant
+{
+
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantDirectMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantImpl.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantImpl.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantImpl.java 2007-07-07 03:36:03 UTC (rev 63898)
@@ -0,0 +1,64 @@
+/*
+ * 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.microcontainer.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * A JmxRegistrantImpl.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class JmxRegistrantImpl implements JmxRegistrant, MBeanRegistration
+{
+ private boolean registered;
+
+ public boolean isRegisteredInJmx()
+ {
+ return registered;
+ }
+
+ public void postDeregister()
+ {
+ registered = false;
+ }
+
+ public void postRegister(Boolean registrationDone)
+ {
+ registered = true;
+ }
+
+ public void preDeregister() throws Exception
+ {
+ // no-op
+ }
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
+ {
+ return name;
+ }
+
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/JmxRegistrantImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/JMXDecoratedTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/JMXDecoratedTestCase.java 2007-07-07 02:30:11 UTC (rev 63897)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/JMXDecoratedTestCase.java 2007-07-07 03:36:03 UTC (rev 63898)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.microcontainer.test;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanServer;
@@ -30,6 +32,7 @@
import org.jboss.aop.microcontainer.aspects.jmx.JMX;
import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.support.JmxRegistrant;
import org.jboss.test.microcontainer.support.MetaDataContextInterceptor;
import org.jboss.test.microcontainer.support.SimpleBean;
import org.jboss.test.microcontainer.support.SimpleBeanImplMBean;
@@ -117,4 +120,59 @@
assertEquals(jmx, MetaDataContextInterceptor.classAnnotation);
}
+
+ /**
+ * Tests that adding the registerDirectly=true attribute allows a
+ * standard MBean to be registered directly, while not specifying it
+ * causes a proxy to be registered (even if the bean is a standard MBean).
+ * Also confirms a bean that isn't an MBean will fail to deploy if
+ * registerDirectly=true.
+ *
+ * @throws Exception
+ */
+ public void testRegisterDirectly() throws Exception
+ {
+ MBeanServer server = (MBeanServer) getBean("MBeanServer");
+ assertNotNull(server);
+
+ ObjectName name = new ObjectName("test:name=DirectRegistrant");
+ MBeanInfo info = server.getMBeanInfo(name);
+ assertNotNull(info);
+ MBeanAttributeInfo[] attrs = info.getAttributes();
+ assertEquals(1, attrs.length);
+ assertEquals("RegisteredInJmx", attrs[0].getName());
+ assertTrue(attrs[0].isReadable());
+ assertFalse(attrs[0].isWritable());
+
+ JmxRegistrant bean = (JmxRegistrant) getBean("DirectRegistrant");
+ assertTrue("MBeanRegistration callbacks invoked", bean.isRegisteredInJmx());
+
+ name = new ObjectName("test:name=NotDirectRegistrant");
+ info = server.getMBeanInfo(name);
+ assertNotNull(info);
+ attrs = info.getAttributes();
+ assertEquals(1, attrs.length);
+ assertEquals("RegisteredInJmx", attrs[0].getName());
+ assertTrue(attrs[0].isReadable());
+ assertFalse(attrs[0].isWritable());
+
+ bean = (JmxRegistrant) getBean("NotDirectRegistrant");
+ assertFalse("MBeanRegistration callbacks not invoked", bean.isRegisteredInJmx());
+
+ // Deploy a bean that should fail as it's not an mbean
+
+ deploy("JMXDecorated-flawed.xml");
+
+ name = new ObjectName("test:name=FlawedRegistrant");
+ assertFalse(name + " not registered", server.isRegistered(name));
+
+ Object broken = null;
+ try
+ {
+ broken = getBean("FlawedRegistrant");
+ }
+ catch (Exception good) {}
+
+ assertNull("FlawedRegistrant did not deploy", broken);
+ }
}
More information about the jboss-cvs-commits
mailing list