use of com.adaptris.core.SerializableAdaptrisMessage in project interlok by adaptris.
the class MessageMetricsStatisticsByMetadataTest method createMessageForInjection.
@Override
protected SerializableAdaptrisMessage createMessageForInjection(String payload) {
SerializableAdaptrisMessage msg = null;
if (!isEmpty(payload)) {
msg = new SerializableAdaptrisMessage(GUID.getUUID(), payload);
} else {
msg = new SerializableAdaptrisMessage(GUID.getUUID());
}
msg.addMetadata(new MetadataElement("messageType", "Order"));
return msg;
}
use of com.adaptris.core.SerializableAdaptrisMessage in project interlok by adaptris.
the class MetadataTotalsMBeanTest method createMessageForInjection.
@Override
protected SerializableAdaptrisMessage createMessageForInjection(String payload) {
SerializableAdaptrisMessage msg = null;
if (!isEmpty(payload)) {
msg = new SerializableAdaptrisMessage(GUID.getUUID(), payload);
} else {
msg = new SerializableAdaptrisMessage(GUID.getUUID());
}
msg.addMetadata(new MetadataElement(METADATA_KEY1, STATS_KEY));
return msg;
}
use of com.adaptris.core.SerializableAdaptrisMessage 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.SerializableAdaptrisMessage in project interlok by adaptris.
the class MetadataCountMBeanTest method createMessageForInjection.
@Override
protected SerializableAdaptrisMessage createMessageForInjection(String payload) {
SerializableAdaptrisMessage msg = null;
if (!isEmpty(payload)) {
msg = new SerializableAdaptrisMessage(GUID.getUUID(), payload);
} else {
msg = new SerializableAdaptrisMessage(GUID.getUUID());
}
msg.addMetadata(new MetadataElement(COUNTER_1, "10"));
msg.addMetadata(new MetadataElement(COUNTER_2, "10"));
return msg;
}
use of com.adaptris.core.SerializableAdaptrisMessage in project interlok by adaptris.
the class WorkflowManagerTest method testInjectMessage.
@Test
public void testInjectMessage() 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");
MockMessageProducer mockProducer = new MockMessageProducer();
workflow.setProducer(mockProducer);
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();
workflowManagerProxy.processAsync(msg);
assertEquals(1, mockProducer.getMessages().size());
AdaptrisMessage procMsg = mockProducer.getMessages().get(0);
assertEquals(msgUniqueId, procMsg.getUniqueId());
assertEquals(PAYLOAD, procMsg.getContent());
assertEquals(PAYLOAD_ENCODING, procMsg.getContentEncoding());
assertTrue(procMsg.headersContainsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, procMsg.getMetadataValue(METADATA_KEY));
} finally {
adapter.requestClose();
}
}
Aggregations