use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class MessageThresholdNotificationTest method testNotification_ErrorThresholdNotExceeded.
@Test
public void testNotification_ErrorThresholdNotExceeded() throws Exception {
MessageThresholdNotification notif = new MessageThresholdNotification(getName());
notif.setErrorThreshold(100L);
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);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
} finally {
stop(adapter);
}
assertEquals(0, listener.getNotifications().size());
}
use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class MessageThresholdNotificationTest method testNotification_NoNotifications.
@Test
public void testNotification_NoNotifications() throws Exception {
MessageThresholdNotification notif = new MessageThresholdNotification(getName());
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);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
} finally {
stop(adapter);
}
assertEquals(0, listener.getNotifications().size());
}
use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class MetadataCountMBeanTest method testGetMetadataStatistics.
@Test
public void testGetMetadataStatistics() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
MetadataTotalsInterceptor interceptor = createInterceptor();
interceptor.setUniqueId(getName());
Adapter adapter = createSingleChannelAdapter(adapterName, interceptor);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
try {
start(adapter);
register(mBeans);
ObjectName workflowObj = createWorkflowObjectName(adapterName);
ObjectName metricsObj = createMetricsObjectName(adapterName, getName());
MetadataStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MetadataStatisticsMBean.class);
WorkflowManagerMBean workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
SerializableAdaptrisMessage msg = createMessageForInjection(null);
workflow.processAsync(msg);
assertEquals(1, stats.getStatistics().size());
assertEquals(interceptor.getStats().size(), stats.getStatistics().size());
MetadataStatistic interceptorStat = (MetadataStatistic) interceptor.getStats().get(0);
MetadataStatistic mbeanStat = stats.getStatistics().get(0);
// They're not objectively equals (not clones), and no equals method.
assertNotSame(interceptorStat, mbeanStat);
assertEquals(interceptorStat.getEndMillis(), mbeanStat.getEndMillis());
assertEquals(interceptorStat.getMetadataStatistics(), mbeanStat.getMetadataStatistics());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class StatisticsMBeanCase method createJmxManagers.
protected List<BaseComponentMBean> createJmxManagers(Adapter adapter) throws Exception {
List<BaseComponentMBean> result = new ArrayList<BaseComponentMBean>();
AdapterManager am = new AdapterManager(adapter);
result.add(am);
result.addAll(am.getAllDescendants());
return result;
}
use of com.adaptris.core.runtime.BaseComponentMBean in project interlok by adaptris.
the class StatisticsMBeanCase method testStandardGetters.
@Test
public void testStandardGetters() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager am = new AdapterManager(adapter);
try {
start(adapter);
am.registerMBean();
Collection<BaseComponentMBean> children = am.getAllDescendants();
for (BaseComponentMBean bean : children) {
assertNotNull(bean.createObjectName());
if (bean instanceof ChildRuntimeInfoComponent) {
assertNotNull(((ChildRuntimeInfoComponent) bean).getParentId());
assertNotNull(((ChildRuntimeInfoComponent) bean).getParentObjectName());
assertNotNull(((ChildRuntimeInfoComponent) bean).getParentRuntimeInfoComponent());
}
}
} finally {
stop(adapter);
am.unregisterMBean();
}
}
Aggregations