[jboss-cvs] JBossAS SVN: r84172 - in projects/jboss-deployers/trunk: deployers-vfs/src/test/java/org/jboss/test/deployers and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 13 08:56:27 EST 2009
Author: adrian at jboss.org
Date: 2009-02-13 08:56:27 -0500 (Fri, 13 Feb 2009)
New Revision: 84172
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/JMXTestSuite.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/AbstractJMXBootstrapTest.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/ComplexJMXTestCase.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/SimpleJMXTestCase.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/META-INF/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/META-INF/jboss-beans.xml
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/META-INF/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/META-INF/jboss-beans.xml
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/my-jboss-beans.xml
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/simple.jar/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/simple.jar/META-INF/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/simple.jar/META-INF/jboss-beans.xml
Modified:
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/ComponentDeploymentContext.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTest.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTestDelegate.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/DeployersVFSTestSuite.java
Log:
[JBDEPLOY-158] - Fix duplicate registration of subdeployment mbeans
Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java 2009-02-13 13:55:20 UTC (rev 84171)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -673,7 +673,7 @@
children = new TreeSet<DeploymentContext>(comparator);
children.add(child);
if (server != null)
- registerMBeans(child, true);
+ registerMBeans(child, true, true);
}
public boolean removeChild(DeploymentContext child)
@@ -683,7 +683,7 @@
if (children == null)
return false;
if (server != null)
- unregisterMBeans(child, true);
+ unregisterMBeans(child, true, true);
return children.remove(child);
}
@@ -716,7 +716,7 @@
deployed();
components.add(component);
if (server != null)
- registerMBeans(component, true);
+ registerMBeans(component, true, true);
log.debug("Added component " + component.getName() + " to " + getName());
}
@@ -726,7 +726,7 @@
throw new IllegalArgumentException("Null component");
if (server != null)
- unregisterMBeans(component, true);
+ unregisterMBeans(component, true, true);
List<DeploymentContext> componentComponents = component.getComponents();
if (componentComponents.isEmpty() == false)
log.warn("Removing component " + name + " which still has components " + componentComponents);
@@ -961,12 +961,12 @@
public void postRegister(Boolean registrationDone)
{
if (registrationDone)
- registerMBeans(this, false);
+ registerMBeans(this, false, true);
}
public void preDeregister() throws Exception
{
- unregisterMBeans(this, false);
+ unregisterMBeans(this, false, true);
}
public void postDeregister()
@@ -978,8 +978,9 @@
*
* @param context the context
* @param registerContext whether to register the context or just its children and components
+ * @param registerSubDeployments whether to register subdeployments
*/
- protected void registerMBeans(DeploymentContext context, boolean registerContext)
+ protected void registerMBeans(DeploymentContext context, boolean registerContext, boolean registerSubDeployments)
{
if (registerContext && context instanceof DeploymentMBean)
{
@@ -993,12 +994,15 @@
log.warn("Unable to register deployment mbean " + context.getName(), e);
}
}
- List<DeploymentContext> children = context.getChildren();
- for (DeploymentContext child : children)
- registerMBeans(child, true);
- List<DeploymentContext> components = context.getComponents();
- for (DeploymentContext component : components)
- registerMBeans(component, false);
+ if (registerSubDeployments)
+ {
+ List<DeploymentContext> children = context.getChildren();
+ for (DeploymentContext child : children)
+ registerMBeans(child, true, false);
+ List<DeploymentContext> components = context.getComponents();
+ for (DeploymentContext component : components)
+ registerMBeans(component, false, false);
+ }
}
/**
@@ -1006,8 +1010,9 @@
*
* @param context the context
* @param unregisterContext whether to unregister the context or just its children and components
+ * @param unregisterSubDeployments whether to unregister subdeployments
*/
- protected void unregisterMBeans(DeploymentContext context, boolean unregisterContext)
+ protected void unregisterMBeans(DeploymentContext context, boolean unregisterContext, boolean unregisterSubDeployments)
{
if (unregisterContext && context instanceof DeploymentMBean)
{
@@ -1021,12 +1026,15 @@
log.trace("Unable to unregister deployment mbean " + context.getName(), e);
}
}
- List<DeploymentContext> children = context.getChildren();
- for (DeploymentContext child : children)
- unregisterMBeans(child, true);
- List<DeploymentContext> components = context.getComponents();
- for (DeploymentContext component : components)
- unregisterMBeans(component, false);
+ if (unregisterSubDeployments)
+ {
+ List<DeploymentContext> children = context.getChildren();
+ for (DeploymentContext child : children)
+ unregisterMBeans(child, true, false);
+ List<DeploymentContext> components = context.getComponents();
+ for (DeploymentContext component : components)
+ unregisterMBeans(component, false, false);
+ }
}
@Override
Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/ComponentDeploymentContext.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/ComponentDeploymentContext.java 2009-02-13 13:55:20 UTC (rev 84171)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/ComponentDeploymentContext.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -398,7 +398,7 @@
throw new IllegalArgumentException("Null component");
components.add(component);
if (server != null)
- registerMBeans(component, true);
+ registerMBeans(component, true, true);
}
public boolean removeComponent(DeploymentContext component)
@@ -407,7 +407,7 @@
throw new IllegalArgumentException("Null component");
boolean result = components.remove(component);
if (server != null)
- unregisterMBeans(component, true);
+ unregisterMBeans(component, true, true);
component.cleanup();
return result;
}
@@ -632,12 +632,12 @@
public void postRegister(Boolean registrationDone)
{
if (registrationDone)
- registerMBeans(this, false);
+ registerMBeans(this, false, true);
}
public void preDeregister() throws Exception
{
- unregisterMBeans(this, false);
+ unregisterMBeans(this, false, true);
}
public void postDeregister()
@@ -649,8 +649,9 @@
*
* @param context the context
* @param registerContext whether to register the context or just its children and components
+ * @param registerSubDeployments whether to register subdeployments
*/
- protected void registerMBeans(DeploymentContext context, boolean registerContext)
+ protected void registerMBeans(DeploymentContext context, boolean registerContext, boolean registerSubDeployments)
{
if (registerContext && context instanceof DeploymentMBean)
{
@@ -664,9 +665,12 @@
log.warn("Unable to register deployment mbean " + context.getName(), e);
}
}
- List<DeploymentContext> components = context.getComponents();
- for (DeploymentContext component : components)
- registerMBeans(component, false);
+ if (registerSubDeployments)
+ {
+ List<DeploymentContext> components = context.getComponents();
+ for (DeploymentContext component : components)
+ registerMBeans(component, false, false);
+ }
}
/**
@@ -674,8 +678,9 @@
*
* @param context the context
* @param unregisterContext whether to unregister the context or just its children and components
+ * @param unregisterSubDeployments whether to unregister subdeployments
*/
- protected void unregisterMBeans(DeploymentContext context, boolean unregisterContext)
+ protected void unregisterMBeans(DeploymentContext context, boolean unregisterContext, boolean unregisterSubDeployments)
{
if (unregisterContext && context instanceof DeploymentMBean)
{
@@ -689,9 +694,12 @@
log.trace("Unable to unregister deployment mbean " + context.getName(), e);
}
}
- List<DeploymentContext> components = context.getComponents();
- for (DeploymentContext component : components)
- unregisterMBeans(component, false);
+ if (unregisterSubDeployments)
+ {
+ List<DeploymentContext> components = context.getComponents();
+ for (DeploymentContext component : components)
+ unregisterMBeans(component, false, false);
+ }
}
public String toString()
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTest.java 2009-02-13 13:55:20 UTC (rev 84171)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTest.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -27,6 +27,7 @@
import java.util.List;
import junit.framework.AssertionFailedError;
+
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jboss.classloader.plugins.ClassLoaderUtils;
@@ -39,7 +40,6 @@
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.test.AbstractTestDelegate;
import org.jboss.test.kernel.junit.MicrocontainerTest;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VFS;
@@ -56,7 +56,7 @@
*/
public abstract class BootstrapDeployersTest extends MicrocontainerTest
{
- public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ public static BootstrapDeployersTestDelegate getDelegate(Class<?> clazz) throws Exception
{
return new BootstrapDeployersTestDelegate(clazz);
}
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTestDelegate.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTestDelegate.java 2009-02-13 13:55:20 UTC (rev 84171)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTestDelegate.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -23,6 +23,9 @@
import java.net.URL;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
import org.jboss.classloader.plugins.ClassLoaderUtils;
import org.jboss.classloader.plugins.filter.PatternClassFilter;
import org.jboss.classloader.spi.ClassLoaderDomain;
@@ -33,6 +36,7 @@
import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.deployers.spi.deployer.Deployers;
import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
@@ -49,6 +53,8 @@
private MainDeployerImpl mainDeployer;
+ private MBeanServer server = null;
+
static
{
DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
@@ -94,6 +100,16 @@
super(clazz);
}
+ public MBeanServer getMBeanServer()
+ {
+ return server;
+ }
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
protected void deploy() throws Exception
{
String common = "/bootstrap/bootstrap.xml";
@@ -106,6 +122,12 @@
ClassLoaderDomain domain = system.getDefaultDomain();
domain.setParentPolicy(parentPolicy);
+ if (server != null)
+ {
+ Deployers deployers = getBean("Deployers", ControllerState.INSTALLED, Deployers.class);
+ server.registerMBean(deployers, new ObjectName("test:type=Deployers"));
+ }
+
super.deploy();
}
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/DeployersVFSTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/DeployersVFSTestSuite.java 2009-02-13 13:55:20 UTC (rev 84171)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/DeployersVFSTestSuite.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -34,6 +34,7 @@
import org.jboss.test.deployers.vfs.deployer.nonmetadata.NonMetadataDeployersTestSuite;
import org.jboss.test.deployers.vfs.deployer.validate.ValidateDeployerTestSuite;
import org.jboss.test.deployers.vfs.deploymentfactory.VFSDeploymentFactoryTestSuite;
+import org.jboss.test.deployers.vfs.jmx.JMXTestSuite;
import org.jboss.test.deployers.vfs.managed.VFSManagedTestSuite;
import org.jboss.test.deployers.vfs.matchers.VFSMatchersTestSuite;
import org.jboss.test.deployers.vfs.metadata.VFSMetaDataTestSuite;
@@ -79,6 +80,7 @@
suite.addTest(ValidateDeployerTestSuite.suite());
suite.addTest(AnnotationScanningTestSuite.suite());
suite.addTest(DependencyTestSuite.suite());
+ suite.addTest(JMXTestSuite.suite());
return suite;
}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/JMXTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/JMXTestSuite.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/JMXTestSuite.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.deployers.vfs.jmx;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.deployers.vfs.jmx.test.ComplexJMXTestCase;
+import org.jboss.test.deployers.vfs.jmx.test.SimpleJMXTestCase;
+
+/**
+ * JMXTestSuite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JMXTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("JMX Tests");
+
+ suite.addTest(SimpleJMXTestCase.suite());
+ suite.addTest(ComplexJMXTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/AbstractJMXBootstrapTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/AbstractJMXBootstrapTest.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/AbstractJMXBootstrapTest.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -0,0 +1,167 @@
+/*
+ * 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.test.deployers.vfs.jmx.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+import org.jboss.test.deployers.BootstrapDeployersTestDelegate;
+
+/**
+ * AbstractJMXBootstrapTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractJMXBootstrapTest extends BootstrapDeployersTest
+{
+ public AbstractJMXBootstrapTest(String name)
+ {
+ super(name);
+ }
+
+ public static BootstrapDeployersTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ BootstrapDeployersTestDelegate delegate = BootstrapDeployersTest.getDelegate(clazz);
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ delegate.setMBeanServer(server);
+ return delegate;
+ }
+
+ protected MBeanServer getMBeanServer()
+ {
+ return getDelegate().getMBeanServer();
+ }
+
+ protected Set<ObjectName> assertMBeans(DeploymentUnit unit) throws Exception
+ {
+ Set<ObjectName> names = new HashSet<ObjectName>();
+ assertTopLevelMBean(unit, names);
+ for (DeploymentUnit child : unit.getChildren())
+ assertSubDeploymentMBean(child, names);
+ for (DeploymentUnit component : unit.getComponents())
+ assertComponentMBean(component, names);
+ return names;
+ }
+
+ protected void assertNoMBeans(Set<ObjectName> names) throws Exception
+ {
+ for (ObjectName objectName : names)
+ {
+ boolean result = getMBeanServer().isRegistered(objectName);
+ getLog().debug(objectName + " isRegistered=" + result);
+ assertFalse(objectName + " should NOT be registered with the MBeanServer", result);
+ }
+ }
+
+ protected void assertNoMBeans(DeploymentUnit unit) throws Exception
+ {
+ assertNoTopLevelMBean(unit);
+ for (DeploymentUnit child : unit.getChildren())
+ assertNoSubDeploymentMBean(child);
+ for (DeploymentUnit component : unit.getComponents())
+ assertNoComponentMBean(component);
+ }
+
+ protected void assertTopLevelMBean(DeploymentUnit unit, Set<ObjectName> names) throws Exception
+ {
+ ObjectName objectName = getTopLevelObjectName(unit);
+ names.add(objectName);
+ boolean result = getMBeanServer().isRegistered(objectName);
+ getLog().debug(objectName + " isRegistered=" + result);
+ assertTrue(objectName + " should be registered with the MBeanServer", result);
+ }
+
+ protected void assertNoTopLevelMBean(DeploymentUnit unit) throws Exception
+ {
+ ObjectName objectName = getTopLevelObjectName(unit);
+ boolean result = getMBeanServer().isRegistered(objectName);
+ getLog().debug(objectName + " isRegistered=" + result);
+ assertFalse(objectName + " should NOT be registered with the MBeanServer", result);
+ }
+
+ protected ObjectName getTopLevelObjectName(DeploymentUnit unit) throws Exception
+ {
+ String name = unit.getName();
+ return new ObjectName("jboss.deployment:id=\"" + name + "\",type=Deployment");
+ }
+
+ protected void assertSubDeploymentMBean(DeploymentUnit unit, Set<ObjectName> names) throws Exception
+ {
+ ObjectName objectName = getSubDeploymentObjectName(unit);
+ names.add(objectName);
+ boolean result = getMBeanServer().isRegistered(objectName);
+ getLog().debug(objectName + " isRegistered=" + result);
+ assertTrue(objectName + " should be registered with the MBeanServer", result);
+ for (DeploymentUnit child : unit.getChildren())
+ assertSubDeploymentMBean(child, names);
+ for (DeploymentUnit component : unit.getComponents())
+ assertComponentMBean(component, names);
+ }
+
+ protected void assertNoSubDeploymentMBean(DeploymentUnit unit) throws Exception
+ {
+ ObjectName objectName = getSubDeploymentObjectName(unit);
+ boolean result = getMBeanServer().isRegistered(objectName);
+ getLog().debug(objectName + " isRegistered=" + result);
+ assertFalse(objectName + " should NOT be registered with the MBeanServer", result);
+ for (DeploymentUnit child : unit.getChildren())
+ assertNoSubDeploymentMBean(child);
+ for (DeploymentUnit component : unit.getComponents())
+ assertNoComponentMBean(component);
+ }
+
+ protected ObjectName getSubDeploymentObjectName(DeploymentUnit unit) throws Exception
+ {
+ String name = unit.getName();
+ return new ObjectName("jboss.deployment:id=\"" + name + "\",type=SubDeployment");
+ }
+
+ protected void assertComponentMBean(DeploymentUnit unit, Set<ObjectName> names) throws Exception
+ {
+ ObjectName objectName = getComponentObjectName(unit);
+ names.add(objectName);
+ boolean result = getMBeanServer().isRegistered(objectName);
+ getLog().debug(objectName + " isRegistered=" + result);
+ assertTrue(objectName + " should be registered with the MBeanServer", result);
+ }
+
+ protected void assertNoComponentMBean(DeploymentUnit unit) throws Exception
+ {
+ ObjectName objectName = getComponentObjectName(unit);
+ boolean result = getMBeanServer().isRegistered(objectName);
+ getLog().debug(objectName + " isRegistered=" + result);
+ assertFalse(objectName + " should NOT be registered with the MBeanServer", result);
+ }
+
+ protected ObjectName getComponentObjectName(DeploymentUnit unit) throws Exception
+ {
+ String name = unit.getName();
+ return new ObjectName("jboss.deployment:id=\"" + name + "\",type=Component");
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/ComplexJMXTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/ComplexJMXTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/ComplexJMXTestCase.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.deployers.vfs.jmx.test;
+
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * ComplexJMXTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ComplexJMXTestCase extends AbstractJMXBootstrapTest
+{
+ public ComplexJMXTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(ComplexJMXTestCase.class);
+ }
+
+ public void testComplexJMX() throws Exception
+ {
+ DeploymentUnit unit = addDeployment("/jmx", "complex.jar");
+ Set<ObjectName> names = null;
+ try
+ {
+ getDeployerClient().checkComplete();
+ names = assertMBeans(unit);
+ }
+ finally
+ {
+ undeploy(unit);
+ }
+ assertNoMBeans(names);
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/SimpleJMXTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/SimpleJMXTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/jmx/test/SimpleJMXTestCase.java 2009-02-13 13:56:27 UTC (rev 84172)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.deployers.vfs.jmx.test;
+
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * SimpleJMXTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleJMXTestCase extends AbstractJMXBootstrapTest
+{
+ public SimpleJMXTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(SimpleJMXTestCase.class);
+ }
+
+ public void testSimpleJMX() throws Exception
+ {
+ DeploymentUnit unit = addDeployment("/jmx", "simple.jar");
+ Set<ObjectName> names = null;
+ try
+ {
+ getDeployerClient().checkComplete();
+ names = assertMBeans(unit);
+ }
+ finally
+ {
+ undeploy(unit);
+ }
+ assertNoMBeans(names);
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/META-INF/jboss-beans.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/META-INF/jboss-beans.xml 2009-02-13 13:56:27 UTC (rev 84172)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Complex1" class="java.lang.Object"/>
+</deployment>
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/META-INF/jboss-beans.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/META-INF/jboss-beans.xml 2009-02-13 13:56:27 UTC (rev 84172)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Inner1" class="java.lang.Object"/>
+</deployment>
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/my-jboss-beans.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/my-jboss-beans.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/complex.jar/inner.jar/my-jboss-beans.xml 2009-02-13 13:56:27 UTC (rev 84172)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="My1" class="java.lang.Object"/>
+</deployment>
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/simple.jar/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/simple.jar/META-INF/jboss-beans.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/jmx/simple.jar/META-INF/jboss-beans.xml 2009-02-13 13:56:27 UTC (rev 84172)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Simple1" class="java.lang.Object"/>
+</deployment>
More information about the jboss-cvs-commits
mailing list