Java Code Examples for javax.management.DynamicMBean#getMBeanInfo()
The following examples show how to use
javax.management.DynamicMBean#getMBeanInfo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicMBeanFactoryAttributesTest.java From datakernel with Apache License 2.0 | 6 votes |
@Test public void retreivesProperMBeanInfo() { MBeanWithSimpleAttrsAndPojo mbeanOneSample = new MBeanWithSimpleAttrsAndPojo("data", new SamplePojo(5, 100)); DynamicMBean mbean = createDynamicMBeanFor(mbeanOneSample); MBeanInfo mBeanInfo = mbean.getMBeanInfo(); MBeanAttributeInfo[] attributesInfoArr = mBeanInfo.getAttributes(); Map<String, MBeanAttributeInfo> nameToAttr = nameToAttribute(attributesInfoArr); assertEquals(3, nameToAttr.size()); assertTrue(nameToAttr.containsKey("info")); assertTrue(nameToAttr.get("info").isReadable()); assertTrue(nameToAttr.containsKey("details_count")); assertTrue(nameToAttr.get("details_count").isReadable()); assertTrue(nameToAttr.containsKey("details_sum")); assertTrue(nameToAttr.get("details_sum").isReadable()); }
Example 2
Source File: DynamicMBeanFactoryAttributesTest.java From datakernel with Apache License 2.0 | 6 votes |
@Test public void returnsInfoAboutWritableAttributesInMBeanInfo() { MBeanWithSettableAttributes settableMBean = new MBeanWithSettableAttributes(10, 20, "data"); DynamicMBean mbean = createDynamicMBeanFor(settableMBean); MBeanInfo mBeanInfo = mbean.getMBeanInfo(); MBeanAttributeInfo[] attributesInfoArr = mBeanInfo.getAttributes(); Map<String, MBeanAttributeInfo> nameToAttr = nameToAttribute(attributesInfoArr); assertEquals(3, nameToAttr.size()); assertTrue(nameToAttr.containsKey("notSettableInt")); assertFalse(nameToAttr.get("notSettableInt").isWritable()); assertTrue(nameToAttr.containsKey("settableInt")); assertTrue(nameToAttr.get("settableInt").isWritable()); assertTrue(nameToAttr.containsKey("settableStr")); assertTrue(nameToAttr.get("settableStr").isWritable()); }
Example 3
Source File: DynamicMBeanFactoryAttributesTest.java From datakernel with Apache License 2.0 | 6 votes |
@Test public void worksProperlyWithIsGetters() throws Exception { MBeanWithIsGetter mBeanWithIsGetter = new MBeanWithIsGetter(); DynamicMBean mbean = createDynamicMBeanFor(mBeanWithIsGetter); MBeanInfo mBeanInfo = mbean.getMBeanInfo(); MBeanAttributeInfo[] attributesInfoArr = mBeanInfo.getAttributes(); assertEquals(1, attributesInfoArr.length); MBeanAttributeInfo booleanAttr = attributesInfoArr[0]; assertEquals("active", booleanAttr.getName()); assertTrue(booleanAttr.isReadable()); assertTrue(booleanAttr.isIs()); assertTrue((boolean) mbean.getAttribute("active")); }
Example 4
Source File: DynamicMBeanFactoryAttributesSelectionTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test(expected = RuntimeException.class) public void throwsExceptionInCaseOfInvalidFieldName() { MBeansStubWithInvalidExtraAttrName mbeanStub = new MBeansStubWithInvalidExtraAttrName(); DynamicMBean mbean = createDynamicMBeanFor(mbeanStub); MBeanInfo mBeanInfo = mbean.getMBeanInfo(); MBeanAttributeInfo[] attributesInfoArr = mBeanInfo.getAttributes(); assertEquals(1, attributesInfoArr.length); assertEquals("stats_sum", attributesInfoArr[0].getName()); }
Example 5
Source File: DynamicMBeanFactorySettingsTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void includesOptionalAttributes_thatAreSpecifiedInSettings() { JmxBeanSettings settings = JmxBeanSettings.of(singleton("stats_text"), NO_MODIFIERS, NO_CUSTOM_TYPES); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(asList(new MBeanStubOne()), settings, false); MBeanInfo mBeanInfo = mbean.getMBeanInfo(); Map<String, MBeanAttributeInfo> attrs = nameToAttribute(mBeanInfo.getAttributes()); assertEquals(2, attrs.size()); assertTrue(attrs.containsKey("stats_text")); }
Example 6
Source File: DynamicMBeanFactoryOperationsTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void itShouldCollectInformationAbountJMXOperationsToMBeanInfo() { BeanStubWithOperations bean = new BeanStubWithOperations(); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(singletonList(bean), defaultSettings(), false); MBeanInfo mBeanInfo = mbean.getMBeanInfo(); MBeanOperationInfo[] operations = mBeanInfo.getOperations(); Map<String, MBeanOperationInfo> nameToOperation = new HashMap<>(); for (MBeanOperationInfo operation : operations) { nameToOperation.put(operation.getName(), operation); } assertThat(nameToOperation, hasKey("increment")); assertThat(nameToOperation, hasKey("addInfo")); assertThat(nameToOperation, hasKey("multiplyAndAdd")); MBeanOperationInfo incrementOperation = nameToOperation.get("increment"); MBeanOperationInfo addInfoOperation = nameToOperation.get("addInfo"); MBeanOperationInfo multiplyAndAddOperation = nameToOperation.get("multiplyAndAdd"); assertThat(incrementOperation, hasReturnType("void")); assertThat(addInfoOperation, hasParameter("information", String.class.getName())); assertThat(addInfoOperation, hasReturnType("void")); // parameter names are not annotated assertThat(multiplyAndAddOperation, hasParameter("arg0", "long")); assertThat(multiplyAndAddOperation, hasParameter("arg1", "long")); assertThat(multiplyAndAddOperation, hasReturnType("void")); }
Example 7
Source File: DynamicMBeanFactoryAttributesHidingTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void omitsNullPojoAttributesInSingleton() { MBeanStubOne singletonWithNullPojo = new MBeanStubOne(null); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(singletonList(singletonWithNullPojo), defaultSettings(), false); MBeanInfo mbeanInfo = mbean.getMBeanInfo(); Map<String, MBeanAttributeInfo> attrs = nameToAttribute(mbeanInfo.getAttributes()); assertEquals(0, attrs.size()); }
Example 8
Source File: DynamicMBeanFactoryAttributesHidingTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void omitsPojoAttributesInWorkersIfAllWorkersReturnNull() { MBeanStubOne mbean_1 = new MBeanStubOne(null); MBeanStubOne mbean_2 = new MBeanStubOne(null); List<MBeanStubOne> workersWithNullPojo = asList(mbean_1, mbean_2); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(workersWithNullPojo, defaultSettings(), false); MBeanInfo mbeanInfo = mbean.getMBeanInfo(); Map<String, MBeanAttributeInfo> attrs = nameToAttribute(mbeanInfo.getAttributes()); assertEquals(0, attrs.size()); }
Example 9
Source File: DynamicMBeanFactoryAttributesHidingTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void doesNotOmitPojoAttributesInWorkersIfAtLeastOneWorkerReturnsNonNull() { MBeanStubOne mbean_1 = new MBeanStubOne(null); MBeanStubOne mbean_2 = new MBeanStubOne(new PojoStub()); List<MBeanStubOne> workersWithNullPojo = asList(mbean_1, mbean_2); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(workersWithNullPojo, defaultSettings(), false); MBeanInfo mbeanInfo = mbean.getMBeanInfo(); Map<String, MBeanAttributeInfo> attrs = nameToAttribute(mbeanInfo.getAttributes()); assertEquals(2, attrs.size()); assertTrue(attrs.containsKey("pojoStub_number")); assertTrue(attrs.containsKey("pojoStub_text")); }
Example 10
Source File: DynamicMBeanFactoryAttributesHidingTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void omitsNullJmxStatsAttributesInSingleton() { MBeanStubTwo singletonWithNullJmxStats = new MBeanStubTwo(null); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(singletonList(singletonWithNullJmxStats), defaultSettings(), false); MBeanInfo mbeanInfo = mbean.getMBeanInfo(); Map<String, MBeanAttributeInfo> attrs = nameToAttribute(mbeanInfo.getAttributes()); assertEquals(0, attrs.size()); }
Example 11
Source File: DynamicMBeanFactoryAttributesHidingTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void omitsJmxStatsAttributesInWorkersIfAllWorkersReturnNull() { MBeanStubTwo mbean_1 = new MBeanStubTwo(null); MBeanStubTwo mbean_2 = new MBeanStubTwo(null); List<MBeanStubTwo> workersWithNullPojo = asList(mbean_1, mbean_2); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(workersWithNullPojo, defaultSettings(), false); MBeanInfo mbeanInfo = mbean.getMBeanInfo(); Map<String, MBeanAttributeInfo> attrs = nameToAttribute(mbeanInfo.getAttributes()); assertEquals(0, attrs.size()); }
Example 12
Source File: DynamicMBeanFactoryAttributesHidingTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void doesNotOmitJmxStatsAttributesInWorkersIfAtLeastOneWorkerReturnsNonNull() { MBeanStubTwo mbean_1 = new MBeanStubTwo(null); MBeanStubTwo mbean_2 = new MBeanStubTwo(new JmxStatsStub()); List<MBeanStubTwo> workersWithNullPojo = asList(mbean_1, mbean_2); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(workersWithNullPojo, defaultSettings(), false); MBeanInfo mbeanInfo = mbean.getMBeanInfo(); Map<String, MBeanAttributeInfo> attrs = nameToAttribute(mbeanInfo.getAttributes()); assertEquals(1, attrs.size()); assertTrue(attrs.containsKey("jmxStatsStub_value")); }
Example 13
Source File: DynamicMBeanFactoryAttributesHidingTest.java From datakernel with Apache License 2.0 | 5 votes |
@Test public void omitsNullPojosInNonNullPojos() { MBeanStubThree bean = new MBeanStubThree(new PojoStubThree(null)); DynamicMBean mbean = DynamicMBeanFactory.create() .createDynamicMBean(singletonList(bean), defaultSettings(), false); MBeanInfo mbeanInfo = mbean.getMBeanInfo(); Map<String, MBeanAttributeInfo> attrs = nameToAttribute(mbeanInfo.getAttributes()); assertEquals(1, attrs.size()); assertTrue(attrs.containsKey("pojoStubThree_number")); }
Example 14
Source File: DynamicMBeanFactoryAttributesSelectionTest.java From datakernel with Apache License 2.0 | 4 votes |
@Test public void considerOptionalAttributesIfTheyAreSpecified() { MBeanWithExtraSubAttributes mbeanStub = new MBeanWithExtraSubAttributes(); DynamicMBean mbean = createDynamicMBeanFor(mbeanStub); MBeanInfo mBeanInfo = mbean.getMBeanInfo(); MBeanAttributeInfo[] attributesInfoArr = mBeanInfo.getAttributes(); Map<String, MBeanAttributeInfo> nameToAttr = nameToAttribute(attributesInfoArr); assertEquals(2, nameToAttr.size()); assertTrue(nameToAttr.containsKey("stats_sum")); assertTrue(nameToAttr.containsKey("stats_count")); }
Example 15
Source File: DynamicMBeanFactoryAttributesSelectionTest.java From datakernel with Apache License 2.0 | 3 votes |
@Test public void doNotConsiderOptionalAttributesByDefault() { MBeanWithNoExtraSubAttributes mbeanStub = new MBeanWithNoExtraSubAttributes(); DynamicMBean mbean = createDynamicMBeanFor(mbeanStub); MBeanInfo mBeanInfo = mbean.getMBeanInfo(); MBeanAttributeInfo[] attributesInfoArr = mBeanInfo.getAttributes(); assertEquals(1, attributesInfoArr.length); assertEquals("stats_sum", attributesInfoArr[0].getName()); }