Package javax.management.relation

Examples of javax.management.relation.RelationService


         Listener listener = new Listener(RelationNotification.RELATION_MBEAN_CREATION);
         support = new RelationSupport("id1", service, server,
                                       "relationTypeC", rolesC);
         addRelation(server, service, support, "test:type=support1");
         server.addNotificationListener(service, listener, null, null);
         RelationService rs = (RelationService) services.get(service);
         rs.sendRelationCreationNotification("id1");
         on = new ObjectName("test:type=support1");
         RelationNotification rn = listener.check(1);
         assertEquals(new ArrayList(), rn.getMBeansToUnregister());
         assertEquals(new ArrayList(), rn.getNewRoleValue());
         assertEquals(on, rn.getObjectName());
View Full Code Here


   /**
    * Test send relation removal notification errors
    */
   public void testSendRelationCreationNotificationErrors() throws Exception
   {
      RelationService rs = new RelationService(true);

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

      caught = false;
      try
      {
         rs.sendRelationCreationNotification("rubbish");
      }
      catch (RelationNotFoundException e)
      {
         caught = true;
      }
View Full Code Here

         Listener listener = new Listener(RelationNotification.RELATION_MBEAN_REMOVAL);
         support = new RelationSupport("id1", service, server,
                                          "relationTypeC", rolesC);
         addRelation(server, service, support, "test:type=support1");
         server.addNotificationListener(service, listener, null, null);
         RelationService rs = (RelationService) services.get(service);
         test.add(new ObjectName("test:type=test"));
         rs.sendRelationRemovalNotification("id1", test);
         on = new ObjectName("test:type=support1");
         RelationNotification rn = listener.check(1);
         assertEquals(test, rn.getMBeansToUnregister());
         assertEquals(new ArrayList(), rn.getNewRoleValue());
         assertEquals(on, rn.getObjectName());
View Full Code Here

   /**
    * Test send relation removal notification errors
    */
   public void testSendRelationRemovalNotificationErrors() throws Exception
   {
      RelationService rs = new RelationService(true);

      boolean caught = false;
      try
      {
         rs.sendRelationRemovalNotification(null, new ArrayList());
      }
      catch (IllegalArgumentException e)
      {
         caught = true;
      }
      if (caught == false)
         fail("sendRelationRemovalNotification allows null relation id");


      caught = false;
      try
      {
         rs.sendRelationRemovalNotification("rubbish", new ArrayList());
      }
      catch (RelationNotFoundException e)
      {
         caught = true;
      }
View Full Code Here

         Listener listener = new Listener(RelationNotification.RELATION_MBEAN_UPDATE);
         support = new RelationSupport("id1", service, server,
                                          "relationTypeC", rolesC);
         addRelation(server, service, support, "test:type=support1");
         server.addNotificationListener(service, listener, null, null);
         RelationService rs = (RelationService) services.get(service);
         test.add(new ObjectName("test:type=test"));
         rs.sendRoleUpdateNotification("id1", roleB1, test);
         on = new ObjectName("test:type=support1");
         RelationNotification rn = listener.check(1);
         assertEquals(new ArrayList(), rn.getMBeansToUnregister());
         assertEquals(roleB1.getRoleValue(), rn.getNewRoleValue());
         assertEquals(on, rn.getObjectName());
View Full Code Here

   {
      MBeanServer server = MBeanServerFactory.createMBeanServer();
      try
      {
         ObjectName service = createRelationService("test:type=service", server);
         RelationService rs = (RelationService) services.get(service);
         createRelationTypeB(service);
         createRolesB(server);

         boolean caught = false;
         try
         {
            rs.sendRoleUpdateNotification(null, roleB1, new ArrayList());
         }
         catch (IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("sendRoleUpdateNotification allows null relation id");

         RoleList roleList = new RoleList();
         roleList.add(roleB1);
         roleList.add(roleB2);
         rs.createRelation("relationId", "relationTypeB", roleList);

         caught = false;
         try
         {
            rs.sendRoleUpdateNotification("relationId", null, new ArrayList());
         }
         catch (IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("sendRoleUpdateNotification allows null role");


         caught = false;
         try
         {
            rs.sendRoleUpdateNotification("rubbish", roleB1, new ArrayList());
         }
         catch (RelationNotFoundException e)
         {
            caught = true;
         }
View Full Code Here

         Listener listener = new Listener(RelationNotification.RELATION_MBEAN_UPDATE);
         support = new RelationSupport("id1", service, server,
                                          "relationTypeC", rolesC);
         addRelation(server, service, support, "test:type=support1");
         server.addNotificationListener(service, listener, null, null);
         RelationService rs = (RelationService) services.get(service);
         rs.setRole("id1", roleCX2);
         on = new ObjectName("test:type=support1");
         RoleList shouldBe = new RoleList();
         shouldBe.add(roleC1);
         shouldBe.add(roleCX2);
         compare(shouldBe, support.retrieveAllRoles());
View Full Code Here

   {
      MBeanServer server = MBeanServerFactory.createMBeanServer();
      try
      {
         ObjectName service = createRelationService("test:type=service", server);
         RelationService rs = (RelationService) services.get(service);
         createRelationTypeB(service);
         createRolesB(server);
         createRelationTypeC(service);
         createRolesC(server);
         createRolesCZ(server);
         createRolesCZZ(server);
         RoleList roles = new RoleList();
         roles.add(roleC1);
         roles.add(roleC2);
         rs.createRelation("relationId", "relationTypeC", roles);

         boolean caught = false;
         try
         {
            rs.setRole(null, roleC2);
         }
         catch(IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("setRole allows null relation id");
       
         caught = false;
         try
         {
            rs.setRole("relationId", null);
         }
         catch(IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("setRole allows null role");
       
         caught = false;
         try
         {
            rs.setRole("rubbish", roleC2);
         }
         catch(RelationNotFoundException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("setRole allows invalid relation id");
       
         caught = false;
         try
         {
            rs.setRole("relationId", roleB1);
         }
         catch(RoleNotFoundException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("setRole allows invalid role name");
       
         caught = false;
         try
         {
            rs.setRole("relationId", roleC1);
         }
         catch(RoleNotFoundException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("setRole allows non-writable role");

         caught = false;
         try
         {
            rs.setRole("relationId", roleCZ2);
         }
         catch(InvalidRoleValueException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("setRole allows a role below the minimum");
       
         caught = false;
         try
         {
            rs.setRole("relationId", roleCZZ);
         }
         catch(InvalidRoleValueException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("setRole allows a role above the maximum");
       
         caught = false;
         try
         {
            rs.setRole("relationId", roleCZZZ);
         }
         catch(InvalidRoleValueException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("setRole allows a role with unregistered beans");

         server.unregisterMBean(service);
         caught = false;
         try
         {
            rs.setRole("relationId", roleC2);
         }
         catch(RelationServiceNotRegisteredException e)
         {
            caught = true;
         }
View Full Code Here

         shouldBe.add(roleCX2);
         support = new RelationSupport("id1", service, server,
                                          "relationTypeC", rolesC);
         addRelation(server, service, support, "test:type=support1");
         server.addNotificationListener(service, listener, null, null);
         RelationService rs = (RelationService) services.get(service);
           
         rs.setRoles("id1", shouldBe);
         on = new ObjectName("test:type=support1");
         compare(shouldBe, support.retrieveAllRoles());
         RelationNotification rn = listener.check(1);
      }
      finally
View Full Code Here

   {
      MBeanServer server = MBeanServerFactory.createMBeanServer();
      try
      {
         ObjectName service = createRelationService("test:type=service", server);
         RelationService rs = (RelationService) services.get(service);
         createRelationTypeB(service);
         createRolesB(server);
         RoleList roleList = new RoleList();
         roleList.add(roleB1);
         roleList.add(roleB2);
         rs.createRelation("relationId", "relationTypeB", roleList);

         boolean caught = false;
         try
         {
            rs.updateRoleMap(null, roleB1, new ArrayList());
         }
         catch (IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("updateRoleMap allows null relation id");

         caught = false;
         try
         {
            rs.updateRoleMap("relationId", null, new ArrayList());
         }
         catch (IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("updateRoleMap allows null role");

         caught = false;
         try
         {
            rs.updateRoleMap("rubbish", roleB1, new ArrayList());
         }
         catch (RelationNotFoundException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("updateRoleMap allows invalid relation id");

         server.unregisterMBean(service);

         caught = false;
         try
         {
            rs.updateRoleMap("relationId", roleB1, new ArrayList());
         }
         catch (RelationServiceNotRegisteredException 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.