User: d_jencks
  Date: 02/02/20 09:40:11

  Modified:    src/main/org/jboss/test/jmx/test
                        MBeanClassLoaderUnitTestCase.java
  Added:       src/main/org/jboss/test/jmx/test
                        MBeanDependsOnEJBUnitTestCase.java
  Log:
  Made mbean depending on ejb work, with a test case
  
  Revision  Changes    Path
  1.2       +10 -1     
jbosstest/src/main/org/jboss/test/jmx/test/MBeanClassLoaderUnitTestCase.java
  
  Index: MBeanClassLoaderUnitTestCase.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/jmx/test/MBeanClassLoaderUnitTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MBeanClassLoaderUnitTestCase.java 18 Feb 2002 02:15:05 -0000      1.1
  +++ MBeanClassLoaderUnitTestCase.java 20 Feb 2002 17:40:10 -0000      1.2
  @@ -31,7 +31,7 @@
   /**
    * @see       <related>
    * @author    <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
  - * @version   $Revision: 1.1 $
  + * @version   $Revision: 1.2 $
    */
   public class MBeanClassLoaderUnitTestCase
          extends JBossTestCase
  @@ -71,6 +71,15 @@
      // Public --------------------------------------------------------
   
   
  +   /**
  +    * <code>testMBeanClassLoaders</code> tests if two mbeans get the same 
  +    * classloader.  It expects
  +    * the mbeans to get MBeanClassLoaders and that each mbean 
  +    * gets a new instance. 
  +    * Redeployment of an mbean should result in a new classloader.
  +    * When this test was written it failed.
  +    * @exception Exception if an error occurs
  +    */
      public void testMBeanClassLoaders() throws Exception
      {
         String testUrl = "testmbeanclassloader.jar";
  
  
  
  1.1                  
jbosstest/src/main/org/jboss/test/jmx/test/MBeanDependsOnEJBUnitTestCase.java
  
  Index: MBeanDependsOnEJBUnitTestCase.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package org.jboss.test.jmx.test;
  
  import java.io.File;
  import java.net.InetAddress;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.Set;
  import javax.management.MBeanRegistrationException;
  import javax.management.MalformedObjectNameException;
  import javax.management.ObjectInstance;
  import javax.management.ObjectName;
  import javax.management.ReflectionException;
  import javax.management.RuntimeMBeanException;
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingEnumeration;
  import javax.naming.NamingException;
  import junit.framework.*;
  import org.jboss.test.JBossTestCase;
  
  /**
   * @see       <related>
   * @author    <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
   * @version   $Revision: 1.1 $
   */
  public class MBeanDependsOnEJBUnitTestCase
         extends JBossTestCase
  {
     // Constants -----------------------------------------------------
     protected final static int INSTALLED = 0;
     protected final static int CONFIGURED = 1;
     protected final static int CREATED = 2;
     protected final static int RUNNING = 3;
     protected final static int FAILED = 4;
     protected final static int STOPPED = 5;
     protected final static int DESTROYED = 6;
     protected final static int NOTYETINSTALLED = 7;
     // Attributes ----------------------------------------------------
  
     ObjectName serviceControllerName;
     // Static --------------------------------------------------------
     // Constructors --------------------------------------------------
     /**
      * Constructor for the DeployServiceUnitTestCase object
      *
      * @param name  Test case name
      */
     public MBeanDependsOnEJBUnitTestCase(String name)
     {
        super(name);
        try 
        {
           serviceControllerName = new 
ObjectName("jboss.system:service=ServiceController");
        } 
        catch (Exception e) 
        {
        } // end of try-catch
  
     }
  
     // Public --------------------------------------------------------
  
  
     /**
      * <code>testMBeanDependsOnEJB</code> tests that an mbean can depend
      * on an ejb.  All classes are loaded, the mbean is deployed, checked 
      * that it has not started, then the ejb is deployed, and the mbean
      * is checked that it has started.
      *
      * @exception Exception if an error occurs
      */
     public void testMBeanDependsOnEJB() throws Exception
     {
        String mBeancodeUrl = "testdeploy.sar";
        String mBeanUrl = "testmbeandependsOnEjb-service.xml";
        //random choice of ejb...
        String ejbUrl = "jmxtest.jar";
        getLog().debug("testUrls are : " + mBeanUrl + ", " + ejbUrl);
        ObjectName objectNameMBean = new ObjectName("test:name=TestMBeanDependsOnEjb");
        ObjectName objectNameEJB = new 
ObjectName("jboss.j2ee:service=EJB,name=test/TestDataSource");
        //deploy jar
        deploy(mBeancodeUrl);
        deploy(mBeanUrl);
        try 
        {
           assertTrue("MBean started!", 
!((String)getServer().getAttribute(objectNameMBean, "StateString")).equals("Started"));
           deploy(ejbUrl);
           try 
           {
              assertTrue("MBean not started!", 
((String)getServer().getAttribute(objectNameMBean, "StateString")).equals("Started"));
           }
           finally
           {
              undeploy(ejbUrl);
              assertTrue("MBean started!", 
!((String)getServer().getAttribute(objectNameMBean, "StateString")).equals("Started"));
           } // end of try-catch
        }
        finally
        {
           undeploy(mBeanUrl);
           undeploy(mBeancodeUrl);
        } // end of try-catch
     }
  
  
  }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to