Search in sources :

Example 1 with SerializableAdaptrisMessage

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;
}
Also used : SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement)

Example 2 with SerializableAdaptrisMessage

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;
}
Also used : SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement)

Example 3 with SerializableAdaptrisMessage

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);
    }
}
Also used : WorkflowManagerMBean(com.adaptris.core.runtime.WorkflowManagerMBean) BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) Adapter(com.adaptris.core.Adapter) SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 4 with SerializableAdaptrisMessage

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;
}
Also used : SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement)

Example 5 with SerializableAdaptrisMessage

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();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) ObjectName(javax.management.ObjectName) GuidGenerator(com.adaptris.util.GuidGenerator) Test(org.junit.Test)

Aggregations

SerializableAdaptrisMessage (com.adaptris.core.SerializableAdaptrisMessage)9 Adapter (com.adaptris.core.Adapter)5 ObjectName (javax.management.ObjectName)5 Test (org.junit.Test)5 MetadataElement (com.adaptris.core.MetadataElement)4 BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)3 WorkflowManagerMBean (com.adaptris.core.runtime.WorkflowManagerMBean)3 Channel (com.adaptris.core.Channel)2 StandardWorkflow (com.adaptris.core.StandardWorkflow)2 GuidGenerator (com.adaptris.util.GuidGenerator)2 ArrayList (java.util.ArrayList)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)1 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)1