Package javax.management.openmbean

Examples of javax.management.openmbean.CompositeType


      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);
      assertEquals(CompositeData.class.getName(), compositeType.getClassName());
      assertEquals("description", compositeType.getDescription());
      assertEquals("typeName", compositeType.getTypeName());
      assertTrue("Composite type should not be an array", compositeType.isArray() == false);
   }
View Full Code Here


      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);
      assertTrue("Composite type should contain key name1", compositeType.containsKey("name1") == true);
      assertTrue("Composite type should contain key name2", compositeType.containsKey("name2") == true);
      assertTrue("Composite type should not contain key nameX", compositeType.containsKey("nameX") == false);
      assertTrue("Composite type should not contain key null", compositeType.containsKey(null) == false);
      assertTrue("Composite type should not contain key <empty>", compositeType.containsKey("") == false);
   }
View Full Code Here

      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);
      assertEquals("desc1", compositeType.getDescription("name1"));
      assertEquals("desc2", compositeType.getDescription("name2"));
   }
View Full Code Here

      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);
      assertEquals(SimpleType.STRING, compositeType.getType("name1"));
      assertEquals(SimpleType.INTEGER, compositeType.getType("name2"));
   }
View Full Code Here

      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);
      Set keys = compositeType.keySet();
      assertTrue("Should be 2 items", keys.size() == 2);
      assertTrue("Should contain name1", keys.contains("name1"));
      assertTrue("Should contain name2", keys.contains("name2"));
   }
View Full Code Here

      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);

      assertTrue("null is not a value of composite type", compositeType.isValue(null) == false);
      assertTrue("object is not a value of composite type", compositeType.isValue(new Object()) == false);

      Object[] itemValues = new Object[] { "string", new Integer(2) };
      CompositeDataSupport data = new CompositeDataSupport(compositeType, itemNames, itemValues);
      assertTrue("data should be a value of composite type", compositeType.isValue(data));

      CompositeType compositeType2 = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);
      data = new CompositeDataSupport(compositeType2, itemNames, itemValues);
      assertTrue("data should be a value of composite type, even though not the object instance",
         compositeType.isValue(data));

      OpenType[] itemTypes2 = new OpenType[] { SimpleType.STRING, SimpleType.LONG };
      compositeType2 = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes2);
      Object[] itemValues2 = new Object[] { "string", new Long(2) };
      data = new CompositeDataSupport(compositeType2, itemNames, itemValues2);
      assertTrue("data should not be a value of composite type, it has different types",
         compositeType.isValue(data) == false);

      compositeType2 = new CompositeType("typeName2", "description",
         itemNames, itemDescriptions, itemTypes);
      data = new CompositeDataSupport(compositeType2, itemNames, itemValues);
      assertTrue("data should not be a value of composite type, it has a different type name",
         compositeType.isValue(data) == false);

      String[] itemNames2 = new String[] { "nameX", "name2" };
      compositeType2 = new CompositeType("typeName", "description",
         itemNames2, itemDescriptions, itemTypes);
      data = new CompositeDataSupport(compositeType2, itemNames2, itemValues);
      assertTrue("data should not be a value of composite type, it has different item names",
         compositeType.isValue(data) == false);
   }
View Full Code Here

      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);

      assertTrue("null is not equal composite type", compositeType.equals(null) == false);
      assertTrue("object is not equal composite type", compositeType.equals(new Object()) == false);

      CompositeType compositeType2 = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);
      assertTrue("compositeType2 should be equal composite type, even though not the object instance",
         compositeType.equals(compositeType2));
      assertTrue("compositeType2 should be equal composite type, even though not the object instance",
         compositeType2.equals(compositeType));

      OpenType[] itemTypes2 = new OpenType[] { SimpleType.STRING, SimpleType.LONG };
      compositeType2 = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes2);
      assertTrue("compositeType2 should not be equal composite type, it has different types",
         compositeType.equals(compositeType2) == false);
      assertTrue("compositeType2 should not be equal composite type, it has different types",
         compositeType2.equals(compositeType) == false);

      compositeType2 = new CompositeType("typeName2", "description",
         itemNames, itemDescriptions, itemTypes);
      assertTrue("compositeType2 should not be equal composite type, it has a different type name",
         compositeType.equals(compositeType2) == false);
      assertTrue("compositeType2 should not be equal composite type, it has a different type name",
         compositeType2.equals(compositeType) == false);

      String[] itemNames2 = new String[] { "nameX", "name2" };
      compositeType2 = new CompositeType("typeName", "description",
         itemNames2, itemDescriptions, itemTypes);
      assertTrue("compositeType2 should not be equal composite type, it has different item names",
         compositeType.equals(compositeType2) == false);
      assertTrue("compositeType2 should not be equal composite type, it has different item names",
         compositeType2.equals(compositeType) == false);
   }
View Full Code Here

      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);

      int myHashCode = "typeName".hashCode() + SimpleType.STRING.hashCode() + SimpleType.INTEGER.hashCode()
         + "name1".hashCode() + "name2".hashCode();
      assertTrue("Wrong hash code generated", myHashCode == compositeType.hashCode());
   }
View Full Code Here

      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);

      String toString = compositeType.toString();

      assertTrue("toString() should contain the composite type class name",
         toString.indexOf(CompositeType.class.getName()) != -1);
      assertTrue("toString() should contain the item name name1",
         toString.indexOf("name1") != -1);
View Full Code Here

      throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType compositeType = new CompositeType("typeName", "description",
         itemNames, itemDescriptions, itemTypes);

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

TOP

Related Classes of javax.management.openmbean.CompositeType

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.