Search in sources :

Example 36 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class MultiPayloadXmlTransformServiceTest method testResolvableExpressionParameter_XSLTOutput.

@Test
public void testResolvableExpressionParameter_XSLTOutput() throws Exception {
    MultiPayloadAdaptrisMessage message = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
    message.addPayload("somePayload", "World".getBytes());
    MultiPayloadXmlTransformService service = createBaseExample();
    ResolvableExpressionParameter params = new ResolvableExpressionParameter();
    KeyValuePairList exprns = new KeyValuePairList();
    exprns.add(new KeyValuePair("world", "%payload{id:somePayload}"));
    params.setExpressions(exprns);
    service.setTransformParameter(params);
    execute(service, message);
    assertEquals(PROPERTIES.getProperty(KEY_XML_TEST_OUTPUT) + "World", message.getContent(PAYLOAD_ID_OUTPUT));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairList(com.adaptris.util.KeyValuePairList) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

Example 37 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class XpathDocumentCopierTest method testSplit_DocTypeNotAllowed.

@Test
public void testSplit_DocTypeNotAllowed() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.setContent(XML_WITH_DOCTYPE, msg.getContentEncoding());
    XpathDocumentCopier splitter = new XpathDocumentCopier(XPATH_DOCUMENT_COUNT);
    DocumentBuilderFactoryBuilder builder = new DocumentBuilderFactoryBuilder();
    builder.getFeatures().add(new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true"));
    splitter.setXmlDocumentFactoryConfig(builder);
    try {
        List<AdaptrisMessage> result = splitToList(splitter, msg);
        fail();
    } catch (CoreException expected) {
        assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Test(org.junit.Test)

Example 38 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class XpathSplitterTest method testSplit_DocTypeNotAllowed.

@Test
public void testSplit_DocTypeNotAllowed() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.setContent(XML_WITH_DOCTYPE, msg.getContentEncoding());
    XpathMessageSplitter splitter = new XpathMessageSplitter(ENVELOPE_DOCUMENT, ENCODING_UTF8);
    DocumentBuilderFactoryBuilder builder = new DocumentBuilderFactoryBuilder();
    builder.getFeatures().add(new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true"));
    splitter.setXmlDocumentFactoryConfig(builder);
    try {
        splitter.splitMessage(msg);
        fail();
    } catch (CoreException expected) {
        assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Test(org.junit.Test) XpathMetadataServiceTest(com.adaptris.core.services.metadata.XpathMetadataServiceTest)

Example 39 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class XpathSplitterTest method testSetNamespaceContext.

@Test
public void testSetNamespaceContext() throws Exception {
    XpathMessageSplitter obj = new XpathMessageSplitter();
    assertNull(obj.getNamespaceContext());
    KeyValuePairSet kvps = new KeyValuePairSet();
    kvps.add(new KeyValuePair("hello", "world"));
    obj.setNamespaceContext(kvps);
    assertEquals(kvps, obj.getNamespaceContext());
    obj.setNamespaceContext(null);
    assertNull(obj.getNamespaceContext());
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test) XpathMetadataServiceTest(com.adaptris.core.services.metadata.XpathMetadataServiceTest)

Example 40 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class CommonsSystemCommandExecutorServiceTest method testDoService_WithStaticEnvironment.

@Test
public void testDoService_WithStaticEnvironment() throws Exception {
    Thread.currentThread().setName(getName());
    DefaultCommandBuilder builder = createEchoCommandWithEnvVar(KEY_ENV);
    builder.getEnvironmentProperties().add(new KeyValuePair(KEY_ENV, VALUE_ENV));
    SystemCommandExecutorService service = new SystemCommandExecutorService(builder, new OverwritePayload());
    AdaptrisMessage msg = createMessage();
    execute(service, msg);
    assertEquals(VALUE_ENV, StringUtils.strip(msg.getContent()));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Aggregations

KeyValuePair (com.adaptris.util.KeyValuePair)143 Test (org.junit.Test)79 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)55 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)26 KeyValuePairList (com.adaptris.util.KeyValuePairList)12 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)11 StandaloneProducer (com.adaptris.core.StandaloneProducer)10 Channel (com.adaptris.core.Channel)9 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)9 TimeInterval (com.adaptris.util.TimeInterval)9 ServiceException (com.adaptris.core.ServiceException)7 JmsConnection (com.adaptris.core.jms.JmsConnection)6 ArrayList (java.util.ArrayList)6 CoreException (com.adaptris.core.CoreException)5 StandardWorkflow (com.adaptris.core.StandardWorkflow)5 PasProducer (com.adaptris.core.jms.PasProducer)5 MetadataCollection (com.adaptris.core.MetadataCollection)4 MetadataElement (com.adaptris.core.MetadataElement)4 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3