use of com.adaptris.core.SerializableAdaptrisMessage in project interlok by adaptris.
the class WorkflowManagerTest method testInjectWithReply.
@Test
public void testInjectWithReply() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
StandardWorkflow workflow = createWorkflow("w1");
workflow.getServiceCollection().add(new AddMetadataService(Arrays.asList(new MetadataElement(getName(), getName()))));
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
channelManager.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
String msgUniqueId = new GuidGenerator().getUUID();
SerializableAdaptrisMessage msg = createSAM(msgUniqueId);
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
adapterManager.requestStart();
SerializableAdaptrisMessage reply = (SerializableAdaptrisMessage) workflowManagerProxy.process(msg);
assertEquals(msgUniqueId, reply.getUniqueId());
assertEquals(PAYLOAD, reply.getContent());
assertEquals(PAYLOAD_ENCODING, reply.getContentEncoding());
assertTrue(reply.containsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, reply.getMetadataValue(METADATA_KEY));
assertTrue(reply.containsKey(getName()));
assertEquals(getName(), reply.getMetadataValue(getName()));
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.SerializableAdaptrisMessage in project interlok by adaptris.
the class MetadataTotalsMBeanTest method testGetMetadataStatistics.
@Test
public void testGetMetadataStatistics() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
MetadataCountInterceptor 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.SerializableAdaptrisMessage in project interlok by adaptris.
the class MessageMetricsStatisticsTest method testGetTotalStringStats.
@Test
public void testGetTotalStringStats() 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);
MessageMetricsStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
WorkflowManagerMBean workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
assertNotNull(stats.getTotalStringStats());
SerializableAdaptrisMessage msg = createMessageForInjection(null);
workflow.processAsync(msg);
assertNotNull(stats.getTotalStringStats());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.SerializableAdaptrisMessage in project interlok by adaptris.
the class WorkflowManagerTest method createSAM.
private SerializableAdaptrisMessage createSAM(String msgUniqueId) {
SerializableAdaptrisMessage msg = new SerializableAdaptrisMessage();
msg.setUniqueId(msgUniqueId);
msg.setContent(PAYLOAD);
msg.setContentEncoding(PAYLOAD_ENCODING);
msg.addMetadata(METADATA_KEY, METADATA_VALUE);
return msg;
}
Aggregations