Package javax.management.openmbean

Examples of javax.management.openmbean.OpenMBeanAttributeInfoSupport


   }

   public void testOpenType()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false);
      assertEquals(SimpleType.STRING, info.getOpenType());
   }
View Full Code Here


   }

   public void testHas()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false, "default");
      assertEquals(true, info.hasDefaultValue());

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false, null);
      assertEquals(false, info.hasDefaultValue());

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, null, new Integer(3), null);
      assertEquals(true, info.hasMinValue());

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, null, null, null);
      assertEquals(false, info.hasMinValue());

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, null, null, new Integer(3));
      assertEquals(true, info.hasMaxValue());

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, null, null, null);
      assertEquals(false, info.hasMaxValue());

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, null, new Object[] { new Integer(3) });
      assertEquals(true, info.hasLegalValues());

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, null, null);
      assertEquals(false, info.hasLegalValues());
   }
View Full Code Here

   }

   public void testIsValue()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false);
      assertTrue("String should be a value", info.isValue("string"));
      assertTrue("Integer should not be a value", info.isValue(new Integer(3)) == false);
      assertTrue("Null should not be a value", info.isValue(null) == false);
   }
View Full Code Here

   }

   public void testIsWritable()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false);
      assertEquals(true, info.isWritable());
      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, false, false);
      assertEquals(false, info.isWritable());
   }
View Full Code Here

   }

   public void testIsReadable()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false);
      assertEquals(true, info.isReadable());
      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, false, true, false);
      assertEquals(false, info.isReadable());
   }
View Full Code Here

   }

   public void testIsIs()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.BOOLEAN, true, true, true);
      assertEquals(true, info.isIs());
      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false);
      assertEquals(false, info.isIs());
   }
View Full Code Here

   }

   public void testEquals()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false);

      assertTrue("Null should not be equal", info.equals(null) == false);
      assertTrue("Only OpenMBeanAttributeInfo should be equal", info.equals(new Object()) == false);

      OpenMBeanAttributeInfoSupport info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.STRING, true, true, false);

      assertTrue("Different instances of the same data are equal", info.equals(info2));
      assertTrue("Different instances of the same data are equal", info2.equals(info));

      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description2", SimpleType.STRING, true, true, false);

      assertTrue("Different instances with different descriptions are equal", info.equals(info2));
      assertTrue("Different instances with different descritpions are equal", info2.equals(info));

      info2 = new OpenMBeanAttributeInfoSupport(
         "name2", "description", SimpleType.STRING, true, true, false);

      assertTrue("Instances with different names are not equal", info.equals(info2) == false);
      assertTrue("Instances with different names are not equal", info2.equals(info) == false);

      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false);

      assertTrue("Instances with different types are not equal", info.equals(info2) == false);
      assertTrue("Instances with different types are not equal", info2.equals(info) == false);

      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, false, true, false);

      assertTrue("Instances with different read are not equal", info.equals(info2) == false);
      assertTrue("Instances with different read are not equal", info2.equals(info) == false);

      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, false, false);

      assertTrue("Instances with different write are not equal", info.equals(info2) == false);
      assertTrue("Instances with different write are not equal", info2.equals(info) == false);

      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.BOOLEAN, true, true, true);
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.BOOLEAN, true, true, true);

      assertTrue("Instances with different write are not equal", info.equals(info2) == false);
      assertTrue("Instances with different write are not equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
          new Integer(3), new Integer(2), new Integer(4));
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(2), new Integer(2), new Integer(4));

      assertTrue("Instances with different default values are not equal", info.equals(info2) == false);
      assertTrue("Instances with different default values are not equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), new Integer(2), new Integer(4));
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(2), null, new Integer(4));

      assertTrue("Instances with different default values are not equal", info.equals(info2) == false);
      assertTrue("Instances with different default values are not equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, new Integer(3));
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, new Integer(3));

      assertTrue("Different instances of the same default value are equal", info.equals(info2));
      assertTrue("Different instances of the same default value are equal", info2.equals(info));

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Integer(2), null);
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Integer(2), null);

      assertTrue("Different instances of the same minimum are equal", info.equals(info2));
      assertTrue("Different instances of the same minimum are equal", info2.equals(info));

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, null, new Integer(2));
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, null, new Integer(2));

      assertTrue("Different instances of the same maximum are equal", info.equals(info2));
      assertTrue("Different instances of the same maximum are equal", info2.equals(info));

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), new Integer(2), new Integer(4));
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), new Integer(1), new Integer(4));

      assertTrue("Instances with different minimums are not equal", info.equals(info2) == false);
      assertTrue("Instances with different minimums are not equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), new Integer(2), new Integer(4));
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), null, new Integer(4));

      assertTrue("Instances with different minimums are not equal", info.equals(info2) == false);
      assertTrue("Instances with different minimums are not equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), new Integer(2), new Integer(4));
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), new Integer(2), new Integer(5));

      assertTrue("Instances with different maximums are not equal", info.equals(info2) == false);
      assertTrue("Instances with different maximums are not equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), new Integer(2), new Integer(4));
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         new Integer(3), new Integer(2), null);

      assertTrue("Instances with different maximums are not equal", info.equals(info2) == false);
      assertTrue("Instances with different maximums are not equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Object[] { new Integer(2), new Integer(3) });
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Object[] { new Integer(2), new Integer(3) });

      assertTrue("Different instances of the same legal values are equal", info.equals(info2));
      assertTrue("Different instances of the same legal values are equal", info2.equals(info));

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Object[] { new Integer(2), new Integer(3) });
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Object[] { new Integer(2), new Integer(4) });

      assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
      assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Object[] { new Integer(2), new Integer(3) });
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Object[] { new Integer(2) });

      assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
      assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, new Object[] { new Integer(2), new Integer(3) });
      info2 = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false,
         null, null);

      assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
      assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);
   }
View Full Code Here

   public void testHashCode()
      throws Exception
   {

      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, new Integer(3), new Integer(2), new Integer(4));
      int myHash = "name".hashCode() + SimpleType.INTEGER.hashCode() +
         new Integer(3).hashCode() + new Integer(2).hashCode() + new Integer(4).hashCode();
      assertEquals(myHash, info.hashCode());
      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, new Integer(3),
         new Object[] { new Integer(2), new Integer(3), new Integer(4) } );
      myHash = "name".hashCode() + SimpleType.INTEGER.hashCode() +
         new Integer(3).hashCode() + new Integer(2).hashCode() + new Integer(3).hashCode() + new Integer(4).hashCode();
      assertEquals(myHash, info.hashCode());
   }
View Full Code Here

   }

   public void testToString()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, new Integer(3), new Integer(2), new Integer(4));

      String toString = info.toString();
      assertTrue("info.toString() should contain the name", toString.indexOf("name") != -1);
      assertTrue("info.toString() should contain the simple type",
         toString.indexOf(SimpleType.INTEGER.toString()) != -1);
      assertTrue("info.toString() should contain the default value",
         toString.indexOf(new Integer(3).toString()) != -1);
      assertTrue("info.toString() should contain the minimum value",
         toString.indexOf(new Integer(2).toString()) != -1);
      assertTrue("info.toString() should contain the maximum value",
         toString.indexOf(new Integer(4).toString()) != -1);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, new Integer(3),
         new Object[] { new Integer(2), new Integer(3), new Integer(4) } );
      assertTrue("info.toString() should contain the legal value 2",
         toString.indexOf(new Integer(2).toString()) != -1);
      assertTrue("info.toString() should contain the legal value 3",
View Full Code Here

   }

   public void testSerialization()
      throws Exception
   {
      OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, new Integer(3), new Integer(2), new Integer(4));

      // Serialize it
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(info);
   
      // Deserialize it
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      ObjectInputStream ois = new ObjectInputStream(bais);
      Object result = ois.readObject();

      assertEquals(info, result);

      info = new OpenMBeanAttributeInfoSupport(
         "name", "description", SimpleType.INTEGER, true, true, false, new Integer(3),
         new Object[] { new Integer(2), new Integer(3), new Integer(4) } );

      // Serialize it
      baos = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of javax.management.openmbean.OpenMBeanAttributeInfoSupport

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.