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));
}
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"));
}
}
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"));
}
}
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());
}
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()));
}
Aggregations