use of javax.management.openmbean.CompositeData in project nhin-d by DirectProject.
the class RDBMSAuditor_getEventsTest method testGetEvents_NoRecordsRequested_ReturnedRecords.
@Test
public void testGetEvents_NoRecordsRequested_ReturnedRecords() {
AuditEvent event1 = new AuditEvent("Category" + UUID.randomUUID(), "type");
AuditEvent event2 = new AuditEvent("Category" + UUID.randomUUID(), "type");
DefaultAuditContext context1 = new DefaultAuditContext("name1", "value1");
DefaultAuditContext context2 = new DefaultAuditContext("name2", "value2");
auditorImpl.audit(PRINCIPAL, event1);
auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
CompositeData[] events = auditorImpl.getEvents(0);
assertNull(events);
}
use of javax.management.openmbean.CompositeData in project nhin-d by DirectProject.
the class RDBMSAuditor_writeEventTest method testWriteEvent_noContexts_assertWritten.
@Test
public void testWriteEvent_noContexts_assertWritten() throws Exception {
final AuditEvent auditEvent = new AuditEvent("name1", "value1");
this.auditorImpl.audit("testPin", auditEvent, null);
final CompositeData lastMessage = auditorImpl.getLastEvent();
assertNotNull(lastMessage);
assertEquals(auditEvent.getName(), lastMessage.get("Event Name"));
assertEquals(auditEvent.getType(), lastMessage.get("Event Type"));
assertTrue(lastMessage.get("Event Id").toString().length() > 0);
assertTrue(lastMessage.get("Event Time").toString().length() > 0);
assertNotNull(lastMessage.get("Contexts"));
String[] contexts = (String[]) lastMessage.get("Contexts");
assertEquals(1, contexts.length);
}
use of javax.management.openmbean.CompositeData in project nhin-d by DirectProject.
the class RDBMSAuditor_writeEventTest method testWriteEvent_withContexts_assertWritten.
@Test
public void testWriteEvent_withContexts_assertWritten() throws Exception {
final AuditEvent auditEvent = new AuditEvent("name1", "value1");
final DefaultAuditContext context1 = new DefaultAuditContext("name1", "value1");
final DefaultAuditContext context2 = new DefaultAuditContext("name2", "value2");
this.auditorImpl.audit("testPin", auditEvent, Arrays.asList(context1, context2));
final CompositeData lastMessage = auditorImpl.getLastEvent();
assertNotNull(lastMessage);
assertEquals(auditEvent.getName(), lastMessage.get("Event Name"));
assertEquals(auditEvent.getType(), lastMessage.get("Event Type"));
assertTrue(lastMessage.get("Event Id").toString().length() > 0);
assertTrue(lastMessage.get("Event Time").toString().length() > 0);
assertNotNull(lastMessage.get("Contexts"));
String[] contexts = (String[]) lastMessage.get("Contexts");
assertEquals(2, contexts.length);
assertEquals("name1:value1", contexts[0]);
assertEquals("name2:value2", contexts[1]);
}
use of javax.management.openmbean.CompositeData in project midpoint by Evolveum.
the class SystemInfoPanel method fillMemoryUsage.
private void fillMemoryUsage(SystemInfoDto dto) throws Exception {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName name = ObjectName.getInstance("java.lang:type=Memory");
CompositeData cd = (CompositeData) mbs.getAttribute(name, "HeapMemoryUsage");
dto.heapMemory[0] = (Long) cd.get("used");
dto.heapMemory[1] = (Long) cd.get("committed");
dto.heapMemory[2] = (Long) cd.get("max");
cd = (CompositeData) mbs.getAttribute(name, "NonHeapMemoryUsage");
dto.nonHeapMemory[0] = (Long) cd.get("used");
dto.nonHeapMemory[1] = (Long) cd.get("committed");
dto.nonHeapMemory[2] = (Long) cd.get("max");
}
use of javax.management.openmbean.CompositeData in project jdk8u_jdk by JetBrains.
the class MXBeanTest method proxyEqual.
// Also needed for 5095277
private static boolean proxyEqual(Object proxy1, Object proxy2, NamedMXBeans namedMXBeans) {
if (proxy1.getClass() != proxy2.getClass())
return proxy1.equals(proxy2);
InvocationHandler ih1 = Proxy.getInvocationHandler(proxy1);
InvocationHandler ih2 = Proxy.getInvocationHandler(proxy2);
if (!(ih1 instanceof CompositeDataInvocationHandler) || !(ih2 instanceof CompositeDataInvocationHandler))
return proxy1.equals(proxy2);
CompositeData cd1 = ((CompositeDataInvocationHandler) ih1).getCompositeData();
CompositeData cd2 = ((CompositeDataInvocationHandler) ih2).getCompositeData();
return compositeDataEqual(cd1, cd2, namedMXBeans);
}
Aggregations