Search in sources :

Example 41 with ServiceList

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;
}
Also used : ServiceList(com.adaptris.core.ServiceList) LogMessageService(com.adaptris.core.services.LogMessageService) FileWriter(java.io.FileWriter) File(java.io.File)

Example 42 with ServiceList

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()));
}
Also used : 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)

Example 43 with ServiceList

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()));
}
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) SelectByPosition(com.adaptris.util.text.mime.SelectByPosition) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 44 with ServiceList

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);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) InputStream(java.io.InputStream) LogMessageService(com.adaptris.core.services.LogMessageService) Test(org.junit.Test)

Example 45 with ServiceList

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);
}
Also used : ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) LogMessageService(com.adaptris.core.services.LogMessageService) StopProcessingService(com.adaptris.core.services.StopProcessingService) StopProcessingService(com.adaptris.core.services.StopProcessingService) Test(org.junit.Test)

Aggregations

ServiceList (com.adaptris.core.ServiceList)64 Test (org.junit.Test)52 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)43 StandaloneProducer (com.adaptris.core.StandaloneProducer)39 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)33 Channel (com.adaptris.core.Channel)31 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)29 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)23 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)20 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)20 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)20 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)18 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)18 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)17 Service (com.adaptris.core.Service)16 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)16 MetadataElement (com.adaptris.core.MetadataElement)14 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)11 LogMessageService (com.adaptris.core.services.LogMessageService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10