1 15 package org.apache.hivemind.management.mbeans; 16 17 import javax.management.Attribute ; 18 import javax.management.AttributeList ; 19 import javax.management.MBeanInfo ; 20 21 import junit.framework.TestCase; 22 23 28 public class TestAbstractDynamicMBean extends TestCase 29 { 30 public void testMBeanInfo() 31 { 32 ConcreteMBean mbean = new ConcreteMBean(); 33 MBeanInfo beanInfo = mbean.getMBeanInfo(); 34 assertEquals(2, beanInfo.getAttributes().length); 35 assertEquals("attribute1", beanInfo.getAttributes()[0].getName()); 36 assertEquals("attribute2", beanInfo.getAttributes()[1].getName()); 37 assertEquals("constructor", beanInfo.getConstructors()[0].getName()); 38 assertEquals("notification", beanInfo.getNotifications()[0].getName()); 39 assertEquals("operation", beanInfo.getOperations()[0].getName()); 40 } 41 42 public void testGetAttributes() throws Exception 43 { 44 ConcreteMBean mbean = new ConcreteMBean(); 45 AttributeList list = mbean.getAttributes(new String [] 46 { "attribute1", "attribute2" }); 47 assertEquals("value1", ((Attribute ) list.get(0)).getValue()); 48 assertEquals("value2", ((Attribute ) list.get(1)).getValue()); 49 } 50 51 public void testSetAttributes() throws Exception 52 { 53 ConcreteMBean mbean = new ConcreteMBean(); 54 55 AttributeList list = new AttributeList (); 56 list.add(new Attribute ("attribute1", "newvalue1")); 57 list.add(new Attribute ("attribute2", "newvalue2")); 58 mbean.setAttributes(list); 59 assertEquals("newvalue1", mbean.getAttribute("attribute1")); 60 assertEquals("newvalue2", mbean.getAttribute("attribute2")); 61 } 62 } 63 64 | Popular Tags |