Package javax.management.relation

Examples of javax.management.relation.RoleInfo


  /**
   * Basic tests
   */
  public void testBasic()
  {
    RoleInfo roleInfo1 = null;
    RoleInfo roleInfo2 = null;
    RoleInfo[] roleInfos = null;
    RelationTypeSupport support = null;
    try
    {
      roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
      roleInfo2 = new RoleInfo("roleInfo2", RelationSupport.class.getName());
      roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 };
      support = new RelationTypeSupport("name", roleInfos);
    }
    catch (Exception e)
    {
      fail(e.toString());
    }

    // Check the name
    assertEquals("name", support.getRelationTypeName());

    // Check the roleInfos
    ArrayList result = (ArrayList) support.getRoleInfos();
    assertEquals(2, result.size());

    // Check get
    try
    {
      assertEquals(roleInfo1.toString(), support.getRoleInfo("roleInfo1").toString());
      assertEquals(roleInfo2.toString(), support.getRoleInfo("roleInfo2").toString());
    }
    catch (Exception e)
    {
      fail(e.toString());
    }
View Full Code Here


  /**
   * Error handling
   */
  public void testErrorHandling()
  {
    RoleInfo roleInfo1 = null;
    RoleInfo roleInfo2 = null;
    RoleInfo[] roleInfos = null;
    RelationTypeSupport support = null;

    boolean caught = false;
    try
    {
      roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
      roleInfo2 = new RoleInfo("roleInfo2", RelationSupport.class.getName());
      roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 };
      support = new RelationTypeSupport(null, roleInfos);
    }
    catch (IllegalArgumentException e)
    {
      caught = true;
    }
    catch (Exception e)
    {
      fail(e.toString());
    }
    if (caught == false)
      fail("Constructor accepts null relation type name");

    caught = false;
    try
    {
      support = new RelationTypeSupport("name", null);
    }
    catch (IllegalArgumentException e)
    {
      caught = true;
    }
    catch (Exception e)
    {
      fail(e.toString());
    }
    if (caught == false)
      fail("Constructor accepts null role infos");

    caught = false;
    try
    {
      support = new RelationTypeSupport("name", new RoleInfo[0]);
    }
    catch (InvalidRelationTypeException e)
    {
      caught = true;
    }
    catch (Exception e)
    {
      fail(e.toString());
    }
    if (caught == false)
      fail("Constructor accepts no role infos");

    caught = false;
    try
    {
      roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
      roleInfos = new RoleInfo[] { roleInfo1, null };
      support = new RelationTypeSupport("name", roleInfos);
    }
    catch (InvalidRelationTypeException e)
    {
      caught = true;
    }
    catch (Exception e)
    {
      fail(e.toString());
    }
    if (caught == false)
      fail("Constructor accepts null role");

    caught = false;
    try
    {
      roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
      roleInfos = new RoleInfo[] { roleInfo1 };
      support = new RelationTypeSupport("name", roleInfos);
      support.getRoleInfo(null);
    }
    catch (IllegalArgumentException e)
    {
      caught = true;
    }
    catch (Exception e)
    {
      fail(e.toString());
    }
    if (caught == false)
      fail("getRoleInfo allows a null role info name");

    caught = false;
    try
    {
      roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
      roleInfos = new RoleInfo[] { roleInfo1 };
      support = new RelationTypeSupport("name", roleInfos);
      support.getRoleInfo("rubbish");
    }
    catch (RoleInfoNotFoundException e)
View Full Code Here

   * Test serialization.
   */
  public void testSerialization()
  {
    // Create the relationt type support
    RoleInfo roleInfo1 = null;
    RoleInfo roleInfo2 = null;
    RoleInfo[] roleInfos = null;
    RelationTypeSupport support = null;
    try
    {
      roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
      roleInfo2 = new RoleInfo("roleInfo2", RelationSupport.class.getName());
      roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 };
      support = new RelationTypeSupport("name", roleInfos);
    }
    catch (Exception e)
    {
View Full Code Here

  private RoleInfo createRoleInfo(String name, Class mbean,
                                  boolean read, boolean write,
                                  int min, int max)
  {
    RoleInfo result = null;
    try
    {
      result = new RoleInfo(name, mbean.getName(), read, write, min, max, "");
    }
    catch(Exception e)
    {
      fail(e.toString());
    }
View Full Code Here

    Iterator iterator = resolved.iterator();
    while (iterator.hasNext())
    {
      Role role = (Role) iterator.next();
      String roleName = role.getRoleName();
      RoleInfo info = (RoleInfo) infos.get(roleName);
      if (info == null)
        fail("unknown role " + roleName);
      if (info.isReadable() == false)
        fail("role should not be readable " + roleName);
      Role original = removeRole(copy, roleName);
      compareListOfObjectNames(original.getRoleValue(), role.getRoleValue());
    }

    iterator = copy.iterator();
    while (iterator.hasNext())
    {
      Role role = (Role) iterator.next();
      String roleName = role.getRoleName();
      RoleInfo info = (RoleInfo) infos.get(roleName);
      if (info.isReadable() == true)
        fail("missing role " + roleName);
    }
  }
View Full Code Here

    Iterator iterator = unresolved.iterator();
    while (iterator.hasNext())
    {
      RoleUnresolved roleUnresolved = (RoleUnresolved) iterator.next();
      String roleName = roleUnresolved.getRoleName();
      RoleInfo info = (RoleInfo) infos.get(roleName);
      if (info == null)
        fail("unknown role " + roleName);
      if (info.isReadable() == true)
        fail("role should be readable " + roleName);
      removeRole(copy, roleName);
    }

    iterator = copy.iterator();
    while (iterator.hasNext())
    {
      Role role = (Role) iterator.next();
      String roleName = role.getRoleName();
      RoleInfo info = (RoleInfo) infos.get(roleName);
      if (info.isReadable() == false)
        fail("missing unresolved role " + roleName);
    }
  }
View Full Code Here

  private void createRelationTypeA(ObjectName relationService)
  {
    try
    {
      RoleInfo roleInfoA1 = createRoleInfo("roleA1", Trivial.class, true, true, 1, 1);
      RoleInfo[] roleInfos = new RoleInfo[] { roleInfoA1 };
      createRelationType(relationService, "relationTypeA", roleInfos);
      for (int i=0; i < roleInfos.length; i++)
        roleInfosA.put(roleInfos[i].getName(), roleInfos[i]);
    }
View Full Code Here

  private void createRelationTypeB(ObjectName relationService)
  {
    try
    {
      RoleInfo roleInfoB1 = createRoleInfo("roleB1", Trivial.class, true, false, 1, 2);
      RoleInfo roleInfoB2 = createRoleInfo("roleB2", Trivial.class, false, true, 3, 4);
      RoleInfo[] roleInfos = new RoleInfo[] { roleInfoB1, roleInfoB2 };
      createRelationType(relationService, "relationTypeB", roleInfos );
      for (int i=0; i < roleInfos.length; i++)
        roleInfosB.put(roleInfos[i].getName(), roleInfos[i]);
    }
View Full Code Here

  private void createRelationTypeC(ObjectName relationService)
  {
    try
    {
      RoleInfo roleInfoC1 = createRoleInfo("roleC1", Trivial.class, true, false, 1, 2);
      RoleInfo roleInfoC2 = createRoleInfo("roleC2", Trivial.class, false, true, 3, 4);
      RoleInfo[] roleInfos = new RoleInfo[] { roleInfoC1, roleInfoC2 };
      createRelationType(relationService, "relationTypeC", roleInfos );
      for (int i=0; i < roleInfos.length; i++)
        roleInfosC.put(roleInfos[i].getName(), roleInfos[i]);
    }
View Full Code Here

   /**
    * Test add a relation type
    */
   public void testAddRelationType() throws Exception
   {
      RoleInfo roleInfo1 = null;
      RoleInfo roleInfo2 = null;
      RoleInfo[] roleInfos = null;
      RelationService rs = null;
      ArrayList result = null;
      RoleInfo result1 = null;
      RoleInfo result2 = null;
      roleInfo1 = new RoleInfo("roleInfo1", Trivial.class.getName());
      roleInfo2 = new RoleInfo("roleInfo2", Trivial.class.getName());
      roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 };
      RelationTypeSupport rtsupp = new RelationTypeSupport("RelationTypeName",
                                                  roleInfos);
      rs = new RelationService(true);
      rs.addRelationType(rtsupp);
      result = (ArrayList) rs.getRoleInfos("RelationTypeName");
      result1 = rs.getRoleInfo("RelationTypeName", "roleInfo1");
      result2 = rs.getRoleInfo("RelationTypeName", "roleInfo2");

      // Check the roleInfos
      assertEquals(2, result.size());
      assertEquals(roleInfo1.toString(), result1.toString());
      assertEquals(roleInfo2.toString(), result2.toString());
   }
View Full Code Here

TOP

Related Classes of javax.management.relation.RoleInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.