use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class PasswordDecodeMetadataFilterTest method testFilter_NoMatches.
@Test
public void testFilter_NoMatches() throws Exception {
PasswordDecodeMetadataFilter filter = new PasswordDecodeMetadataFilter();
AdaptrisMessage msg = createMessage();
MetadataCollection filtered = filter.filter(msg);
assertEquals(3, filtered.size());
// Changes not reflected in the underlying message.
assertNotSame("password1", msg.getMetadataValue("passwordKey1"));
assertNotSame("password2", msg.getMetadataValue("passwordKey2"));
assertEquals("PW:WillNotDecode", msg.getMetadataValue("key1"));
for (MetadataElement e : filtered) {
if ("passwordKey1".equalsIgnoreCase(e.getKey())) {
assertTrue(e.getValue().startsWith("PW:"));
}
if ("passwordKey2".equalsIgnoreCase(e.getKey())) {
assertTrue(e.getValue().startsWith("PW:"));
}
}
}
use of com.adaptris.core.MetadataElement 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();
}
}
use of com.adaptris.core.MetadataElement 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.MetadataElement 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.MetadataElement in project interlok by adaptris.
the class AddToCacheServiceTest method testDoService.
@Test
public void testDoService() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(JmsConstants.JMS_CORRELATION_ID, CORRELATION_ID) }));
Cache cache = createCacheInstanceForTests();
AddToCacheService service = createServiceForTests();
try {
service.setConnection(new CacheConnection(cache));
service.setEnforceSerializable(false);
start(service);
service.doService(msg);
Object value = cache.get(CORRELATION_ID);
assertTrue("Cached object should be a JMS Queue", value instanceof Queue);
assertEquals(QUEUE_NAME, ((Queue) value).getQueueName());
} finally {
stop(service);
}
}
Aggregations