User: d_jencks
  Date: 02/02/17 18:15:05

  Added:       src/main/org/jboss/test/jmx/test
                        MBeanClassLoaderUnitTestCase.java
  Log:
  added test of identities of MBeanClassLoaders on redeployment
  
  Revision  Changes    Path
  1.1                  
jbosstest/src/main/org/jboss/test/jmx/test/MBeanClassLoaderUnitTestCase.java
  
  Index: MBeanClassLoaderUnitTestCase.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 MBeanClassLoaderUnitTestCase
         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 MBeanClassLoaderUnitTestCase(String name)
     {
        super(name);
        try 
        {
           serviceControllerName = new 
ObjectName("jboss.system:service=ServiceController");
        } 
        catch (Exception e) 
        {
        } // end of try-catch
  
     }
  
     // Public --------------------------------------------------------
  
  
     public void testMBeanClassLoaders() throws Exception
     {
        String testUrl = "testmbeanclassloader.jar";
        getLog().debug("testUrl is : " + testUrl);
        ObjectName objectNameA = new ObjectName("test:name=TestMBClassLoaderA");
        ObjectName objectNameB = new ObjectName("test:name=TestMBClassLoaderB");
        //deploy jar
        deploy(testUrl);
        //deploy service.xml
        String testServiceUrl = "test-mbean-classloader-service.xml";
        deploy(testServiceUrl);
        String mbclA1 = (String)getServer().getAttribute(objectNameA, "ClassLoader");
        String mbclB1 = (String)getServer().getAttribute(objectNameB, "ClassLoader");
        getLog().debug("classloader for A: " +  mbclA1);
        getLog().debug("classloader for B: " +  mbclB1);
        undeploy(testServiceUrl);
        undeploy(testUrl);
        deploy(testUrl);
        deploy(testServiceUrl);
        String mbclA2 = (String)getServer().getAttribute(objectNameA, "ClassLoader");
        String mbclB2 = (String)getServer().getAttribute(objectNameB, "ClassLoader");
        getLog().debug("classloader for A: " +  mbclA2);
        getLog().debug("classloader for B: " +  mbclB2);
        undeploy(testServiceUrl);
        undeploy(testUrl);
        assertTrue("Classloaders for A and B are the same!", !mbclA1.equals(mbclB1));
        assertTrue("Classloaders for A and B are the same!", !mbclA2.equals(mbclB2));
        assertTrue("First and second Classloaders for A  are the same!", 
!mbclA1.equals(mbclA2));
        assertTrue("First and second Classloaders for B  are the same!", 
!mbclB1.equals(mbclB2));
     }
  
  
  }
  
  
  

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

Reply via email to