use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class StatisticsMBeanCase method register.
protected void register(Collection<BaseComponentMBean> mBeans) throws Exception {
for (BaseComponentMBean bean : mBeans) {
ObjectName name = bean.createObjectName();
registeredObjects.add(name);
mBeanServer.registerMBean(bean, name);
log.trace("MBean [" + bean + "] registered");
}
}
use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class StatisticsMBeanCase method testGetTimesliceDuration.
@Test
public void testGetTimesliceDuration() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
try {
start(adapter);
register(mBeans);
ObjectName workflowObj = createWorkflowObjectName(adapterName);
ObjectName metricsObj = createMetricsObjectName(adapterName);
MetricsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MetricsMBean.class);
WorkflowManagerMBean workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
assertEquals(10, stats.getTimeSliceDurationSeconds());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class StatisticsMBeanCase method testGet_NoTimeslicesAvailable.
@Test
public void testGet_NoTimeslicesAvailable() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
try {
start(adapter);
register(mBeans);
ObjectName workflowObj = createWorkflowObjectName(adapterName);
ObjectName metricsObj = createMetricsObjectName(adapterName);
MetricsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MetricsMBean.class);
WorkflowManagerMBean workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
assertEquals(0, stats.getNumberOfTimeSlices());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class MessageThresholdNotificationTest method testNotification_ErrorThresholdExceeded.
@Test
public void testNotification_ErrorThresholdExceeded() throws Exception {
MessageThresholdNotification notif = new MessageThresholdNotification(getName());
notif.setErrorThreshold(0L);
StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
workflow.getServiceCollection().add(new AlwaysFailService());
Adapter adapter = createAdapter(getName(), workflow);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
BaseComponentMBean notifier = getFirstImpl(mBeans, InterceptorNotificationMBean.class);
assertNotNull(notifier);
ObjectName notifObjName = notifier.createObjectName();
SimpleNotificationListener listener = new SimpleNotificationListener();
try {
start(adapter);
register(mBeans);
mBeanServer.addNotificationListener(notifObjName, listener, null, null);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World");
workflow.onAdaptrisMessage(msg);
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification notification = listener.getNotifications().get(0);
Properties userData = (Properties) notification.getUserData();
assertEquals("11", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_SIZE));
assertEquals("1", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_COUNT));
assertEquals("1", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_ERROR));
} finally {
stop(adapter);
}
}
use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class MessageThresholdNotificationTest method testNotification_CountThresholdExceeded.
@Test
public void testNotification_CountThresholdExceeded() throws Exception {
MessageThresholdNotification notif = new MessageThresholdNotification(getName());
notif.setCountThreshold(0L);
StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
Adapter adapter = createAdapter(getName(), workflow);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
BaseComponentMBean notifier = getFirstImpl(mBeans, InterceptorNotificationMBean.class);
assertNotNull(notifier);
ObjectName notifObjName = notifier.createObjectName();
SimpleNotificationListener listener = new SimpleNotificationListener();
try {
start(adapter);
register(mBeans);
mBeanServer.addNotificationListener(notifObjName, listener, null, null);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World");
workflow.onAdaptrisMessage(msg);
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification notification = listener.getNotifications().get(0);
Properties userData = (Properties) notification.getUserData();
assertEquals("11", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_SIZE));
assertEquals("1", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_COUNT));
assertEquals("0", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_ERROR));
} finally {
stop(adapter);
}
}
Aggregations