[jboss-cvs] JBossAS SVN: r69381 - in trunk/system-jmx/src: tests/org/jboss/test/system and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jan 27 20:57:36 EST 2008
Author: alesj
Date: 2008-01-27 20:57:36 -0500 (Sun, 27 Jan 2008)
New Revision: 69381
Added:
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/CLDeployer.java
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/JmxCL.java
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/JmxCLMBean.java
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/Tester.java
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/TesterMBean.java
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/DeployersTestSuite.java
trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/ServiceUnitNameTestCase.java
Modified:
trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java
trunk/system-jmx/src/tests/org/jboss/test/system/SystemTestSuite.java
Log:
Test ServiceDeployer being unit name aware.
Modified: trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java 2008-01-28 00:07:50 UTC (rev 69380)
+++ trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -64,6 +64,7 @@
throw new IllegalArgumentException("Null controller");
this.controller = controller;
setComponentsOnly(true);
+ // TODO setUseUnitName(true);
}
Modified: trunk/system-jmx/src/tests/org/jboss/test/system/SystemTestSuite.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/SystemTestSuite.java 2008-01-28 00:07:50 UTC (rev 69380)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/SystemTestSuite.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -27,6 +27,7 @@
import org.jboss.test.system.controller.test.ControllerTestSuite;
import org.jboss.test.system.metadata.test.MetaDataTestSuite;
+import org.jboss.test.system.deployers.test.DeployersTestSuite;
/**
* System Test Suite.
@@ -47,7 +48,8 @@
suite.addTest(MetaDataTestSuite.suite());
suite.addTest(ControllerTestSuite.suite());
-
+ suite.addTest(DeployersTestSuite.suite());
+
return suite;
}
}
Added: trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/CLDeployer.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/CLDeployer.java (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/CLDeployer.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -0,0 +1,37 @@
+/*
+* 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.system.deployers.support;
+
+import org.jboss.deployers.spi.deployer.helpers.AbstractTopLevelClassLoaderDeployer;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CLDeployer extends AbstractTopLevelClassLoaderDeployer
+{
+ protected ClassLoader createTopLevelClassLoader(DeploymentContext deploymentContext) throws Exception
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return new JmxCL(loader);
+ }
+}
Added: trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/JmxCL.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/JmxCL.java (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/JmxCL.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -0,0 +1,33 @@
+/*
+* 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.system.deployers.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JmxCL extends ClassLoader implements JmxCLMBean
+{
+ public JmxCL(ClassLoader parent)
+ {
+ super(parent);
+ }
+}
Added: trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/JmxCLMBean.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/JmxCLMBean.java (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/JmxCLMBean.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -0,0 +1,29 @@
+/*
+* 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.system.deployers.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface JmxCLMBean
+{
+}
Added: trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/Tester.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/Tester.java (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/Tester.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -0,0 +1,44 @@
+/*
+* 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.system.deployers.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class Tester implements TesterMBean
+{
+ public void create() throws Exception
+ {
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void destroy()
+ {
+ }
+}
Added: trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/TesterMBean.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/TesterMBean.java (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/deployers/support/TesterMBean.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -0,0 +1,31 @@
+/*
+* 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.system.deployers.support;
+
+import org.jboss.system.Service;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface TesterMBean extends Service
+{
+}
Added: trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/DeployersTestSuite.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/DeployersTestSuite.java (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/DeployersTestSuite.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -0,0 +1,48 @@
+/*
+* 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.system.deployers.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Service deployers tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DeployersTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Deployers Tests");
+
+ suite.addTest(ServiceUnitNameTestCase.suite());
+
+ return suite;
+ }
+}
Added: trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/ServiceUnitNameTestCase.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/ServiceUnitNameTestCase.java (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/ServiceUnitNameTestCase.java 2008-01-28 01:57:36 UTC (rev 69381)
@@ -0,0 +1,190 @@
+/*
+* 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.system.deployers.test;
+
+import java.util.Collections;
+import java.lang.reflect.Method;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.plugins.deployers.DeployersImpl;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.StructuralDeployers;
+import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.system.ServiceController;
+import org.jboss.system.server.jmx.LazyMBeanServer;
+import org.jboss.system.deployers.ServiceDeployer;
+import org.jboss.system.deployers.ServiceDeploymentDeployer;
+import org.jboss.system.metadata.ServiceDeployment;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.test.AbstractSystemTest;
+import org.jboss.test.system.deployers.support.CLDeployer;
+import org.jboss.test.system.deployers.support.Tester;
+import org.jboss.test.system.deployers.support.JmxCL;
+import org.jboss.mx.server.ServerConstants;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * Test component name usage.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServiceUnitNameTestCase extends AbstractSystemTest
+{
+ public ServiceUnitNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(ServiceUnitNameTestCase.class);
+ }
+
+ public void testServiceDeployerComponentName() throws Exception
+ {
+ SecurityManager sm = suspendSecurity();
+ try
+ {
+ MBeanServer mbeanServer = createMBeanServer("jboss");
+ try
+ {
+ ServiceController serviceController = new ServiceController();
+ ObjectName objectName = new ObjectName("jboss.system:service=ServiceController");
+ mbeanServer.registerMBean(serviceController, objectName);
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ mbeanServer.registerMBean(new JmxCL(loader), new ObjectName("jboss:service=defaultClassLoader"));
+
+ BasicBootstrap bootstrap = new BasicBootstrap();
+ bootstrap.run();
+ Kernel kernel = bootstrap.getKernel();
+ AbstractController controller = (AbstractController)kernel.getController();
+
+ serviceController.setMBeanServer(mbeanServer);
+ serviceController.setKernel(kernel);
+
+ MainDeployerImpl mainDeployer = new MainDeployerImpl();
+ mainDeployer.setStructuralDeployers(new StructuralDeployers()
+ {
+ public DeploymentContext determineStructure(Deployment deployment) throws DeploymentException
+ {
+ return new AbstractDeploymentContext("SMD", "");
+ }
+ });
+ DeployersImpl deployersImpl = new DeployersImpl(controller);
+ deployersImpl.addDeployer(new ServiceDeployer(serviceController));
+ deployersImpl.addDeployer(new ServiceDeploymentDeployer());
+ deployersImpl.addDeployer(new CLDeployer());
+ deployersImpl.addDeployer(new SMDParsingDeployer());
+ mainDeployer.setDeployers(deployersImpl);
+
+ Deployment deployment = new AbstractDeployment("SMD");
+ mainDeployer.addDeployment(deployment);
+ mainDeployer.process();
+
+ mainDeployer.checkComplete(deployment);
+ }
+ finally
+ {
+ mbeanServer.unregisterMBean(objectName);
+ }
+ }
+ finally
+ {
+ MBeanServerFactory.releaseMBeanServer(mbeanServer);
+ }
+ }
+ finally
+ {
+ resumeSecurity(sm);
+ }
+ }
+
+ private class SMDParsingDeployer extends AbstractParsingDeployerWithOutput<ServiceDeployment>
+ {
+ public SMDParsingDeployer()
+ {
+ super(ServiceDeployment.class);
+ }
+
+ protected ServiceDeployment getServiceDeployment() throws Exception
+ {
+ ServiceMetaData metaData = new ServiceMetaData();
+ metaData.setObjectName(new ObjectName("jboss.system:service=Tester"));
+ metaData.setCode(Tester.class.getName());
+ metaData.setConstructor(new ServiceConstructorMetaData());
+ ServiceDependencyMetaData o = new ServiceDependencyMetaData();
+ o.setIDependOn("somenonexistant");
+ metaData.setDependencies(Collections.singletonList(o));
+
+ ServiceDeployment serviceDeployment = new ServiceDeployment();
+ serviceDeployment.setServices(Collections.singletonList(metaData));
+ return serviceDeployment;
+ }
+
+ protected ServiceDeployment parse(DeploymentUnit deploymentUnit, String s, ServiceDeployment deployment) throws Exception
+ {
+ return getServiceDeployment();
+ }
+
+ protected ServiceDeployment parse(DeploymentUnit deploymentUnit, String s, String s1, ServiceDeployment deployment) throws Exception
+ {
+ return getServiceDeployment();
+ }
+ }
+
+ private MBeanServer createMBeanServer(String domain) throws Exception
+ {
+ MBeanServer server;
+
+ String builder = System.getProperty(ServerConstants.MBEAN_SERVER_BUILDER_CLASS_PROPERTY, ServerConstants.DEFAULT_MBEAN_SERVER_BUILDER_CLASS);
+ System.setProperty(ServerConstants.MBEAN_SERVER_BUILDER_CLASS_PROPERTY, builder);
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Class clazz = cl.loadClass("java.lang.management.ManagementFactory");
+ Class[] sig = null;
+ Method method = clazz.getMethod("getPlatformMBeanServer", sig);
+ Object[] args = null;
+ server = (MBeanServer)method.invoke(null, args);
+ // Tell the MBeanServerLocator to point to this mbeanServer
+ MBeanServerLocator.setJBoss(server);
+ /* If the LazyMBeanServer was used, we need to reset to the jboss
+ MBeanServer to use our implementation for the jboss services.
+ */
+ return LazyMBeanServer.resetToJBossServer(server);
+ }
+}
More information about the jboss-cvs-commits
mailing list