User: juhalindfors
  Date: 02/02/03 11:07:12

  Added:       src/main/test/compliance/loading LoadingSUITE.java
                        MLetTEST.java
  Log:
  
  
  Revision  Changes    Path
  1.1                  jmx/src/main/test/compliance/loading/LoadingSUITE.java
  
  Index: LoadingSUITE.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package test.compliance.loading;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  public class LoadingSUITE extends TestSuite
  {
     public static void main(String[] args)
     {
        junit.textui.TestRunner.run(suite());
     }
  
     public static Test suite()
     {
        TestSuite suite = new TestSuite("MLet Tests");
  
        suite.addTest(new TestSuite(MLetTEST.class));
        
        return suite;
     }
  
  }
  
  
  
  1.1                  jmx/src/main/test/compliance/loading/MLetTEST.java
  
  Index: MLetTEST.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package test.compliance.loading;
  
  import junit.framework.TestCase;
  import junit.framework.AssertionFailedError;
  
  import javax.management.MBeanServer;
  import javax.management.MBeanServerFactory;
  import javax.management.ObjectName;
  import javax.management.ServiceNotFoundException;
  import javax.management.MBeanException;
  
  import javax.management.loading.MLet;
  import javax.management.loading.MLetMBean;
  
  public class MLetTEST extends TestCase
  {
     public MLetTEST(String s)
     {
        super(s);
     }
  
     public void testCreateAndRegister()
     {
        try 
        {
           MBeanServer server = MBeanServerFactory.createMBeanServer();
           MLet mlet = new MLet();
           ObjectName name = new ObjectName("test:name=mlet");
        
           server.registerMBean(mlet, name);
        }
        catch (AssertionFailedError e)
        {
           // defensive: in case assertXXX() or fail() are later added
           throw e;
        }
        catch (Throwable t)
        {
           fail("Unexpected error: " + t.toString());
        }
     }
     
     public void testBasicMLetFileLoad()
     {
        // NOTE: 
        // the urls used here are relative to the location of the build.xml
        
        try
        {
           MBeanServer server = MBeanServerFactory.createMBeanServer();
           MLet mlet = new MLet();
           ObjectName name = new ObjectName("test:name=mlet");
           server.registerMBean(mlet, name);
           
           server.invoke(name, "getMBeansFromURL", 
           new Object[] { 
"file:./src/main/test/compliance/loading/support/mlet/BasicConfig.mlet" },
           new String[] { String.class.getName() }
           );
           
           assertTrue(server.isRegistered(new ObjectName("test:name=Trivial")));
           assertTrue(server.getMBeanInfo(new ObjectName("test:name=Trivial")) != 
null);
           
           server.invoke(new ObjectName("test:name=Trivial"), "doOperation",
           new Object[] { "Test" },
           new String[] { String.class.getName() }
           );
        }
        catch (AssertionFailedError e)
        {
           throw e;   
        }
        catch (Throwable t)
        {
           fail("Unexpected error: " + t.toString());
        }
     }
     
     public void testMalformedURLLoad()
     {
        // NOTE:
        // the urls used here are relative to the location of the build.xml
        
        try
        {
           MBeanServer server = MBeanServerFactory.createMBeanServer();
           MLet mlet = new MLet();
           ObjectName name = new ObjectName("test:name=mlet");
           server.registerMBean(mlet, name);
           
           server.invoke(name, "getMBeansFromURL",
           new Object[] { 
"src/main/test/compliance/loading/support/mlet/BasicConfig.mlet" },
           new String[] { String.class.getName() }
           );
           
           // should not reach here
           fail("FAILS IN RI: Malformed URL in getMBeansURL() should result in 
ServiceNotFoundException thrown.");
        }
        catch (AssertionFailedError e)
        {
           // defensive: in case assertXXX() or fail() are later added
           throw e;
        }
        catch (MBeanException e)
        {
           assertTrue(e.getTargetException() instanceof ServiceNotFoundException);
        }
        catch (Throwable t)
        {
           fail("Unexpected error: " + t.toString());
        }   
     }
     
     public void testMissingMLetTagInLoad()
     {
        // NOTE:
        // the urls used here are relative to the location of the build.xml
        
        try
        {
           MBeanServer server = MBeanServerFactory.createMBeanServer();
           MLet mlet = new MLet();
           ObjectName name = new ObjectName("test:name=mlet");
           server.registerMBean(mlet, name);
           
           server.invoke(name, "getMBeansFromURL",
           new Object[] { 
"file:./src/main/test/compliance/loading/support/mlet/MissingMLET.mlet" },
           new String[] { String.class.getName() }
           );
           
           // should not reach here
           fail("MLet text file missing the MLET tag should result in 
ServiceNotFoundException thrown.");
        }
        catch (AssertionFailedError e)
        {
           // defensive: in case assertXXX() or fail() are added later
           throw e;
        }
        catch (MBeanException e)
        {
           assertTrue(e.getTargetException() instanceof ServiceNotFoundException);
        }
        catch (Throwable t)
        {
           fail("Unexpected error: " + t.toString());
        }
     }
  
     public void testMissingMandatoryArchiveTagInLoad()
     {
        // NOTE:
        // the urls used here are relative to the location of the build.xml
        
        try
        {
           MBeanServer server = MBeanServerFactory.createMBeanServer();
           MLet mlet = new MLet();
           ObjectName name = new ObjectName("test:name=mlet");
           server.registerMBean(mlet, name);
           
           server.invoke(name, "getMBeansFromURL",
           new Object[] { 
"file:./src/main/test/compliance/loading/support/mlet/MissingMandatoryArchive.mlet" },
           new String[] { String.class.getName() }
           );
           
           // should not reach here
           fail("MLet text file missing mandatory ARCHIVE attribute should result in 
ServiceNotFoundException thrown.");
        }
        catch (AssertionFailedError e)
        {
           // defensive: in case assertXXX() or fail() are added later
           throw e;
        }
        catch (MBeanException e)
        {
           assertTrue(e.getTargetException() instanceof ServiceNotFoundException);
        }
        catch (Throwable t)
        {
           fail("Unexpected error: " + t.toString());
        }
     }
     
     public void testMissingMandatoryCodeTagInLoad()
     {
        // NOTE:
        // the urls used here are relative to the location of the build.xml
        
        try
        {
           MBeanServer server = MBeanServerFactory.createMBeanServer();
           MLet mlet = new MLet();
           ObjectName name = new ObjectName("test:name=mlet");
           server.registerMBean(mlet, name);
           
           server.invoke(name, "getMBeansFromURL",
           new Object[] { 
"file:./src/main/test/compliance/loading/support/mlet/MissingMAndatoryCode.mlet" },
           new String[] { String.class.getName() }
           );
           
           // should not reach here
           fail("MLet text file missing mandatory CODE attribute should result in 
ServiceNotFoundException thrown.");
        }
        catch (AssertionFailedError e)
        {
           // defensive: in case assertXXX() or fail() are added later
           throw e;
        }
        catch (MBeanException e)
        {
           assertTrue(e.getTargetException() instanceof ServiceNotFoundException);
        }
        catch (Throwable t)
        {
           fail("Unexpected error: " + t.toString());
        }
     }         
     
  }
  
  
  

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

Reply via email to