use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class JmsTransactedWorkflowTest method createPlainChannel.
private Channel createPlainChannel() throws Exception {
GuidGenerator guid = new GuidGenerator();
Channel result = new MockChannel();
result.setUniqueId(guid.create(result));
result.setMessageErrorHandler(new NullProcessingExceptionHandler());
return result;
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class BasicActiveMqConsumerTest method createDurableSubsAdapter.
private Adapter createDurableSubsAdapter(String adapterName, EmbeddedActiveMq activeMqBroker) throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(adapterName);
Channel c = new Channel();
JmsConnection conn = activeMqBroker.getJmsConnection(createVendorImpl());
conn.setClientId(MY_CLIENT_ID);
c.setConsumeConnection(conn);
StandardWorkflow swf = new StandardWorkflow();
PasConsumer pasConsumer = new PasConsumer().withTopic(new GuidGenerator().safeUUID());
pasConsumer.setSubscriptionId(MY_SUBSCRIPTION_ID);
swf.setConsumer(pasConsumer);
c.getWorkflowList().add(swf);
ChannelList cl = new ChannelList();
cl.addChannel(c);
adapter.setChannelList(cl);
return adapter;
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FileBackedMimeEncoderTest method generateOutput.
private File generateOutput() throws Exception {
File file = TempFileUtils.createTrackedFile(this);
MultiPartOutput output = new MultiPartOutput(new GuidGenerator().getUUID());
output.addPart(STANDARD_PAYLOAD.getBytes(), "base64", "AdaptrisMessage/payload");
Properties p = new Properties();
p.setProperty(METADATA_KEY, METADATA_VALUE);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
p.store(bytes, "");
bytes.close();
output.addPart(bytes.toByteArray(), "base64", "AdaptrisMessage/metadata");
output.addPart(STANDARD_PAYLOAD_NON_JUST_ALPHA.getBytes(), "base64", "Dude/SomeOtherPart");
try (FileOutputStream out = new FileOutputStream(file)) {
output.writeTo(out);
}
return file;
}
use of com.adaptris.util.GuidGenerator 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();
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class WorkflowManagerTest method testProcess.
@Test
public void testProcess() 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();
SerializableMessage msg = createSM(msgUniqueId);
try {
register(mBeans);
MessageProcessor workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
adapterManager.requestStart();
SerializableMessage reply = workflowManagerProxy.process(msg);
assertEquals(msgUniqueId, reply.getUniqueId());
assertEquals(PAYLOAD, reply.getContent());
assertEquals(PAYLOAD_ENCODING, reply.getContentEncoding());
Map<String, String> headers = reply.getMessageHeaders();
assertTrue(headers.containsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, headers.get(METADATA_KEY));
assertTrue(headers.containsKey(getName()));
assertEquals(getName(), headers.get(getName()));
assertEquals("", reply.getNextServiceId());
} finally {
adapter.requestClose();
}
}
Aggregations