User: ejort   
  Date: 02/01/26 07:12:10

  Added:       src/main/test/compliance/relation BasicTEST.java
                        RelationSUITE.java RelationUnitTestSUITE.java
  Log:
  Simple relation test
  
  Revision  Changes    Path
  1.1                  jmx/src/main/test/compliance/relation/BasicTEST.java
  
  Index: BasicTEST.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package test.compliance.relation;
  
  import junit.framework.TestCase;
  
  import java.io.*;
  import java.util.*;
  import javax.management.*;
  import javax.management.relation.*;
  
  /**
   * Basic relation test
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]";>Trevor Squires</a>.
   */
  public class BasicTEST
    extends TestCase
  {
    public BasicTEST(String s)
    {
      super(s);
    }
  
    public void fail(Exception e)
    {
      CharArrayWriter caw = new CharArrayWriter();
      PrintWriter pw = new PrintWriter(caw);
      e.printStackTrace(pw);
      pw.flush();
      fail(caw.toString());
    }
  
    public void testTemp()
    {
      try
      {
        MBeanServer server = MBeanServerFactory.createMBeanServer();
        ObjectName relationService = new ObjectName("X:type=RelationService");
        server.createMBean("javax.management.relation.RelationService",
                           relationService,
                           new Object[] { new Boolean(true) },
                           new String[] { "boolean" });
  
        RoleInfo[] roleInfos = new RoleInfo[] { 
          new RoleInfo("TestRole", "test.compliance.standard.support.Trivial",
            true, true, 1, 2, "Test description") };
        server.invoke(relationService, "createRelationType",
          new Object[] { "TestRelationType", roleInfos },
          new String[] { "java.lang.String", "[Ljavax.management.relation.RoleInfo;" 
});
  
        ObjectName mBean1 = new ObjectName("X:type=MBean,no=1");
        server.createMBean("test.compliance.standard.support.Trivial",
                           mBean1);
        ObjectName mBean2 = new ObjectName("X:type=MBean,no=2");
        server.createMBean("test.compliance.standard.support.Trivial",
                           mBean2);
  
        ArrayList mBeans = new ArrayList();
        mBeans.add(mBean1);
        mBeans.add(mBean2);
  
        RoleList roles = new RoleList();
        roles.add(new Role("TestRole", mBeans));
  
        server.invoke(relationService, "createRelation",
          new Object[] { "TestRelationId", "TestRelationType", roles },
          new String[] { "java.lang.String", "java.lang.String",
                         "javax.management.relation.RoleList" });         
  
        Map map = (Map) server.invoke(relationService, "getReferencedMBeans",
          new Object[] { "TestRelationId" },
          new String[] { "java.lang.String" });
        assertEquals(map.size(), 2);
  
        server.unregisterMBean(mBean2);
  
        map = (Map) server.invoke(relationService, "getReferencedMBeans",
          new Object[] { "TestRelationId" },
          new String[] { "java.lang.String" });
        assertEquals(map.size(), 1);
  
        server.unregisterMBean(mBean1);
  
        boolean caught = false;
        try
        {
          map = (Map) server.invoke(relationService, "getReferencedMBeans",
            new Object[] { "TestRelationId" },
            new String[] { "java.lang.String" });
        }
        catch (Exception e)
        {
          caught = true;
        }
        assertEquals(caught, true);
      }
      catch (MBeanException mbe)
      {
        Exception e = mbe.getTargetException();
        fail(e);
      }
      catch (Exception e)
      {
        fail(e);
      }
    }
  }
  
  
  
  1.1                  jmx/src/main/test/compliance/relation/RelationSUITE.java
  
  Index: RelationSUITE.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package test.compliance.relation;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  /**
   * Tests for the relation service.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Adrian Brock</a>.
   */
  public class RelationSUITE
    extends TestSuite
  {
    /**
     * Run the tests
     * 
     * @param args the arguments for the test
     */
    public static void main(String[] args)
    {
      junit.textui.TestRunner.run(suite());
    }
  
    /**
     * Get a list of tests.
     *
     * @return the tests
     */
    public static Test suite()
    {
      TestSuite suite = new TestSuite("Relation Service Tests");
  
      suite.addTest(RelationUnitTestSUITE.suite());
  
      return suite;
    }
  }
  
  
  
  1.1                  jmx/src/main/test/compliance/relation/RelationUnitTestSUITE.java
  
  Index: RelationUnitTestSUITE.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package test.compliance.relation;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  /**
   * Relation Unit tests.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Adrian Brock</a>.
   */
  public class RelationUnitTestSUITE
    extends TestSuite
  {
    /**
     * Run the tests
     * 
     * @param args the arguments for the test
     */
    public static void main(String[] args)
    {
      junit.textui.TestRunner.run(suite());
    }
  
    /**
     * Get a list of tests.
     *
     * @return the tests
     */
    public static Test suite()
    {
      TestSuite suite = new TestSuite("Relation Service Unit Tests");
  
      suite.addTest(new TestSuite(BasicTEST.class));
  
      return suite;
    }
  }
  
  
  

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

Reply via email to