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();
}
}
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));
}
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;
}
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()));
}
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) {
}
}
Aggregations