use of com.adaptris.core.Adapter in project interlok by adaptris.
the class MessageMetricsStatisticsByMetadataTest method testGetMessageStatistics.
@Override
public void testGetMessageStatistics() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
String payload = "SomePayload";
MessageMetricsInterceptorByMetadata 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());
MessageMetricsStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
MessageProcessor workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
workflow.processAsync(createMessageForInjection(payload));
assertEquals(1, stats.getStatistics().size());
assertEquals(interceptor.getStats().size(), stats.getStatistics().size());
MessageStatistic interceptorStat = (MessageStatistic) interceptor.getStats().get(0);
MessageStatistic 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.getTotalMessageCount(), mbeanStat.getTotalMessageCount());
assertEquals(interceptorStat.getTotalMessageErrorCount(), mbeanStat.getTotalMessageErrorCount());
assertEquals(interceptorStat.getTotalMessageSize(), mbeanStat.getTotalMessageSize());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class MessageMetricsStatisticsTest method testGetMessageStatistics.
@Test
public void testGetMessageStatistics() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
String payload = "SomePayload";
MessageMetricsInterceptor interceptor = (MessageMetricsInterceptor) 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());
MessageMetricsStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
MessageProcessor workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
workflow.processAsync(createMessageForInjection(payload));
assertEquals(1, stats.getStatistics().size());
assertEquals(interceptor.getStats().size(), stats.getStatistics().size());
MessageStatistic interceptorStat = (MessageStatistic) interceptor.getStats().get(0);
MessageStatistic 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.getTotalMessageCount(), mbeanStat.getTotalMessageCount());
assertEquals(interceptorStat.getTotalMessageErrorCount(), mbeanStat.getTotalMessageErrorCount());
assertEquals(interceptorStat.getTotalMessageSize(), mbeanStat.getTotalMessageSize());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class MessageMetricsStatisticsTest method testNoCachesExists.
@Test
public void testNoCachesExists() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
try {
start(adapter);
register(mBeans);
ObjectName adapterObj = createAdapterObjectName(adapterName);
ObjectName metricsObj = createMetricsObjectName(adapterName);
MessageMetricsStatisticsMBean metrics = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
assertEquals(0, metrics.getNumberOfTimeSlices());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class MessageNotificationCase method createAdapter.
protected Adapter createAdapter(String uid, Workflow... workflows) throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(uid);
adapter.getChannelList().add(createChannel(uid + "_Channel", workflows));
return adapter;
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class SlowMessageNotificationTest method testNotification_SentAsPartOfCleanup.
@Test
public void testNotification_SentAsPartOfCleanup() throws Exception {
SlowMessageNotification notif = new SlowMessageNotification(getName(), new TimeInterval(100L, TimeUnit.MILLISECONDS), new TimeInterval(200L, TimeUnit.MILLISECONDS));
StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
workflow.getServiceCollection().add(new WaitService(new TimeInterval(500L, TimeUnit.MILLISECONDS)));
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();
workflow.onAdaptrisMessage(msg);
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification notification = listener.getNotifications().get(0);
Properties userData = (Properties) notification.getUserData();
assertEquals(msg.getUniqueId(), userData.getProperty(SlowMessageNotification.KEY_MESSAGE_ID));
assertEquals("-1", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_DURATION));
assertEquals("-1", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_END));
assertEquals("false", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_SUCCESS));
} finally {
stop(adapter);
}
}
Aggregations