Package javax.management.modelmbean

Examples of javax.management.modelmbean.DescriptorSupport$ValueHolder


   public void testValid() throws Exception
   {
      // Create a valid Descriptor object
      String[] attributes = {"name=mytest", "descriptorType=MBean", "role=constructor"};
      new DescriptorSupport(attributes);

      // Try a different constructor
      String[] names = {"name", "descriptorType", "role", "persistPolicy", "persistPeriod"};
      String[] values = {"mytest", "MBean", "constructor", "Never", "1"};
      new DescriptorSupport(names, values);

      // Create a valid Descriptor object. Check that persistPolicy's value is not case sensitive
      names = new String[]{"name", "descriptorType", "persistPolicy"};
      values = new String[]{"mytest", "MBean", "never"};

      new DescriptorSupport(names, values);
   }
View Full Code Here


      String[] names = {"name", "descriptorType", "role", "persistPolicy"};
      String[] values = {"mytest", "MBean", "constructor", "Something"};

      try
      {
         new DescriptorSupport(names, values);
         fail("Descriptor support object created with invalid attributes");
      }
      catch (RuntimeOperationsException ex)
      {
      }

      // Create an invalid Descriptor object. Check persistPeriod
      // Persist period should be bigger or equal than -1
      names = new String[]{"name", "descriptorType", "persistPolicy", "persistPeriod"};
      values = new String[]{"mytest", "MBean", "Never", "-2"};

      try
      {
         new DescriptorSupport(names, values);
         fail("Descriptor support object created with invalid persistPeriod");
      }
      catch (RuntimeOperationsException ex)
      {
      }

      // Create an invalid Descriptor object. Check visiblity
      // visibility should be between 1 and 4
      names = new String[]{"name", "descriptorType", "visibility"};
      values = new String[]{"mytest", "MBean", "0"};

      try
      {
         new DescriptorSupport(names, values);
         fail("Descriptor support object created with invalid visiblity");
      }
      catch (RuntimeOperationsException ex)
      {
      }

      // Create an invalid Descriptor object. Check visiblity
      // visibility should be between 1 and 4
      names = new String[]{"name", "descriptorType", "visibility"};
      values = new String[]{"mytest", "MBean", "5"};

      try
      {
         new DescriptorSupport(names, values);
         fail("Descriptor support object created with invalid visiblity");
      }
      catch (RuntimeOperationsException ex)
      {
      }
View Full Code Here

   {
      // Test for bug #686306
      String[] names = {"name", "descriptorType", "persistPolicy", "persistPeriod"};
      String[] values = {"test", "mbean", "AlwaYs", "-1"};

      DescriptorSupport ds = new DescriptorSupport(names, values);

      assertTrue(ds.isValid());
   }
View Full Code Here

   {
      // Test for bug #744423 and #775742
      String[] names = {"name", "descriptorType", "severity"};
      String[] values = {"test", "mbean", "0"};

      DescriptorSupport ds = new DescriptorSupport(names, values);
      assertTrue(ds.isValid());

      names = new String[]{"name", "descriptorType", "severity"};
      values = new String[]{"test", "mbean", "6"};

      ds = new DescriptorSupport(names, values);
      assertTrue(ds.isValid());
   }
View Full Code Here

   public void testCaseInsensitiveFieldNames() throws Exception
   {
      String[] fields = {"descriptorType", "myField"};
      Object[] values = {"MBean", "top secret"};
      DescriptorSupport ds = new DescriptorSupport(fields, values);
      assertEquals("Expecting 'descriptorType' value to be 'mbean'", (String)ds.getFieldValue("DESCRIPTORTYPE"), "MBean");
      assertEquals("Expecting 'myField' value to be 'top secret'", (String)ds.getFieldValue("MYfIELD"), "top secret");

      fields = new String[]{"name", "descriptorType", "deleteMe"};
      values = new String[]{"testCaseInsensitiveFieldNames", "MBean", "nothing of consequence"};
      ds = new DescriptorSupport(fields, values);
      ds.removeField("DELETEmE");
      String[] fieldnames = ds.getFields();
      List fieldlist = new ArrayList();
      for (int i = 0; i < fieldnames.length; i++) fieldlist.add(fieldnames[i]);
      int fieldcount = fieldnames.length;
      assertEquals("Expecting 'deleteMe' to be gone", fieldcount, 2);
      assertFalse(fieldlist.contains("deleteme"));
View Full Code Here

   public void testCaseInsensitiveFieldValues() throws Exception
   {
      String[] fields = {"descriptorType", "persistPolicy", "log"};
      String[] values = {"mBEAN", "oNuPDATE", "TRUE"};
      new DescriptorSupport(fields, values);
   }
View Full Code Here

   public void testCaseSensitivityPreserved() throws Exception
   {
      String[] names = {"Name", "DescriptorType"};
      String[] values = {"test", "mbean"};
      DescriptorSupport descriptor = new DescriptorSupport(names, values);

      // Check case insensitivity on get
      String value = (String)descriptor.getFieldValue("name");
      assertNotNull(value);
      assertEquals(value, values[0]);
      value = (String)descriptor.getFieldValue("descriptorType");
      assertNotNull(value);
      assertEquals(value, values[1]);

      // Be sure case is preserved
      String[] fieldNames = descriptor.getFieldNames();
      assertNotNull(fieldNames);
      assertEquals(fieldNames.length, 2);
      if (!fieldNames[0].equals(names[0]) && !fieldNames[0].equals(names[1])) fail();
      if (!fieldNames[1].equals(names[0]) && !fieldNames[1].equals(names[1])) fail();

      // Check serialization works
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(descriptor);
      oos.close();
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      ObjectInputStream ois = new ObjectInputStream(bais);
      DescriptorSupport newDescriptor = (DescriptorSupport)ois.readObject();
      value = (String)newDescriptor.getFieldValue("name");
      assertNotNull(value);
      assertEquals(value, values[0]);
      // Be sure case is preserved
      fieldNames = newDescriptor.getFieldNames();
      assertNotNull(fieldNames);
      assertEquals(fieldNames.length, 2);
      if (!fieldNames[0].equals(names[0]) && !fieldNames[0].equals(names[1])) fail();
      if (!fieldNames[1].equals(names[0]) && !fieldNames[1].equals(names[1])) fail();
View Full Code Here

      assertEquals(fieldNames[0], names[1]);
   }

   public void testDefaultFieldValuesSize() throws Exception
   {
      DescriptorSupport ds = new DescriptorSupport();
      Object[] fields = ds.getFieldValues(null);
      assertTrue("Expecting 0 length array", fields.length == 0);
   }
View Full Code Here

      assertTrue("Expecting 0 length array", fields.length == 0);
   }

   public void testNullDescriptorConstructorParam() throws Exception
   {
      DescriptorSupport ds = new DescriptorSupport((DescriptorSupport)null);
      assertNotNull(ds.getFields());
      assertEquals("Expecting the descriptor to be empty", ds.getFields().length, 0);
      assertFalse("Expecting the descriptor to be invalid", ds.isValid());
   }
View Full Code Here

   public void testNullStringConstructorParam() throws Exception
   {
      try
      {
         new DescriptorSupport((String)null);
         fail("Expecting RuntimeOperationsException");
      }
      catch (RuntimeOperationsException x)
      {
         if (!(x.getTargetException() instanceof IllegalArgumentException))
View Full Code Here

TOP

Related Classes of javax.management.modelmbean.DescriptorSupport$ValueHolder

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.