1 22 package org.jboss.test.jmx.test; 23 24 import java.io.File ; 25 import java.net.InetAddress ; 26 import java.net.URL ; 27 import java.util.ArrayList ; 28 import java.util.Arrays ; 29 import java.util.Collection ; 30 import java.util.Iterator ; 31 import java.util.Set ; 32 import javax.management.MBeanRegistrationException ; 33 import javax.management.MalformedObjectNameException ; 34 import javax.management.ObjectInstance ; 35 import javax.management.ObjectName ; 36 import javax.management.ReflectionException ; 37 import javax.management.RuntimeMBeanException ; 38 import javax.naming.Context ; 39 import javax.naming.InitialContext ; 40 import javax.naming.NamingEnumeration ; 41 import javax.naming.NamingException ; 42 import junit.framework.*; 43 import org.jboss.test.JBossTestCase; 44 import org.jboss.deployment.IncompleteDeploymentException; 45 46 51 public class MBeanDependsOnEJBUnitTestCase 52 extends JBossTestCase 53 { 54 protected final static int INSTALLED = 0; 56 protected final static int CONFIGURED = 1; 57 protected final static int CREATED = 2; 58 protected final static int RUNNING = 3; 59 protected final static int FAILED = 4; 60 protected final static int STOPPED = 5; 61 protected final static int DESTROYED = 6; 62 protected final static int NOTYETINSTALLED = 7; 63 65 ObjectName serviceControllerName; 66 73 public MBeanDependsOnEJBUnitTestCase(String name) 74 { 75 super(name); 76 try 77 { 78 serviceControllerName = new ObjectName ("jboss.system:service=ServiceController"); 79 } 80 catch (Exception e) 81 { 82 } 84 } 85 86 88 89 97 public void testMBeanDependsOnEJB() throws Exception 98 { 99 String mBeancodeUrl = "testdeploy.sar"; 100 String mBeanUrl = "testmbeandependsOnEjb-service.xml"; 101 String ejbUrl = "jmxtest.jar"; 103 getLog().debug("testUrls are : " + mBeanUrl + ", " + ejbUrl); 104 ObjectName objectNameMBean = new ObjectName ("test:name=TestMBeanDependsOnEjb"); 105 ObjectName objectNameEJB = new ObjectName ("jboss.j2ee:service=EJB,name=test/TestDataSource"); 106 deploy(mBeancodeUrl); 108 try 109 { 110 deploy(mBeanUrl); 111 fail("suceeded in deploying mbean with unsatisfied dependency!"); 112 } 113 catch (IncompleteDeploymentException e) 114 { 115 } 118 try 120 { 121 assertTrue("MBean started!", !((String )getServer().getAttribute(objectNameMBean, "StateString")).equals("Started")); 122 deploy(ejbUrl); 123 try 124 { 125 assertTrue("MBean not started!", ((String )getServer().getAttribute(objectNameMBean, "StateString")).equals("Started")); 126 } 127 finally 128 { 129 undeploy(ejbUrl); 130 assertTrue("MBean started!", !((String )getServer().getAttribute(objectNameMBean, "StateString")).equals("Started")); 131 } } 133 finally 134 { 135 undeploy(mBeanUrl); 136 undeploy(mBeancodeUrl); 137 } } 139 140 141 } 142 | Popular Tags |