Package javax.management.relation

Examples of javax.management.relation.RelationService


         fail(e.toString());
      }

      try
      {
         server.addNotificationListener(testName, new RelationService(true), null, null);
      }
      catch (Exception e)
      {
         fail(e.toString());
      }
View Full Code Here


   /**
    * Test the constructor
    */
   public void testConstructor() throws Exception
   {
      RelationService rs = null;
      rs = new RelationService(true);
      assertEquals(true, rs.getPurgeFlag());

      rs = new RelationService(false);
      assertEquals(false, rs.getPurgeFlag());
   }
View Full Code Here

         createRolesB(server);
         RelationSupport support = null;
         ObjectName rsupp = null;
         String result = null;
         Listener listener = new Listener(RelationNotification.RELATION_MBEAN_CREATION);
         RelationService rs = (RelationService) services.get(service);
         server.addNotificationListener(service, listener, null, null);
         support = new RelationSupport("id", service, server, "relationTypeB",
                                       rolesB);
         rsupp = new ObjectName("test:add=relation");
         server.registerMBean(support, rsupp);
         rs.addRelation(rsupp);
         result = rs.isRelation(rsupp);
         assertEquals("id", result);
         listener.check(1);
      }
      finally
      {
View Full Code Here

   {
      MBeanServer server = MBeanServerFactory.createMBeanServer();
      try
      {
         ObjectName service = createRelationService("test:type=service", null);
         RelationService rs = (RelationService) services.get(service);
         createRelationTypeB(service);
         createRolesB(server);
         RelationSupport support = null;
         ObjectName name = null;
         support = new RelationSupport("id", service, server, "relationTypeB",
                                          rolesB);
         name = new ObjectName("test:type=relation");
         server.registerMBean(support, name);

         boolean caught = false;
         try
         {
            rs.addRelation(null);
         }
         catch (IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("addRelation allows null relation");

         caught = false;
         try
         {
            rs.addRelation(name);
         }
         catch (RelationServiceNotRegisteredException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("addRelation allowed when not registered");

         ObjectName badRelation = null;
         server.registerMBean(rs, service);
         badRelation = new ObjectName("test:type=bad");
         server.registerMBean(new Trivial(), badRelation);

         caught = false;
         try
         {
            rs.addRelation(badRelation);
         }
         catch (NoSuchMethodException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("addRelation allowed when not a relation");

         caught = false;
         try
         {
            rs.addRelation(name);
            rs.addRelation(name);
         }
         catch (InvalidRelationIdException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("addRelation allows duplicate relation ids");

         rs.removeRelation("id");
         server.unregisterMBean(name);

         caught = false;
         try
         {
            rs.addRelation(name);
         }
         catch (InstanceNotFoundException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("addRelation allows unregistered relation");

         ObjectName service2 = createRelationService("test:type=service2", null);
         createRelationTypeB(service2);
         ObjectName name2 = null;
         support = new RelationSupport("id", service2, server, "relationTypeB",
                                          rolesB);
         name2 = new ObjectName("test:type=relation2");
         server.registerMBean(support, name2);

         caught = false;
         try
         {
            rs.addRelation(name2);
         }
         catch (InvalidRelationServiceException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("addRelation allows registration in the wrong relation service");

         support = new RelationSupport("id", service, server, "relationTypeX",
                                          rolesB);
         name = new ObjectName("test:type=relationX");
         server.registerMBean(support, name);

         caught = false;
         try
         {
            rs.addRelation(name);
         }
         catch (RelationTypeNotFoundException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("addRelation allows registration with invalid relation type");

         createRelationTypeC(service);
         createRolesC(server);
         createRolesCZ(server);
         support = new RelationSupport("idC", service, server, "relationTypeB",
                                          rolesC);
         name = new ObjectName("test:type=relationC");
         server.registerMBean(support, name);

         caught = false;
         try
         {
            rs.addRelation(name);
         }
         catch (RoleNotFoundException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("addRelation allows registration with invalid role name");

         support = new RelationSupport("idCZ", service, server, "relationTypeC",
                                          rolesCZ);
         name = new ObjectName("test:type=relationCZ");
         server.registerMBean(support, name);

         caught = false;
         try
         {
            rs.addRelation(name);
         }
         catch (InvalidRoleValueException e)
         {
            caught = true;
         }
View Full Code Here

   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

   public void testAddRelationTypeErrors() throws Exception
   {
      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

         createRelationTypeB(service);
         createRolesB(server);
         RelationSupport support = null;
         Integer readB1 = null;
         Integer readB2 = null;
         RelationService rs = (RelationService) services.get(service);
         support = new RelationSupport("id", service, server,
                                          "relationTypeB", rolesB);
         addRelation(server, service, support, "test:type=support");
         readB1 = rs.checkRoleReading("roleB1", "relationTypeB");
         readB2 = rs.checkRoleReading("roleB2", "relationTypeB");

         assertEquals(0, readB1.intValue());
         assertEquals(RoleStatus.ROLE_NOT_READABLE, readB2.intValue());
      }
      finally
View Full Code Here

    * Test check role reading errors
    */
   public void testCheckRoleReadingErrors() throws Exception
   {
      ObjectName service = createRelationService("test:type=service", null);
      RelationService rs = (RelationService) services.get(service);
      createRelationTypeB(service);
      createRolesB(null);

      boolean caught = false;
      try
      {
         rs.checkRoleReading(null, "relationTypeB");
      }
      catch(IllegalArgumentException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("checkRoleReading allows null role name");

      caught = false;
      try
      {
         rs.checkRoleReading("roleB1", null);
      }
      catch(IllegalArgumentException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("checkRoleReading allows null relation name");

      caught = false;
      try
      {
         rs.checkRoleReading("roleB1", "rubbish");
      }
      catch(RelationTypeNotFoundException e)
      {
         caught = true;
      }
View Full Code Here

         RelationSupport support = null;
         Integer writeB1normal = null;
         Integer writeB2normal = null;
         Integer writeB1init = null;
         Integer writeB2init = null;
         RelationService rs = (RelationService) services.get(service);
         support = new RelationSupport("id", service, server,
                                       "relationTypeB", rolesB);
         addRelation(server, service, support, "test:type=support");
         writeB1normal = rs.checkRoleWriting(roleB1, "relationTypeB", new Boolean(false));
         writeB2normal = rs.checkRoleWriting(roleB2, "relationTypeB", new Boolean(false));
         writeB1init = rs.checkRoleWriting(roleB1, "relationTypeB", new Boolean(true));
         writeB2init = rs.checkRoleWriting(roleB2, "relationTypeB", new Boolean(true));
         assertEquals(RoleStatus.ROLE_NOT_WRITABLE, writeB1normal.intValue());
         assertEquals(0, writeB2normal.intValue());
         assertEquals(0, writeB1init.intValue());
         assertEquals(0, writeB2init.intValue());
      }
View Full Code Here

    * Test check role writing errors
    */
   public void testCheckRoleWritingErrors() throws Exception
   {
      ObjectName service = createRelationService("test:type=service", null);
      RelationService rs = (RelationService) services.get(service);
      createRelationTypeB(service);
      createRolesB(null);

      boolean caught = false;
      try
      {
         rs.checkRoleWriting(null, "relationTypeB", new Boolean(true));
      }
      catch(IllegalArgumentException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("checkRoleWriting allows null role name");

      caught = false;
      try
      {
         rs.checkRoleWriting(roleB1, null, new Boolean(true));
      }
      catch(IllegalArgumentException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("checkRoleWriting allows null relation name");

      caught = false;
      try
      {
         rs.checkRoleWriting(roleB1, "relationTypeB", null);
      }
      catch(IllegalArgumentException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("checkRoleWriting allows null init flag");

      caught = false;
      try
      {
         rs.checkRoleWriting(roleB1, "rubbish", new Boolean(true));
      }
      catch(RelationTypeNotFoundException e)
      {
         caught = true;
      }
View Full Code Here

TOP

Related Classes of javax.management.relation.RelationService

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.