Search in sources :

Example 6 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService 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 AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService in project interlok by adaptris.

the class EmbeddedScriptingServiceTest method testBranchingServiceExcecution_NextServiceId.

@Test
public void testBranchingServiceExcecution_NextServiceId() throws Exception {
    BranchingServiceCollection bsc = new BranchingServiceCollection();
    bsc.setFirstServiceId(getName());
    bsc.add(createServiceForBranch(getName(), NEXT_SERVICE_ID));
    AddMetadataService next = new AddMetadataService(new ArrayList<>(Arrays.asList(new MetadataElement(MY_METADATA_KEY2, MY_METADATA_VALUE))));
    next.setUniqueId(NEXT_SERVICE_ID);
    bsc.add(next);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.addMetadata(MY_METADATA_KEY, MY_METADATA_VALUE);
    execute(bsc, msg);
    assertEquals(MY_METADATA_VALUE, msg.getMetadataValue(MY_METADATA_KEY));
    assertEquals(MY_METADATA_VALUE, msg.getMetadataValue(MY_METADATA_KEY2));
}
Also used : BranchingServiceCollection(com.adaptris.core.BranchingServiceCollection) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 8 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService in project interlok by adaptris.

the class MimeAggregatorCase method createAddMetadataService.

protected AddMetadataService createAddMetadataService(String key) {
    AddMetadataService service = new AddMetadataService();
    service.addMetadataElement(key, "$UNIQUE_ID$");
    return service;
}
Also used : AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService)

Example 9 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService in project interlok by adaptris.

the class DynamicServiceExecutorTest method testDoService_DefaultServiceExtractor_WithMarshaller.

@Test
public void testDoService_DefaultServiceExtractor_WithMarshaller() throws Exception {
    AddMetadataService metadataService = new AddMetadataService();
    metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
    DynamicServiceExecutor dynamicService = createService();
    dynamicService.setMarshaller(new XStreamMarshaller());
    AdaptrisMessage msg = createMessage(new ServiceList(new Service[] { metadataService }));
    execute(dynamicService, msg);
    assertEquals(getName(), msg.getMetadataValue(getName()));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) LogMessageService(com.adaptris.core.services.LogMessageService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) MetadataElement(com.adaptris.core.MetadataElement) XStreamMarshaller(com.adaptris.core.XStreamMarshaller) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 10 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService in project interlok by adaptris.

the class DynamicServiceExecutorTest method testDoService_MimeServiceExtractor_ByContentId_NotFound.

@Test
public void testDoService_MimeServiceExtractor_ByContentId_NotFound() throws Exception {
    AddMetadataService metadataService = new AddMetadataService();
    metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
    DynamicServiceExecutor dynamicService = createService();
    dynamicService.setServiceExtractor(new MimeServiceExtractor(new SelectByContentId("Blah")));
    AdaptrisMessage msg = createMimeMessage(new ServiceList(new Service[] { metadataService }), ENCODING_BASE64);
    try {
        execute(dynamicService, msg);
        fail();
    } catch (ServiceException expected) {
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) SelectByContentId(com.adaptris.util.text.mime.SelectByContentId) Service(com.adaptris.core.Service) LogMessageService(com.adaptris.core.services.LogMessageService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Aggregations

AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)46 Test (org.junit.Test)35 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)22 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)20 MetadataElement (com.adaptris.core.MetadataElement)18 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)18 MockChannel (com.adaptris.core.stubs.MockChannel)18 ServiceList (com.adaptris.core.ServiceList)16 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)15 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)15 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)15 Service (com.adaptris.core.Service)10 Iterator (java.util.Iterator)10 EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)9 StandaloneProducer (com.adaptris.core.StandaloneProducer)8 LogMessageService (com.adaptris.core.services.LogMessageService)7 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)6 Channel (com.adaptris.core.Channel)5 ArrayList (java.util.ArrayList)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3