Examples of RelationTypeSupport


Examples of javax.management.relation.RelationTypeSupport

  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

Examples of javax.management.relation.RelationTypeSupport

  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)
    {
      caught = true;
    }
View Full Code Here

Examples of javax.management.relation.RelationTypeSupport

  {
    // 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)
    {
      fail(e.toString());
    }
    RelationTypeSupport support2 = null;

    try
    {
      // Serialize it
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(support);
   
      // Deserialize it
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      ObjectInputStream ois = new ObjectInputStream(bais);
      support2 = (RelationTypeSupport) ois.readObject();
    }
    catch (IOException ioe)
    {
      fail(ioe.toString());
    }
    catch (ClassNotFoundException cnfe)
    {
      fail(cnfe.toString());
    }

    // Did it work?
    assertEquals("name", support2.getRelationTypeName());
    ArrayList result = (ArrayList) support2.getRoleInfos();
    assertEquals(2, result.size());
  }
View Full Code Here

Examples of javax.management.relation.RelationTypeSupport

      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");
View Full Code Here

Examples of javax.management.relation.RelationTypeSupport

   {
      RoleInfo roleInfo1 = null;
      RoleInfo roleInfo2 = null;
      RoleInfo[] roleInfos = null;
      RelationService rs = null;
      RelationTypeSupport rtsupp = null;

      // Null relation type
      boolean caught = false;
      try
      {
         roleInfo1 = new RoleInfo("roleInfo1", Trivial.class.getName());
         roleInfo2 = new RoleInfo("roleInfo2", Trivial.class.getName());
         roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 };
         rs = new RelationService(true);
         rs.addRelationType(null);
      }
      catch (IllegalArgumentException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("addRelationType allows null relation type");

      // Duplicate relation types
      caught = false;
      try
      {
         rtsupp = new RelationTypeSupport("RelationTypeName", roleInfos);
         rs.addRelationType(rtsupp);
         rs.addRelationType(rtsupp);
      }
      catch (InvalidRelationTypeException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("addRelationType allows duplication relation types");

      // Duplicate role infos
      caught = false;
      try
      {
         roleInfos[1] = roleInfos[0];
         rtsupp = new RelationTypeSupport("RelationTypeName1", roleInfos);
         rs.addRelationType(rtsupp);
      }
      catch (InvalidRelationTypeException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("addRelationType allows duplicate role names");

      // Null role info
      caught = false;
      try
      {
         roleInfos[1] = null;
         rtsupp = new RelationTypeSupport("RelationTypeName1", roleInfos);
         rs.addRelationType(rtsupp);
      }
      catch (InvalidRelationTypeException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("addRelationType allows null role info");

      // No role info
      caught = false;
      try
      {
         rtsupp = new RelationTypeSupport("RelationTypeName1", new RoleInfo[0]);
         rs.addRelationType(rtsupp);
      }
      catch (InvalidRelationTypeException e)
      {
         caught = true;
View Full Code Here

Examples of javax.management.relation.RelationTypeSupport

   private static final QName NAME_QNAME = new QName("", NAME);
   private static final QName ROLE_INFOS_QNAME = new QName("", ROLE_INFOS);

   public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException
   {
      RelationTypeSupport relTypeSup = (RelationTypeSupport)value;
      context.startElement(name, attributes);
      context.serialize(NAME_QNAME, null, relTypeSup.getRelationTypeName());
      for (Iterator i = relTypeSup.getRoleInfos().iterator(); i.hasNext();)
      {
         context.serialize(Constants.QNAME_LITERAL_ITEM, null, i.next());
      }
      context.endElement();
   }
View Full Code Here

Examples of javax.management.relation.RelationTypeSupport

  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

Examples of javax.management.relation.RelationTypeSupport

  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)
    {
      caught = true;
    }
View Full Code Here

Examples of javax.management.relation.RelationTypeSupport

  {
    // 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)
    {
      fail(e.toString());
    }
    RelationTypeSupport support2 = null;

    try
    {
      // Serialize it
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(support);
   
      // Deserialize it
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      ObjectInputStream ois = new ObjectInputStream(bais);
      support2 = (RelationTypeSupport) ois.readObject();
    }
    catch (IOException ioe)
    {
      fail(ioe.toString());
    }
    catch (ClassNotFoundException cnfe)
    {
      fail(cnfe.toString());
    }

    // Did it work?
    assertEquals("name", support2.getRelationTypeName());
    ArrayList result = (ArrayList) support2.getRoleInfos();
    assertEquals(2, result.size());
  }
View Full Code Here

Examples of javax.management.relation.RelationTypeSupport

      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");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.