Search in sources :

Example 11 with LogMessageService

use of com.adaptris.core.services.LogMessageService 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 12 with LogMessageService

use of com.adaptris.core.services.LogMessageService in project interlok by adaptris.

the class IfElseTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    IfElse result = new IfElse();
    ConditionMetadata condition = new ConditionMetadata();
    condition.setMetadataKey("key1");
    condition.setOperator(new NotNull());
    Equals equals = new Equals();
    equals.setValue("myValue");
    ConditionMetadata condition2 = new ConditionMetadata();
    condition2.setMetadataKey("key2");
    condition2.setOperator(equals);
    ConditionOr conditionOr = new ConditionOr();
    ConditionExpression conditionExpression = new ConditionExpression();
    conditionExpression.setAlgorithm("(%message{key1} - 10) == %message{key2}");
    conditionOr.getConditions().add(conditionExpression);
    conditionOr.getConditions().add(condition2);
    ConditionAnd conditionAnd = new ConditionAnd();
    conditionAnd.getConditions().add(condition);
    conditionAnd.getConditions().add(conditionOr);
    conditionAnd.getConditions().add(new ConditionFunction("function evaluateScript(message) { return message.getMetadataValue('mykey').equals('myvalue');}"));
    ThenService thenSrvc = new ThenService();
    ElseService elseSrvc = new ElseService();
    thenSrvc.setService(new LogMessageService());
    elseSrvc.setService(new LogMessageService());
    result.setCondition(conditionAnd);
    result.setThen(thenSrvc);
    result.setOtherwise(elseSrvc);
    return result;
}
Also used : ConditionAnd(com.adaptris.core.services.conditional.conditions.ConditionAnd) ConditionFunction(com.adaptris.core.services.conditional.conditions.ConditionFunction) Equals(com.adaptris.core.services.conditional.operator.Equals) ConditionOr(com.adaptris.core.services.conditional.conditions.ConditionOr) ConditionExpression(com.adaptris.core.services.conditional.conditions.ConditionExpression) LogMessageService(com.adaptris.core.services.LogMessageService) ConditionMetadata(com.adaptris.core.services.conditional.conditions.ConditionMetadata) NotNull(com.adaptris.core.services.conditional.operator.NotNull)

Example 13 with LogMessageService

use of com.adaptris.core.services.LogMessageService in project interlok by adaptris.

the class CheckUniqueMetadataValueServiceTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    service.setUniqueId("CheckMetadataUniqueNess");
    service.setStoreFileUrl("file:///path/to/store.file");
    service.setMetadataKeyToCheck("metadata-key");
    BranchingServiceCollection sl = new BranchingServiceCollection();
    sl.addService(service);
    sl.setFirstServiceId(service.getUniqueId());
    sl.addService(new LogMessageService(CheckUniqueMetadataValueService.DEFAULT_SERVICE_ID_UNIQUE));
    sl.addService(new LogMessageService(CheckUniqueMetadataValueService.DEFAULT_SERVICE_ID_DUPLICATE));
    return sl;
}
Also used : BranchingServiceCollection(com.adaptris.core.BranchingServiceCollection) LogMessageService(com.adaptris.core.services.LogMessageService)

Example 14 with LogMessageService

use of com.adaptris.core.services.LogMessageService in project interlok by adaptris.

the class XStreamMarshallerTest method adapterInstanceFieldChecks.

// redmineID 2457 - ensures that marshalling/unmarshalling the given files results in no loss of data
public static void adapterInstanceFieldChecks(Adapter fromXML) {
    assertNotNull(fromXML);
    assertEquals("SimpleAdapterTest", fromXML.getUniqueId());
    assertTrue(fromXML.getEventHandler() instanceof DefaultEventHandler);
    assertTrue(((DefaultEventHandler) fromXML.getEventHandler()).getConnection() instanceof NullConnection);
    assertTrue(((DefaultEventHandler) fromXML.getEventHandler()).getProducer() instanceof NullMessageProducer);
    // ShutdownWaitSeconds is now null.
    assertNull(((DefaultEventHandler) fromXML.getEventHandler()).getShutdownWaitSeconds());
    assertTrue(fromXML.getMessageErrorHandler() instanceof NullProcessingExceptionHandler);
    Channel channel = fromXML.getChannelList().get(0);
    assertTrue(channel.getConsumeConnection() instanceof NullConnection);
    assertTrue(channel.getProduceConnection() instanceof NullConnection);
    // Check workflow
    WorkflowList workflowList = channel.getWorkflowList();
    assertNotNull(workflowList);
    assertEquals(1, workflowList.size());
    // test workflow
    StandardWorkflow standardWorkflow = (StandardWorkflow) workflowList.get(0);
    assertNotNull(standardWorkflow);
    assertEquals("workflow1", standardWorkflow.getUniqueId());
    // test workflow consumer
    NullMessageConsumer consumer = (NullMessageConsumer) standardWorkflow.getConsumer();
    assertNotNull(consumer);
    // test services
    ServiceCollection serviceCollection = standardWorkflow.getServiceCollection();
    assertNotNull(serviceCollection);
    assertEquals("serviceListID1", serviceCollection.getUniqueId());
    assertEquals(3, serviceCollection.size());
    assertTrue(serviceCollection instanceof ServiceList);
    // test service 1
    Service service1 = serviceCollection.get(0);
    assertEquals("serviceID1", service1.getUniqueId());
    assertTrue(service1 instanceof AddMetadataService);
    Set<MetadataElement> metadataElements = ((AddMetadataService) service1).getMetadataElements();
    assertEquals(1, metadataElements.size());
    for (Iterator<MetadataElement> iterator = metadataElements.iterator(); iterator.hasNext(); ) {
        MetadataElement metadataElement = iterator.next();
        assertEquals("key1", metadataElement.getKey());
        assertEquals("val1", metadataElement.getValue());
        break;
    }
    // test service 2
    Service service2 = serviceCollection.get(1);
    assertEquals("serviceID2", service2.getUniqueId());
    assertTrue(service2 instanceof XpathMetadataService);
    List<XpathQuery> xpathQueries = ((XpathMetadataService) service2).getXpathQueries();
    assertEquals(1, xpathQueries.size());
    assertEquals(ConfiguredXpathQuery.class, xpathQueries.get(0).getClass());
    assertEquals("/a/b/c", ((ConfiguredXpathQuery) xpathQueries.get(0)).getXpathQuery());
    // Test service3
    Service service3 = serviceCollection.get(2);
    assertEquals("serviceID3", service3.getUniqueId());
    assertTrue(service3 instanceof LogMessageService);
    assertTrue(StringUtils.isBlank(((LogMessageService) service3).getLogPrefix()));
}
Also used : LogMessageService(com.adaptris.core.services.LogMessageService) XpathMetadataService(com.adaptris.core.services.metadata.XpathMetadataService) LogMessageService(com.adaptris.core.services.LogMessageService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) XpathQuery(com.adaptris.core.services.metadata.xpath.XpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) XpathMetadataService(com.adaptris.core.services.metadata.XpathMetadataService)

Example 15 with LogMessageService

use of com.adaptris.core.services.LogMessageService in project interlok by adaptris.

the class SharedServiceTest method retrieveObjectForCastorRoundTrip.

@Override
protected Service retrieveObjectForCastorRoundTrip() {
    // bit of a frig really, but otherwise we can't "lookup" in JNDI
    SharedService sharedService = new SharedService(getName());
    sharedService.setClonedService(new LogMessageService(getName()));
    return sharedService;
}
Also used : LogMessageService(com.adaptris.core.services.LogMessageService)

Aggregations

LogMessageService (com.adaptris.core.services.LogMessageService)18 BranchingServiceCollection (com.adaptris.core.BranchingServiceCollection)7 ServiceList (com.adaptris.core.ServiceList)4 ConditionMetadata (com.adaptris.core.services.conditional.conditions.ConditionMetadata)3 ConditionOr (com.adaptris.core.services.conditional.conditions.ConditionOr)3 NotNull (com.adaptris.core.services.conditional.operator.NotNull)3 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)3 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)3 IsNull (com.adaptris.core.services.conditional.operator.IsNull)2 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 CoreException (com.adaptris.core.CoreException)1 NullService (com.adaptris.core.NullService)1 ServiceCollection (com.adaptris.core.ServiceCollection)1 ServiceException (com.adaptris.core.ServiceException)1 ExpiringMapCache (com.adaptris.core.cache.ExpiringMapCache)1 ConstantDataInputParameter (com.adaptris.core.common.ConstantDataInputParameter)1 FsConsumer (com.adaptris.core.fs.FsConsumer)1 FsProducer (com.adaptris.core.fs.FsProducer)1 JmsConnection (com.adaptris.core.jms.JmsConnection)1