Search in sources :

Example 6 with SerializableAdaptrisMessage

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

Example 7 with SerializableAdaptrisMessage

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);
    }
}
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 8 with SerializableAdaptrisMessage

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);
    }
}
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 9 with SerializableAdaptrisMessage

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

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