use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class ServiceFromUrlTest method createService.
private File createService() throws Exception {
File f = TempFileUtils.createTrackedFile(this);
String xml = DynamicServiceExecutorTest.createMessage(new ServiceList(new Service[] { new LogMessageService() })).getContent();
try (FileWriter w = new FileWriter(f, false)) {
w.write(xml);
}
return f;
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class DynamicServiceExecutorTest method testDoService_MimeServiceExtractor_ByContentId.
@Test
public void testDoService_MimeServiceExtractor_ByContentId() throws Exception {
AddMetadataService metadataService = new AddMetadataService();
metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
DynamicServiceExecutor dynamicService = createService();
dynamicService.setServiceExtractor(new MimeServiceExtractor(new SelectByContentId("Service")));
AdaptrisMessage msg = createMimeMessage(new ServiceList(new Service[] { metadataService }), ENCODING_8BIT);
execute(dynamicService, msg);
assertEquals(getName(), msg.getMetadataValue(getName()));
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class DynamicServiceExecutorTest method testDoService_MimeServiceExtractor_ByPosition.
@Test
public void testDoService_MimeServiceExtractor_ByPosition() throws Exception {
AddMetadataService metadataService = new AddMetadataService();
metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
DynamicServiceExecutor dynamicService = createService();
dynamicService.setServiceExtractor(new MimeServiceExtractor(new SelectByPosition(0)));
AdaptrisMessage msg = createMimeMessage(new ServiceList(new Service[] { metadataService }), ENCODING_7BIT);
execute(dynamicService, msg);
assertEquals(getName(), msg.getMetadataValue(getName()));
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class ServiceFromDataInputTest method testGetInputStream.
@Test
public void testGetInputStream() throws Exception {
String xml = DynamicServiceExecutorTest.createMessage(new ServiceList(new Service[] { new LogMessageService() })).getContent();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
ServiceFromDataInputParameter serviceExtractor = new ServiceFromDataInputParameter(new ConstantDataInputParameter(xml));
try {
LifecycleHelper.initAndStart(serviceExtractor);
try (InputStream in = serviceExtractor.getInputStream(msg)) {
assertNotNull(in);
assertEquals(ServiceList.class, DefaultMarshaller.getDefaultMarshaller().unmarshal(in).getClass());
}
} finally {
LifecycleHelper.stopAndClose(serviceExtractor);
}
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class WhileTest method testStopProcessingServiceCancelsLoop.
@Test
public void testStopProcessingServiceCancelsLoop() throws Exception {
when(mockCondition.evaluate(message)).thenReturn(true);
Service stopProcessingService = new StopProcessingService();
ServiceList services = new ServiceList();
services.add(stopProcessingService);
services.add(mockService);
thenService = new ThenService();
thenService.setService(services);
logicalExpression = new While().withThen(thenService).withCondition(mockCondition);
startMe(logicalExpression);
logicalExpression.doService(message);
// The default would loop 10 times, but the stop-processing-service should limit us to only a single loop.
verify(mockCondition, times(1)).evaluate(message);
}
Aggregations