Package javax.management.relation

Examples of javax.management.relation.RelationService$InternalRelation


   /**
    * Test Is Relation Errors
    */
   public void testIsRelationErrors() throws Exception
   {
      RelationService rs = new RelationService(true);

      boolean caught = false;
      try
      {
         rs.isRelation(null);
      }
      catch(IllegalArgumentException e)
      {
         caught = true;
      }
View Full Code Here


                                       "relationTypeC", rolesC);
         addRelation(server, service, support, "test:type=support1");
         support = new RelationSupport("id2", service, server,
                                       "relationTypeC", rolesC);
         addRelation(server, service, support, "test:type=support2");
         RelationService rs = (RelationService) services.get(service);
         result1 = rs.isRelationMBean("id1");
         result2 = rs.isRelationMBean("id2");
         on1 = new ObjectName("test:type=support1");
         on2 = new ObjectName("test:type=support2");
         assertEquals(on1, result1);
         assertEquals(on2, result2);
      }
View Full Code Here

   /**
    * Test Is Relation MBean Errors
    */
   public void testIsRelationMBeanErrors() throws Exception
   {
      RelationService rs = new RelationService(true);

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

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

         boolean result = false;
         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);
         server.unregisterMBean(new ObjectName("x:relation=c,role=2,bean=1"));
         on = new ObjectName("test:type=support1");
         result = rs.hasRelation("id1").booleanValue();
         assertEquals(false, result);
         RelationNotification rn = listener.check(1);
         assertEquals(new ArrayList(), rn.getMBeansToUnregister());
         assertEquals(on, rn.getObjectName());
         assertEquals("id1", rn.getRelationId());
View Full Code Here

         createRolesC(server);
         RelationSupport support = null;
         ObjectName on = null;
         Listener listener = new Listener(RelationNotification.RELATION_MBEAN_REMOVAL);
         boolean result = false;
         RelationService rs = null;
         support = new RelationSupport("id1", service, server,
                                       "relationTypeC", rolesC);
         addRelation(server, service, support, "test:type=support1");
         server.addNotificationListener(service, listener, null, null);
         rs = (RelationService) services.get(service);
         rs.setPurgeFlag(false);
         server.unregisterMBean(new ObjectName("x:relation=c,role=2,bean=1"));
         on = new ObjectName("test:type=support1");
         result = rs.hasRelation("id1").booleanValue();
         assertEquals(true, result);
         RelationNotification rn = listener.check(0);

         rs.purgeRelations();
         result = rs.hasRelation("id1").booleanValue();
         assertEquals(false, result);
         rn = listener.check(1);
         assertEquals(new ArrayList(), rn.getMBeansToUnregister());
         assertEquals(on, rn.getObjectName());
         assertEquals("id1", rn.getRelationId());
View Full Code Here

   /**
    * Test purge relations errors
    */
   public void testPurgeRelationsErrors() throws Exception
   {
      RelationService rs = new RelationService(true);

      boolean caught = false;
      try
      {
         rs.purgeRelations();
      }
      catch (RelationServiceNotRegisteredException e)
      {
         caught = true;
      }
View Full Code Here

                                          "relationTypeC", rolesC);
         addRelation(server, service, supportA1, "test:type=supportA1");
         addRelation(server, service, supportA2, "test:type=supportA2");
         addRelation(server, service, supportCX, "test:type=supportCX");
         addRelation(server, service, supportC, "test:type=supportC");
         RelationService rs = (RelationService) services.get(service);
         rs.removeRelation("idcx");
         result = rs.getAllRelationIds();
         assertEquals(3, result.size());
         assertEquals(true, result.contains("ida1"));
         assertEquals(true, result.contains("ida2"));
         assertEquals(true, result.contains("idc"));
         assertEquals(false, result.contains("idcx"));
View Full Code Here

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

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

         service = createRelationService("test:type=service", server);
         createRelationTypeA(service);
         createRolesA(server);
         RelationSupport supportA1 = new RelationSupport("ida1", service, server,
                                       "relationTypeA", rolesA);
         addRelation(server, service, supportA1, "test:type=supportA1");
         rs = (RelationService) services.get(service);

         caught = false;
         try
         {
            rs.removeRelation(null);
         }
         catch (IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("removeRelation accepts a null relation");

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

   public void testRemoveRelationType() throws Exception
   {
      MBeanServer server = MBeanServerFactory.createMBeanServer();
      try
      {
         RelationService rs = new RelationService(true);
         assertEquals(0, rs.getAllRelationTypeNames().size());

         RoleInfo roleInfo1 = null;
         RoleInfo roleInfo2 = null;
         RoleInfo[] roleInfos = null;
         ObjectName name = new ObjectName("test:type = rs");
         server.registerMBean(rs, name);
         roleInfo1 = new RoleInfo("roleInfo1", Trivial.class.getName());
         roleInfo2 = new RoleInfo("roleInfo2", Trivial.class.getName());
         roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 };
         rs.createRelationType("name1", roleInfos);
         rs.createRelationType("name2", roleInfos);
         rs.createRelationType("name3", roleInfos);
         rs.removeRelationType("name3");

         ArrayList result = (ArrayList) rs.getAllRelationTypeNames();
         assertEquals(2, result.size());
         assertEquals(true, result.contains("name1"));
         assertEquals(true, result.contains("name2"));
         assertEquals(false, result.contains("name3"));
      }
View Full Code Here

   public void testRemoveRelationTypeErrors() throws Exception
   {
      MBeanServer server = MBeanServerFactory.createMBeanServer();
      try
      {
         RelationService rs = null;
         RoleInfo roleInfo1 = null;
         RoleInfo roleInfo2 = null;
         RoleInfo[] roleInfos = null;
         rs = new RelationService(true);
         roleInfo1 = new RoleInfo("roleInfo1", Trivial.class.getName());
         roleInfo2 = new RoleInfo("roleInfo2", Trivial.class.getName());
         roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 };
         rs.createRelationType("name1", roleInfos);

         boolean caught = false;
         try
         {
            rs.removeRelationType("name1");
         }
         catch (RelationServiceNotRegisteredException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("Remove relation type allowed when not registered, why not?");

         server.registerMBean(rs, new ObjectName("test:type=RelationService"));

         caught = false;
         try
         {
            rs.removeRelationType(null);
         }
         catch (IllegalArgumentException e)
         {
            caught = true;
         }
         if (caught == false)
            fail("Remove relation type allows null relation type name");

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

TOP

Related Classes of javax.management.relation.RelationService$InternalRelation

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.