@Test public void testNickNameIsExposed() throws Exception { ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo(); MBeanAttributeInfo attr = inf.getAttribute("NickName"); assertNickName(attr); }
/** * Tests the situation where the property only has a getter. */ @Test public void testWithOnlySetter() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = inf.getAttribute("NickName"); assertNotNull("Attribute should not be null", attr); }
/** * Tests the situation where the property only has a setter. */ @Test public void testWithOnlyGetter() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute("Superman"); assertNotNull("Attribute should not be null", attr); }
@Test public void testNickNameIsExposed() throws Exception { ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo(); MBeanAttributeInfo attr = inf.getAttribute("NickName"); assertNickName(attr); }
@Test public void testAttributeDescriptionOnGetter() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = inf.getAttribute(NAME_ATTRIBUTE); assertEquals("The description for the name attribute is incorrect", "The Name Attribute", attr.getDescription()); }
@Test public void testAttributeDescriptionOnSetter() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = inf.getAttribute(AGE_ATTRIBUTE); assertEquals("The description for the age attribute is incorrect", "The Age Attribute", attr.getDescription()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue(attr.isReadable()); assertFalse(attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertFalse("Age is not writable", attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertFalse("Age is not writable", attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertTrue("Age is not writable", attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertFalse("Age is not writable", attr.isWritable()); }
@Test public void testSupermanIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute("Superman"); assertTrue(attr.isReadable()); assertFalse(attr.isWritable()); }
@Test public void testAttributeFromInterface() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = inf.getAttribute("Colour"); assertTrue("The name attribute should be writable", attr.isWritable()); assertTrue("The name attribute should be readable", attr.isReadable()); }
@Test public void testReadWriteAttribute() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = inf.getAttribute(NAME_ATTRIBUTE); assertTrue("The name attribute should be writable", attr.isWritable()); assertTrue("The name attribute should be readable", attr.isReadable()); }
@Test public void testNickNameIsExposed() throws Exception { ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo(); MBeanAttributeInfo attr = inf.getAttribute("NickName"); assertNotNull("Nick Name should not be null", attr); assertTrue("Nick Name should be writable", attr.isWritable()); assertTrue("Nick Name should be readable", attr.isReadable()); }
@Test public void testWithFallThrough() throws Exception { MethodNameBasedMBeanInfoAssembler assembler = getWithMapping("foobar", "add,myOperation,getName,setName,getAge"); assembler.setManagedMethods("getNickName", "setNickName"); ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName()); MBeanAttributeInfo attr = inf.getAttribute("NickName"); assertNickName(attr); }
@Test public void testMetricDescription() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo metric = inf.getAttribute(QUEUE_SIZE_METRIC); ModelMBeanOperationInfo operation = inf.getOperation("getQueueSize"); assertEquals("The description for the queue size metric is incorrect", "The QueueSize metric", metric.getDescription()); assertEquals("The description for the getter operation of the queue size metric is incorrect", "The QueueSize metric", operation.getDescription()); }
@Test public void testAttributeDescriptor() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); Descriptor desc = info.getAttribute(NAME_ATTRIBUTE).getDescriptor(); assertEquals("Default value should be foo", "foo", desc.getFieldValue("default")); assertEquals("Currency Time Limit should be 20", "20", desc.getFieldValue("currencyTimeLimit")); assertEquals("Persist Policy should be OnUpdate", "OnUpdate", desc.getFieldValue("persistPolicy")); assertEquals("Persist Period should be 300", "300", desc.getFieldValue("persistPeriod")); }
@Test public void testAttributeInfoHasDescriptors() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(NAME_ATTRIBUTE); Descriptor desc = attr.getDescriptor(); assertNotNull("getMethod field should not be null", desc.getFieldValue("getMethod")); assertNotNull("setMethod field should not be null", desc.getFieldValue("setMethod")); assertEquals("getMethod field has incorrect value", "getName", desc.getFieldValue("getMethod")); assertEquals("setMethod field has incorrect value", "setName", desc.getFieldValue("setMethod")); }
@Test public void testMetricDescriptor() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); Descriptor desc = info.getAttribute(QUEUE_SIZE_METRIC).getDescriptor(); assertEquals("Currency Time Limit should be 20", "20", desc.getFieldValue("currencyTimeLimit")); assertEquals("Persist Policy should be OnUpdate", "OnUpdate", desc.getFieldValue("persistPolicy")); assertEquals("Persist Period should be 300", "300", desc.getFieldValue("persistPeriod")); assertEquals("Unit should be messages", "messages",desc.getFieldValue("units")); assertEquals("Display Name should be Queue Size", "Queue Size",desc.getFieldValue("displayName")); assertEquals("Metric Type should be COUNTER", "COUNTER",desc.getFieldValue("metricType")); assertEquals("Metric Category should be utilization", "utilization",desc.getFieldValue("metricCategory")); }